1
|
import * as tslib_1 from "tslib";
|
2
|
/**
|
3
|
* @license Angular v4.4.6
|
4
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
5
|
* License: MIT
|
6
|
*/
|
7
|
import { Injectable, NgModule, Version } from '@angular/core';
|
8
|
import { Observable } from 'rxjs/Observable';
|
9
|
import { ɵgetDOM } from '@angular/platform-browser';
|
10
|
/**
|
11
|
* @license
|
12
|
* Copyright Google Inc. All Rights Reserved.
|
13
|
*
|
14
|
* Use of this source code is governed by an MIT-style license that can be
|
15
|
* found in the LICENSE file at https://angular.io/license
|
16
|
*/
|
17
|
/**
|
18
|
* A backend for http that uses the `XMLHttpRequest` browser API.
|
19
|
*
|
20
|
* Take care not to evaluate this in non-browser contexts.
|
21
|
*
|
22
|
* \@experimental
|
23
|
*/
|
24
|
var BrowserXhr = (function () {
|
25
|
function BrowserXhr() {
|
26
|
}
|
27
|
/**
|
28
|
* @return {?}
|
29
|
*/
|
30
|
BrowserXhr.prototype.build = function () { return ((new XMLHttpRequest())); };
|
31
|
return BrowserXhr;
|
32
|
}());
|
33
|
BrowserXhr.decorators = [
|
34
|
{ type: Injectable },
|
35
|
];
|
36
|
/**
|
37
|
* @nocollapse
|
38
|
*/
|
39
|
BrowserXhr.ctorParameters = function () { return []; };
|
40
|
var RequestMethod = {};
|
41
|
RequestMethod.Get = 0;
|
42
|
RequestMethod.Post = 1;
|
43
|
RequestMethod.Put = 2;
|
44
|
RequestMethod.Delete = 3;
|
45
|
RequestMethod.Options = 4;
|
46
|
RequestMethod.Head = 5;
|
47
|
RequestMethod.Patch = 6;
|
48
|
RequestMethod[RequestMethod.Get] = "Get";
|
49
|
RequestMethod[RequestMethod.Post] = "Post";
|
50
|
RequestMethod[RequestMethod.Put] = "Put";
|
51
|
RequestMethod[RequestMethod.Delete] = "Delete";
|
52
|
RequestMethod[RequestMethod.Options] = "Options";
|
53
|
RequestMethod[RequestMethod.Head] = "Head";
|
54
|
RequestMethod[RequestMethod.Patch] = "Patch";
|
55
|
var ReadyState = {};
|
56
|
ReadyState.Unsent = 0;
|
57
|
ReadyState.Open = 1;
|
58
|
ReadyState.HeadersReceived = 2;
|
59
|
ReadyState.Loading = 3;
|
60
|
ReadyState.Done = 4;
|
61
|
ReadyState.Cancelled = 5;
|
62
|
ReadyState[ReadyState.Unsent] = "Unsent";
|
63
|
ReadyState[ReadyState.Open] = "Open";
|
64
|
ReadyState[ReadyState.HeadersReceived] = "HeadersReceived";
|
65
|
ReadyState[ReadyState.Loading] = "Loading";
|
66
|
ReadyState[ReadyState.Done] = "Done";
|
67
|
ReadyState[ReadyState.Cancelled] = "Cancelled";
|
68
|
var ResponseType = {};
|
69
|
ResponseType.Basic = 0;
|
70
|
ResponseType.Cors = 1;
|
71
|
ResponseType.Default = 2;
|
72
|
ResponseType.Error = 3;
|
73
|
ResponseType.Opaque = 4;
|
74
|
ResponseType[ResponseType.Basic] = "Basic";
|
75
|
ResponseType[ResponseType.Cors] = "Cors";
|
76
|
ResponseType[ResponseType.Default] = "Default";
|
77
|
ResponseType[ResponseType.Error] = "Error";
|
78
|
ResponseType[ResponseType.Opaque] = "Opaque";
|
79
|
var ContentType = {};
|
80
|
ContentType.NONE = 0;
|
81
|
ContentType.JSON = 1;
|
82
|
ContentType.FORM = 2;
|
83
|
ContentType.FORM_DATA = 3;
|
84
|
ContentType.TEXT = 4;
|
85
|
ContentType.BLOB = 5;
|
86
|
ContentType.ARRAY_BUFFER = 6;
|
87
|
ContentType[ContentType.NONE] = "NONE";
|
88
|
ContentType[ContentType.JSON] = "JSON";
|
89
|
ContentType[ContentType.FORM] = "FORM";
|
90
|
ContentType[ContentType.FORM_DATA] = "FORM_DATA";
|
91
|
ContentType[ContentType.TEXT] = "TEXT";
|
92
|
ContentType[ContentType.BLOB] = "BLOB";
|
93
|
ContentType[ContentType.ARRAY_BUFFER] = "ARRAY_BUFFER";
|
94
|
var ResponseContentType = {};
|
95
|
ResponseContentType.Text = 0;
|
96
|
ResponseContentType.Json = 1;
|
97
|
ResponseContentType.ArrayBuffer = 2;
|
98
|
ResponseContentType.Blob = 3;
|
99
|
ResponseContentType[ResponseContentType.Text] = "Text";
|
100
|
ResponseContentType[ResponseContentType.Json] = "Json";
|
101
|
ResponseContentType[ResponseContentType.ArrayBuffer] = "ArrayBuffer";
|
102
|
ResponseContentType[ResponseContentType.Blob] = "Blob";
|
103
|
/**
|
104
|
* Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as
|
105
|
* specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class).
|
106
|
*
|
107
|
* The only known difference between this `Headers` implementation and the spec is the
|
108
|
* lack of an `entries` method.
|
109
|
*
|
110
|
* ### Example
|
111
|
*
|
112
|
* ```
|
113
|
* import {Headers} from '\@angular/http';
|
114
|
*
|
115
|
* var firstHeaders = new Headers();
|
116
|
* firstHeaders.append('Content-Type', 'image/jpeg');
|
117
|
* console.log(firstHeaders.get('Content-Type')) //'image/jpeg'
|
118
|
*
|
119
|
* // Create headers from Plain Old JavaScript Object
|
120
|
* var secondHeaders = new Headers({
|
121
|
* 'X-My-Custom-Header': 'Angular'
|
122
|
* });
|
123
|
* console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular'
|
124
|
*
|
125
|
* var thirdHeaders = new Headers(secondHeaders);
|
126
|
* console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular'
|
127
|
* ```
|
128
|
*
|
129
|
* \@experimental
|
130
|
*/
|
131
|
var Headers = (function () {
|
132
|
/**
|
133
|
* @param {?=} headers
|
134
|
*/
|
135
|
function Headers(headers) {
|
136
|
var _this = this;
|
137
|
/**
|
138
|
* \@internal header names are lower case
|
139
|
*/
|
140
|
this._headers = new Map();
|
141
|
/**
|
142
|
* \@internal map lower case names to actual names
|
143
|
*/
|
144
|
this._normalizedNames = new Map();
|
145
|
if (!headers) {
|
146
|
return;
|
147
|
}
|
148
|
if (headers instanceof Headers) {
|
149
|
headers.forEach(function (values, name) {
|
150
|
values.forEach(function (value) { return _this.append(name, value); });
|
151
|
});
|
152
|
return;
|
153
|
}
|
154
|
Object.keys(headers).forEach(function (name) {
|
155
|
var values = Array.isArray(headers[name]) ? headers[name] : [headers[name]];
|
156
|
_this.delete(name);
|
157
|
values.forEach(function (value) { return _this.append(name, value); });
|
158
|
});
|
159
|
}
|
160
|
/**
|
161
|
* Returns a new Headers instance from the given DOMString of Response Headers
|
162
|
* @param {?} headersString
|
163
|
* @return {?}
|
164
|
*/
|
165
|
Headers.fromResponseHeaderString = function (headersString) {
|
166
|
var /** @type {?} */ headers = new Headers();
|
167
|
headersString.split('\n').forEach(function (line) {
|
168
|
var /** @type {?} */ index = line.indexOf(':');
|
169
|
if (index > 0) {
|
170
|
var /** @type {?} */ name = line.slice(0, index);
|
171
|
var /** @type {?} */ value = line.slice(index + 1).trim();
|
172
|
headers.set(name, value);
|
173
|
}
|
174
|
});
|
175
|
return headers;
|
176
|
};
|
177
|
/**
|
178
|
* Appends a header to existing list of header values for a given header name.
|
179
|
* @param {?} name
|
180
|
* @param {?} value
|
181
|
* @return {?}
|
182
|
*/
|
183
|
Headers.prototype.append = function (name, value) {
|
184
|
var /** @type {?} */ values = this.getAll(name);
|
185
|
if (values === null) {
|
186
|
this.set(name, value);
|
187
|
}
|
188
|
else {
|
189
|
values.push(value);
|
190
|
}
|
191
|
};
|
192
|
/**
|
193
|
* Deletes all header values for the given name.
|
194
|
* @param {?} name
|
195
|
* @return {?}
|
196
|
*/
|
197
|
Headers.prototype.delete = function (name) {
|
198
|
var /** @type {?} */ lcName = name.toLowerCase();
|
199
|
this._normalizedNames.delete(lcName);
|
200
|
this._headers.delete(lcName);
|
201
|
};
|
202
|
/**
|
203
|
* @param {?} fn
|
204
|
* @return {?}
|
205
|
*/
|
206
|
Headers.prototype.forEach = function (fn) {
|
207
|
var _this = this;
|
208
|
this._headers.forEach(function (values, lcName) { return fn(values, _this._normalizedNames.get(lcName), _this._headers); });
|
209
|
};
|
210
|
/**
|
211
|
* Returns first header that matches given name.
|
212
|
* @param {?} name
|
213
|
* @return {?}
|
214
|
*/
|
215
|
Headers.prototype.get = function (name) {
|
216
|
var /** @type {?} */ values = this.getAll(name);
|
217
|
if (values === null) {
|
218
|
return null;
|
219
|
}
|
220
|
return values.length > 0 ? values[0] : null;
|
221
|
};
|
222
|
/**
|
223
|
* Checks for existence of header by given name.
|
224
|
* @param {?} name
|
225
|
* @return {?}
|
226
|
*/
|
227
|
Headers.prototype.has = function (name) { return this._headers.has(name.toLowerCase()); };
|
228
|
/**
|
229
|
* Returns the names of the headers
|
230
|
* @return {?}
|
231
|
*/
|
232
|
Headers.prototype.keys = function () { return Array.from(this._normalizedNames.values()); };
|
233
|
/**
|
234
|
* Sets or overrides header value for given name.
|
235
|
* @param {?} name
|
236
|
* @param {?} value
|
237
|
* @return {?}
|
238
|
*/
|
239
|
Headers.prototype.set = function (name, value) {
|
240
|
if (Array.isArray(value)) {
|
241
|
if (value.length) {
|
242
|
this._headers.set(name.toLowerCase(), [value.join(',')]);
|
243
|
}
|
244
|
}
|
245
|
else {
|
246
|
this._headers.set(name.toLowerCase(), [value]);
|
247
|
}
|
248
|
this.mayBeSetNormalizedName(name);
|
249
|
};
|
250
|
/**
|
251
|
* Returns values of all headers.
|
252
|
* @return {?}
|
253
|
*/
|
254
|
Headers.prototype.values = function () { return Array.from(this._headers.values()); };
|
255
|
/**
|
256
|
* @return {?}
|
257
|
*/
|
258
|
Headers.prototype.toJSON = function () {
|
259
|
var _this = this;
|
260
|
var /** @type {?} */ serialized = {};
|
261
|
this._headers.forEach(function (values, name) {
|
262
|
var /** @type {?} */ split = [];
|
263
|
values.forEach(function (v) { return split.push.apply(split, v.split(',')); });
|
264
|
serialized[((_this._normalizedNames.get(name)))] = split;
|
265
|
});
|
266
|
return serialized;
|
267
|
};
|
268
|
/**
|
269
|
* Returns list of header values for a given name.
|
270
|
* @param {?} name
|
271
|
* @return {?}
|
272
|
*/
|
273
|
Headers.prototype.getAll = function (name) {
|
274
|
return this.has(name) ? this._headers.get(name.toLowerCase()) || null : null;
|
275
|
};
|
276
|
/**
|
277
|
* This method is not implemented.
|
278
|
* @return {?}
|
279
|
*/
|
280
|
Headers.prototype.entries = function () { throw new Error('"entries" method is not implemented on Headers class'); };
|
281
|
/**
|
282
|
* @param {?} name
|
283
|
* @return {?}
|
284
|
*/
|
285
|
Headers.prototype.mayBeSetNormalizedName = function (name) {
|
286
|
var /** @type {?} */ lcName = name.toLowerCase();
|
287
|
if (!this._normalizedNames.has(lcName)) {
|
288
|
this._normalizedNames.set(lcName, name);
|
289
|
}
|
290
|
};
|
291
|
return Headers;
|
292
|
}());
|
293
|
/**
|
294
|
* @license
|
295
|
* Copyright Google Inc. All Rights Reserved.
|
296
|
*
|
297
|
* Use of this source code is governed by an MIT-style license that can be
|
298
|
* found in the LICENSE file at https://angular.io/license
|
299
|
*/
|
300
|
/**
|
301
|
* Creates a response options object to be optionally provided when instantiating a
|
302
|
* {\@link Response}.
|
303
|
*
|
304
|
* This class is based on the `ResponseInit` description in the [Fetch
|
305
|
* Spec](https://fetch.spec.whatwg.org/#responseinit).
|
306
|
*
|
307
|
* All values are null by default. Typical defaults can be found in the
|
308
|
* {\@link BaseResponseOptions} class, which sub-classes `ResponseOptions`.
|
309
|
*
|
310
|
* This class may be used in tests to build {\@link Response Responses} for
|
311
|
* mock responses (see {\@link MockBackend}).
|
312
|
*
|
313
|
* ### Example ([live demo](http://plnkr.co/edit/P9Jkk8e8cz6NVzbcxEsD?p=preview))
|
314
|
*
|
315
|
* ```typescript
|
316
|
* import {ResponseOptions, Response} from '\@angular/http';
|
317
|
*
|
318
|
* var options = new ResponseOptions({
|
319
|
* body: '{"name":"Jeff"}'
|
320
|
* });
|
321
|
* var res = new Response(options);
|
322
|
*
|
323
|
* console.log('res.json():', res.json()); // Object {name: "Jeff"}
|
324
|
* ```
|
325
|
*
|
326
|
* \@experimental
|
327
|
*/
|
328
|
var ResponseOptions = (function () {
|
329
|
/**
|
330
|
* @param {?=} opts
|
331
|
*/
|
332
|
function ResponseOptions(opts) {
|
333
|
if (opts === void 0) { opts = {}; }
|
334
|
var body = opts.body, status = opts.status, headers = opts.headers, statusText = opts.statusText, type = opts.type, url = opts.url;
|
335
|
this.body = body != null ? body : null;
|
336
|
this.status = status != null ? status : null;
|
337
|
this.headers = headers != null ? headers : null;
|
338
|
this.statusText = statusText != null ? statusText : null;
|
339
|
this.type = type != null ? type : null;
|
340
|
this.url = url != null ? url : null;
|
341
|
}
|
342
|
/**
|
343
|
* Creates a copy of the `ResponseOptions` instance, using the optional input as values to
|
344
|
* override
|
345
|
* existing values. This method will not change the values of the instance on which it is being
|
346
|
* called.
|
347
|
*
|
348
|
* This may be useful when sharing a base `ResponseOptions` object inside tests,
|
349
|
* where certain properties may change from test to test.
|
350
|
*
|
351
|
* ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
|
352
|
*
|
353
|
* ```typescript
|
354
|
* import {ResponseOptions, Response} from '\@angular/http';
|
355
|
*
|
356
|
* var options = new ResponseOptions({
|
357
|
* body: {name: 'Jeff'}
|
358
|
* });
|
359
|
* var res = new Response(options.merge({
|
360
|
* url: 'https://google.com'
|
361
|
* }));
|
362
|
* console.log('options.url:', options.url); // null
|
363
|
* console.log('res.json():', res.json()); // Object {name: "Jeff"}
|
364
|
* console.log('res.url:', res.url); // https://google.com
|
365
|
* ```
|
366
|
* @param {?=} options
|
367
|
* @return {?}
|
368
|
*/
|
369
|
ResponseOptions.prototype.merge = function (options) {
|
370
|
return new ResponseOptions({
|
371
|
body: options && options.body != null ? options.body : this.body,
|
372
|
status: options && options.status != null ? options.status : this.status,
|
373
|
headers: options && options.headers != null ? options.headers : this.headers,
|
374
|
statusText: options && options.statusText != null ? options.statusText : this.statusText,
|
375
|
type: options && options.type != null ? options.type : this.type,
|
376
|
url: options && options.url != null ? options.url : this.url,
|
377
|
});
|
378
|
};
|
379
|
return ResponseOptions;
|
380
|
}());
|
381
|
/**
|
382
|
* Subclass of {\@link ResponseOptions}, with default values.
|
383
|
*
|
384
|
* Default values:
|
385
|
* * status: 200
|
386
|
* * headers: empty {\@link Headers} object
|
387
|
*
|
388
|
* This class could be extended and bound to the {\@link ResponseOptions} class
|
389
|
* when configuring an {\@link Injector}, in order to override the default options
|
390
|
* used by {\@link Http} to create {\@link Response Responses}.
|
391
|
*
|
392
|
* ### Example ([live demo](http://plnkr.co/edit/qv8DLT?p=preview))
|
393
|
*
|
394
|
* ```typescript
|
395
|
* import {provide} from '\@angular/core';
|
396
|
* import {bootstrap} from '\@angular/platform-browser/browser';
|
397
|
* import {HTTP_PROVIDERS, Headers, Http, BaseResponseOptions, ResponseOptions} from
|
398
|
* '\@angular/http';
|
399
|
* import {App} from './myapp';
|
400
|
*
|
401
|
* class MyOptions extends BaseResponseOptions {
|
402
|
* headers:Headers = new Headers({network: 'github'});
|
403
|
* }
|
404
|
*
|
405
|
* bootstrap(App, [HTTP_PROVIDERS, {provide: ResponseOptions, useClass: MyOptions}]);
|
406
|
* ```
|
407
|
*
|
408
|
* The options could also be extended when manually creating a {\@link Response}
|
409
|
* object.
|
410
|
*
|
411
|
* ### Example ([live demo](http://plnkr.co/edit/VngosOWiaExEtbstDoix?p=preview))
|
412
|
*
|
413
|
* ```
|
414
|
* import {BaseResponseOptions, Response} from '\@angular/http';
|
415
|
*
|
416
|
* var options = new BaseResponseOptions();
|
417
|
* var res = new Response(options.merge({
|
418
|
* body: 'Angular',
|
419
|
* headers: new Headers({framework: 'angular'})
|
420
|
* }));
|
421
|
* console.log('res.headers.get("framework"):', res.headers.get('framework')); // angular
|
422
|
* console.log('res.text():', res.text()); // Angular;
|
423
|
* ```
|
424
|
*
|
425
|
* \@experimental
|
426
|
*/
|
427
|
var BaseResponseOptions = (function (_super) {
|
428
|
tslib_1.__extends(BaseResponseOptions, _super);
|
429
|
function BaseResponseOptions() {
|
430
|
return _super.call(this, { status: 200, statusText: 'Ok', type: ResponseType.Default, headers: new Headers() }) || this;
|
431
|
}
|
432
|
return BaseResponseOptions;
|
433
|
}(ResponseOptions));
|
434
|
BaseResponseOptions.decorators = [
|
435
|
{ type: Injectable },
|
436
|
];
|
437
|
/**
|
438
|
* @nocollapse
|
439
|
*/
|
440
|
BaseResponseOptions.ctorParameters = function () { return []; };
|
441
|
/**
|
442
|
* @license
|
443
|
* Copyright Google Inc. All Rights Reserved.
|
444
|
*
|
445
|
* Use of this source code is governed by an MIT-style license that can be
|
446
|
* found in the LICENSE file at https://angular.io/license
|
447
|
*/
|
448
|
/**
|
449
|
* Abstract class from which real backends are derived.
|
450
|
*
|
451
|
* The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given
|
452
|
* {\@link Request}.
|
453
|
*
|
454
|
* \@experimental
|
455
|
* @abstract
|
456
|
*/
|
457
|
var ConnectionBackend = (function () {
|
458
|
function ConnectionBackend() {
|
459
|
}
|
460
|
/**
|
461
|
* @abstract
|
462
|
* @param {?} request
|
463
|
* @return {?}
|
464
|
*/
|
465
|
ConnectionBackend.prototype.createConnection = function (request) { };
|
466
|
return ConnectionBackend;
|
467
|
}());
|
468
|
/**
|
469
|
* Abstract class from which real connections are derived.
|
470
|
*
|
471
|
* \@experimental
|
472
|
* @abstract
|
473
|
*/
|
474
|
var Connection = (function () {
|
475
|
function Connection() {
|
476
|
}
|
477
|
return Connection;
|
478
|
}());
|
479
|
/**
|
480
|
* An XSRFStrategy configures XSRF protection (e.g. via headers) on an HTTP request.
|
481
|
*
|
482
|
* \@experimental
|
483
|
* @abstract
|
484
|
*/
|
485
|
var XSRFStrategy = (function () {
|
486
|
function XSRFStrategy() {
|
487
|
}
|
488
|
/**
|
489
|
* @abstract
|
490
|
* @param {?} req
|
491
|
* @return {?}
|
492
|
*/
|
493
|
XSRFStrategy.prototype.configureRequest = function (req) { };
|
494
|
return XSRFStrategy;
|
495
|
}());
|
496
|
/**
|
497
|
* @license
|
498
|
* Copyright Google Inc. All Rights Reserved.
|
499
|
*
|
500
|
* Use of this source code is governed by an MIT-style license that can be
|
501
|
* found in the LICENSE file at https://angular.io/license
|
502
|
*/
|
503
|
/**
|
504
|
* @param {?} method
|
505
|
* @return {?}
|
506
|
*/
|
507
|
function normalizeMethodName(method) {
|
508
|
if (typeof method !== 'string')
|
509
|
return method;
|
510
|
switch (method.toUpperCase()) {
|
511
|
case 'GET':
|
512
|
return RequestMethod.Get;
|
513
|
case 'POST':
|
514
|
return RequestMethod.Post;
|
515
|
case 'PUT':
|
516
|
return RequestMethod.Put;
|
517
|
case 'DELETE':
|
518
|
return RequestMethod.Delete;
|
519
|
case 'OPTIONS':
|
520
|
return RequestMethod.Options;
|
521
|
case 'HEAD':
|
522
|
return RequestMethod.Head;
|
523
|
case 'PATCH':
|
524
|
return RequestMethod.Patch;
|
525
|
}
|
526
|
throw new Error("Invalid request method. The method \"" + method + "\" is not supported.");
|
527
|
}
|
528
|
var isSuccess = function (status) { return (status >= 200 && status < 300); };
|
529
|
/**
|
530
|
* @param {?} xhr
|
531
|
* @return {?}
|
532
|
*/
|
533
|
function getResponseURL(xhr) {
|
534
|
if ('responseURL' in xhr) {
|
535
|
return xhr.responseURL;
|
536
|
}
|
537
|
if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
|
538
|
return xhr.getResponseHeader('X-Request-URL');
|
539
|
}
|
540
|
return null;
|
541
|
}
|
542
|
/**
|
543
|
* @param {?} input
|
544
|
* @return {?}
|
545
|
*/
|
546
|
/**
|
547
|
* @param {?} input
|
548
|
* @return {?}
|
549
|
*/
|
550
|
function stringToArrayBuffer(input) {
|
551
|
var /** @type {?} */ view = new Uint16Array(input.length);
|
552
|
for (var /** @type {?} */ i = 0, /** @type {?} */ strLen = input.length; i < strLen; i++) {
|
553
|
view[i] = input.charCodeAt(i);
|
554
|
}
|
555
|
return view.buffer;
|
556
|
}
|
557
|
/**
|
558
|
* @license
|
559
|
* Copyright Google Inc. All Rights Reserved.
|
560
|
*
|
561
|
* Use of this source code is governed by an MIT-style license that can be
|
562
|
* found in the LICENSE file at https://angular.io/license
|
563
|
* @param {?=} rawParams
|
564
|
* @return {?}
|
565
|
*/
|
566
|
function paramParser(rawParams) {
|
567
|
if (rawParams === void 0) { rawParams = ''; }
|
568
|
var /** @type {?} */ map = new Map();
|
569
|
if (rawParams.length > 0) {
|
570
|
var /** @type {?} */ params = rawParams.split('&');
|
571
|
params.forEach(function (param) {
|
572
|
var /** @type {?} */ eqIdx = param.indexOf('=');
|
573
|
var _a = eqIdx == -1 ? [param, ''] : [param.slice(0, eqIdx), param.slice(eqIdx + 1)], key = _a[0], val = _a[1];
|
574
|
var /** @type {?} */ list = map.get(key) || [];
|
575
|
list.push(val);
|
576
|
map.set(key, list);
|
577
|
});
|
578
|
}
|
579
|
return map;
|
580
|
}
|
581
|
/**
|
582
|
* \@experimental
|
583
|
*
|
584
|
*/
|
585
|
var QueryEncoder = (function () {
|
586
|
function QueryEncoder() {
|
587
|
}
|
588
|
/**
|
589
|
* @param {?} k
|
590
|
* @return {?}
|
591
|
*/
|
592
|
QueryEncoder.prototype.encodeKey = function (k) { return standardEncoding(k); };
|
593
|
/**
|
594
|
* @param {?} v
|
595
|
* @return {?}
|
596
|
*/
|
597
|
QueryEncoder.prototype.encodeValue = function (v) { return standardEncoding(v); };
|
598
|
return QueryEncoder;
|
599
|
}());
|
600
|
/**
|
601
|
* @param {?} v
|
602
|
* @return {?}
|
603
|
*/
|
604
|
function standardEncoding(v) {
|
605
|
return encodeURIComponent(v)
|
606
|
.replace(/%40/gi, '@')
|
607
|
.replace(/%3A/gi, ':')
|
608
|
.replace(/%24/gi, '$')
|
609
|
.replace(/%2C/gi, ',')
|
610
|
.replace(/%3B/gi, ';')
|
611
|
.replace(/%2B/gi, '+')
|
612
|
.replace(/%3D/gi, '=')
|
613
|
.replace(/%3F/gi, '?')
|
614
|
.replace(/%2F/gi, '/');
|
615
|
}
|
616
|
/**
|
617
|
* Map-like representation of url search parameters, based on
|
618
|
* [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard,
|
619
|
* with several extensions for merging URLSearchParams objects:
|
620
|
* - setAll()
|
621
|
* - appendAll()
|
622
|
* - replaceAll()
|
623
|
*
|
624
|
* This class accepts an optional second parameter of ${\@link QueryEncoder},
|
625
|
* which is used to serialize parameters before making a request. By default,
|
626
|
* `QueryEncoder` encodes keys and values of parameters using `encodeURIComponent`,
|
627
|
* and then un-encodes certain characters that are allowed to be part of the query
|
628
|
* according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986.
|
629
|
*
|
630
|
* These are the characters that are not encoded: `! $ \' ( ) * + , ; A 9 - . _ ~ ? /`
|
631
|
*
|
632
|
* If the set of allowed query characters is not acceptable for a particular backend,
|
633
|
* `QueryEncoder` can be subclassed and provided as the 2nd argument to URLSearchParams.
|
634
|
*
|
635
|
* ```
|
636
|
* import {URLSearchParams, QueryEncoder} from '\@angular/http';
|
637
|
* class MyQueryEncoder extends QueryEncoder {
|
638
|
* encodeKey(k: string): string {
|
639
|
* return myEncodingFunction(k);
|
640
|
* }
|
641
|
*
|
642
|
* encodeValue(v: string): string {
|
643
|
* return myEncodingFunction(v);
|
644
|
* }
|
645
|
* }
|
646
|
*
|
647
|
* let params = new URLSearchParams('', new MyQueryEncoder());
|
648
|
* ```
|
649
|
* \@experimental
|
650
|
*/
|
651
|
var URLSearchParams = (function () {
|
652
|
/**
|
653
|
* @param {?=} rawParams
|
654
|
* @param {?=} queryEncoder
|
655
|
*/
|
656
|
function URLSearchParams(rawParams, queryEncoder) {
|
657
|
if (rawParams === void 0) { rawParams = ''; }
|
658
|
if (queryEncoder === void 0) { queryEncoder = new QueryEncoder(); }
|
659
|
this.rawParams = rawParams;
|
660
|
this.queryEncoder = queryEncoder;
|
661
|
this.paramsMap = paramParser(rawParams);
|
662
|
}
|
663
|
/**
|
664
|
* @return {?}
|
665
|
*/
|
666
|
URLSearchParams.prototype.clone = function () {
|
667
|
var /** @type {?} */ clone = new URLSearchParams('', this.queryEncoder);
|
668
|
clone.appendAll(this);
|
669
|
return clone;
|
670
|
};
|
671
|
/**
|
672
|
* @param {?} param
|
673
|
* @return {?}
|
674
|
*/
|
675
|
URLSearchParams.prototype.has = function (param) { return this.paramsMap.has(param); };
|
676
|
/**
|
677
|
* @param {?} param
|
678
|
* @return {?}
|
679
|
*/
|
680
|
URLSearchParams.prototype.get = function (param) {
|
681
|
var /** @type {?} */ storedParam = this.paramsMap.get(param);
|
682
|
return Array.isArray(storedParam) ? storedParam[0] : null;
|
683
|
};
|
684
|
/**
|
685
|
* @param {?} param
|
686
|
* @return {?}
|
687
|
*/
|
688
|
URLSearchParams.prototype.getAll = function (param) { return this.paramsMap.get(param) || []; };
|
689
|
/**
|
690
|
* @param {?} param
|
691
|
* @param {?} val
|
692
|
* @return {?}
|
693
|
*/
|
694
|
URLSearchParams.prototype.set = function (param, val) {
|
695
|
if (val === void 0 || val === null) {
|
696
|
this.delete(param);
|
697
|
return;
|
698
|
}
|
699
|
var /** @type {?} */ list = this.paramsMap.get(param) || [];
|
700
|
list.length = 0;
|
701
|
list.push(val);
|
702
|
this.paramsMap.set(param, list);
|
703
|
};
|
704
|
/**
|
705
|
* @param {?} searchParams
|
706
|
* @return {?}
|
707
|
*/
|
708
|
URLSearchParams.prototype.setAll = function (searchParams) {
|
709
|
var _this = this;
|
710
|
searchParams.paramsMap.forEach(function (value, param) {
|
711
|
var /** @type {?} */ list = _this.paramsMap.get(param) || [];
|
712
|
list.length = 0;
|
713
|
list.push(value[0]);
|
714
|
_this.paramsMap.set(param, list);
|
715
|
});
|
716
|
};
|
717
|
/**
|
718
|
* @param {?} param
|
719
|
* @param {?} val
|
720
|
* @return {?}
|
721
|
*/
|
722
|
URLSearchParams.prototype.append = function (param, val) {
|
723
|
if (val === void 0 || val === null)
|
724
|
return;
|
725
|
var /** @type {?} */ list = this.paramsMap.get(param) || [];
|
726
|
list.push(val);
|
727
|
this.paramsMap.set(param, list);
|
728
|
};
|
729
|
/**
|
730
|
* @param {?} searchParams
|
731
|
* @return {?}
|
732
|
*/
|
733
|
URLSearchParams.prototype.appendAll = function (searchParams) {
|
734
|
var _this = this;
|
735
|
searchParams.paramsMap.forEach(function (value, param) {
|
736
|
var /** @type {?} */ list = _this.paramsMap.get(param) || [];
|
737
|
for (var /** @type {?} */ i = 0; i < value.length; ++i) {
|
738
|
list.push(value[i]);
|
739
|
}
|
740
|
_this.paramsMap.set(param, list);
|
741
|
});
|
742
|
};
|
743
|
/**
|
744
|
* @param {?} searchParams
|
745
|
* @return {?}
|
746
|
*/
|
747
|
URLSearchParams.prototype.replaceAll = function (searchParams) {
|
748
|
var _this = this;
|
749
|
searchParams.paramsMap.forEach(function (value, param) {
|
750
|
var /** @type {?} */ list = _this.paramsMap.get(param) || [];
|
751
|
list.length = 0;
|
752
|
for (var /** @type {?} */ i = 0; i < value.length; ++i) {
|
753
|
list.push(value[i]);
|
754
|
}
|
755
|
_this.paramsMap.set(param, list);
|
756
|
});
|
757
|
};
|
758
|
/**
|
759
|
* @return {?}
|
760
|
*/
|
761
|
URLSearchParams.prototype.toString = function () {
|
762
|
var _this = this;
|
763
|
var /** @type {?} */ paramsList = [];
|
764
|
this.paramsMap.forEach(function (values, k) {
|
765
|
values.forEach(function (v) { return paramsList.push(_this.queryEncoder.encodeKey(k) + '=' + _this.queryEncoder.encodeValue(v)); });
|
766
|
});
|
767
|
return paramsList.join('&');
|
768
|
};
|
769
|
/**
|
770
|
* @param {?} param
|
771
|
* @return {?}
|
772
|
*/
|
773
|
URLSearchParams.prototype.delete = function (param) { this.paramsMap.delete(param); };
|
774
|
return URLSearchParams;
|
775
|
}());
|
776
|
/**
|
777
|
* @license
|
778
|
* Copyright Google Inc. All Rights Reserved.
|
779
|
*
|
780
|
* Use of this source code is governed by an MIT-style license that can be
|
781
|
* found in the LICENSE file at https://angular.io/license
|
782
|
*/
|
783
|
/**
|
784
|
* HTTP request body used by both {\@link Request} and {\@link Response}
|
785
|
* https://fetch.spec.whatwg.org/#body
|
786
|
* @abstract
|
787
|
*/
|
788
|
var Body = (function () {
|
789
|
function Body() {
|
790
|
}
|
791
|
/**
|
792
|
* Attempts to return body as parsed `JSON` object, or raises an exception.
|
793
|
* @return {?}
|
794
|
*/
|
795
|
Body.prototype.json = function () {
|
796
|
if (typeof this._body === 'string') {
|
797
|
return JSON.parse(/** @type {?} */ (this._body));
|
798
|
}
|
799
|
if (this._body instanceof ArrayBuffer) {
|
800
|
return JSON.parse(this.text());
|
801
|
}
|
802
|
return this._body;
|
803
|
};
|
804
|
/**
|
805
|
* Returns the body as a string, presuming `toString()` can be called on the response body.
|
806
|
*
|
807
|
* When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
|
808
|
* bytes in the buffer will be interpreted. Valid values are:
|
809
|
*
|
810
|
* - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
|
811
|
* in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
|
812
|
* In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
|
813
|
* into consideration. This is the default behavior to avoid breaking apps, but should be
|
814
|
* considered deprecated.
|
815
|
*
|
816
|
* - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
|
817
|
* @param {?=} encodingHint
|
818
|
* @return {?}
|
819
|
*/
|
820
|
Body.prototype.text = function (encodingHint) {
|
821
|
if (encodingHint === void 0) { encodingHint = 'legacy'; }
|
822
|
if (this._body instanceof URLSearchParams) {
|
823
|
return this._body.toString();
|
824
|
}
|
825
|
if (this._body instanceof ArrayBuffer) {
|
826
|
switch (encodingHint) {
|
827
|
case 'legacy':
|
828
|
return String.fromCharCode.apply(null, new Uint16Array(/** @type {?} */ (this._body)));
|
829
|
case 'iso-8859':
|
830
|
return String.fromCharCode.apply(null, new Uint8Array(/** @type {?} */ (this._body)));
|
831
|
default:
|
832
|
throw new Error("Invalid value for encodingHint: " + encodingHint);
|
833
|
}
|
834
|
}
|
835
|
if (this._body == null) {
|
836
|
return '';
|
837
|
}
|
838
|
if (typeof this._body === 'object') {
|
839
|
return JSON.stringify(this._body, null, 2);
|
840
|
}
|
841
|
return this._body.toString();
|
842
|
};
|
843
|
/**
|
844
|
* Return the body as an ArrayBuffer
|
845
|
* @return {?}
|
846
|
*/
|
847
|
Body.prototype.arrayBuffer = function () {
|
848
|
if (this._body instanceof ArrayBuffer) {
|
849
|
return (this._body);
|
850
|
}
|
851
|
return stringToArrayBuffer(this.text());
|
852
|
};
|
853
|
/**
|
854
|
* Returns the request's body as a Blob, assuming that body exists.
|
855
|
* @return {?}
|
856
|
*/
|
857
|
Body.prototype.blob = function () {
|
858
|
if (this._body instanceof Blob) {
|
859
|
return (this._body);
|
860
|
}
|
861
|
if (this._body instanceof ArrayBuffer) {
|
862
|
return new Blob([this._body]);
|
863
|
}
|
864
|
throw new Error('The request body isn\'t either a blob or an array buffer');
|
865
|
};
|
866
|
return Body;
|
867
|
}());
|
868
|
/**
|
869
|
* @license
|
870
|
* Copyright Google Inc. All Rights Reserved.
|
871
|
*
|
872
|
* Use of this source code is governed by an MIT-style license that can be
|
873
|
* found in the LICENSE file at https://angular.io/license
|
874
|
*/
|
875
|
/**
|
876
|
* Creates `Response` instances from provided values.
|
877
|
*
|
878
|
* Though this object isn't
|
879
|
* usually instantiated by end-users, it is the primary object interacted with when it comes time to
|
880
|
* add data to a view.
|
881
|
*
|
882
|
* ### Example
|
883
|
*
|
884
|
* ```
|
885
|
* http.request('my-friends.txt').subscribe(response => this.friends = response.text());
|
886
|
* ```
|
887
|
*
|
888
|
* The Response's interface is inspired by the Response constructor defined in the [Fetch
|
889
|
* Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body
|
890
|
* can be accessed many times. There are other differences in the implementation, but this is the
|
891
|
* most significant.
|
892
|
*
|
893
|
* \@experimental
|
894
|
*/
|
895
|
var Response = (function (_super) {
|
896
|
tslib_1.__extends(Response, _super);
|
897
|
/**
|
898
|
* @param {?} responseOptions
|
899
|
*/
|
900
|
function Response(responseOptions) {
|
901
|
var _this = _super.call(this) || this;
|
902
|
_this._body = responseOptions.body;
|
903
|
_this.status = responseOptions.status;
|
904
|
_this.ok = (_this.status >= 200 && _this.status <= 299);
|
905
|
_this.statusText = responseOptions.statusText;
|
906
|
_this.headers = responseOptions.headers;
|
907
|
_this.type = responseOptions.type;
|
908
|
_this.url = responseOptions.url;
|
909
|
return _this;
|
910
|
}
|
911
|
/**
|
912
|
* @return {?}
|
913
|
*/
|
914
|
Response.prototype.toString = function () {
|
915
|
return "Response with status: " + this.status + " " + this.statusText + " for URL: " + this.url;
|
916
|
};
|
917
|
return Response;
|
918
|
}(Body));
|
919
|
/**
|
920
|
* @license
|
921
|
* Copyright Google Inc. All Rights Reserved.
|
922
|
*
|
923
|
* Use of this source code is governed by an MIT-style license that can be
|
924
|
* found in the LICENSE file at https://angular.io/license
|
925
|
*/
|
926
|
var _nextRequestId = 0;
|
927
|
var JSONP_HOME = '__ng_jsonp__';
|
928
|
var _jsonpConnections = null;
|
929
|
/**
|
930
|
* @return {?}
|
931
|
*/
|
932
|
function _getJsonpConnections() {
|
933
|
var /** @type {?} */ w = typeof window == 'object' ? window : {};
|
934
|
if (_jsonpConnections === null) {
|
935
|
_jsonpConnections = w[JSONP_HOME] = {};
|
936
|
}
|
937
|
return _jsonpConnections;
|
938
|
}
|
939
|
var BrowserJsonp = (function () {
|
940
|
function BrowserJsonp() {
|
941
|
}
|
942
|
/**
|
943
|
* @param {?} url
|
944
|
* @return {?}
|
945
|
*/
|
946
|
BrowserJsonp.prototype.build = function (url) {
|
947
|
var /** @type {?} */ node = document.createElement('script');
|
948
|
node.src = url;
|
949
|
return node;
|
950
|
};
|
951
|
/**
|
952
|
* @return {?}
|
953
|
*/
|
954
|
BrowserJsonp.prototype.nextRequestID = function () { return "__req" + _nextRequestId++; };
|
955
|
/**
|
956
|
* @param {?} id
|
957
|
* @return {?}
|
958
|
*/
|
959
|
BrowserJsonp.prototype.requestCallback = function (id) { return JSONP_HOME + "." + id + ".finished"; };
|
960
|
/**
|
961
|
* @param {?} id
|
962
|
* @param {?} connection
|
963
|
* @return {?}
|
964
|
*/
|
965
|
BrowserJsonp.prototype.exposeConnection = function (id, connection) {
|
966
|
var /** @type {?} */ connections = _getJsonpConnections();
|
967
|
connections[id] = connection;
|
968
|
};
|
969
|
/**
|
970
|
* @param {?} id
|
971
|
* @return {?}
|
972
|
*/
|
973
|
BrowserJsonp.prototype.removeConnection = function (id) {
|
974
|
var /** @type {?} */ connections = _getJsonpConnections();
|
975
|
connections[id] = null;
|
976
|
};
|
977
|
/**
|
978
|
* @param {?} node
|
979
|
* @return {?}
|
980
|
*/
|
981
|
BrowserJsonp.prototype.send = function (node) { document.body.appendChild(/** @type {?} */ ((node))); };
|
982
|
/**
|
983
|
* @param {?} node
|
984
|
* @return {?}
|
985
|
*/
|
986
|
BrowserJsonp.prototype.cleanup = function (node) {
|
987
|
if (node.parentNode) {
|
988
|
node.parentNode.removeChild(/** @type {?} */ ((node)));
|
989
|
}
|
990
|
};
|
991
|
return BrowserJsonp;
|
992
|
}());
|
993
|
BrowserJsonp.decorators = [
|
994
|
{ type: Injectable },
|
995
|
];
|
996
|
/**
|
997
|
* @nocollapse
|
998
|
*/
|
999
|
BrowserJsonp.ctorParameters = function () { return []; };
|
1000
|
/**
|
1001
|
* @license
|
1002
|
* Copyright Google Inc. All Rights Reserved.
|
1003
|
*
|
1004
|
* Use of this source code is governed by an MIT-style license that can be
|
1005
|
* found in the LICENSE file at https://angular.io/license
|
1006
|
*/
|
1007
|
var JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
|
1008
|
var JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
|
1009
|
/**
|
1010
|
* Abstract base class for an in-flight JSONP request.
|
1011
|
*
|
1012
|
* \@experimental
|
1013
|
* @abstract
|
1014
|
*/
|
1015
|
var JSONPConnection = (function () {
|
1016
|
function JSONPConnection() {
|
1017
|
}
|
1018
|
/**
|
1019
|
* Callback called when the JSONP request completes, to notify the application
|
1020
|
* of the new data.
|
1021
|
* @abstract
|
1022
|
* @param {?=} data
|
1023
|
* @return {?}
|
1024
|
*/
|
1025
|
JSONPConnection.prototype.finished = function (data) { };
|
1026
|
return JSONPConnection;
|
1027
|
}());
|
1028
|
var JSONPConnection_ = (function (_super) {
|
1029
|
tslib_1.__extends(JSONPConnection_, _super);
|
1030
|
/**
|
1031
|
* @param {?} req
|
1032
|
* @param {?} _dom
|
1033
|
* @param {?=} baseResponseOptions
|
1034
|
*/
|
1035
|
function JSONPConnection_(req, _dom, baseResponseOptions) {
|
1036
|
var _this = _super.call(this) || this;
|
1037
|
_this._dom = _dom;
|
1038
|
_this.baseResponseOptions = baseResponseOptions;
|
1039
|
_this._finished = false;
|
1040
|
if (req.method !== RequestMethod.Get) {
|
1041
|
throw new TypeError(JSONP_ERR_WRONG_METHOD);
|
1042
|
}
|
1043
|
_this.request = req;
|
1044
|
_this.response = new Observable(function (responseObserver) {
|
1045
|
_this.readyState = ReadyState.Loading;
|
1046
|
var id = _this._id = _dom.nextRequestID();
|
1047
|
_dom.exposeConnection(id, _this);
|
1048
|
// Workaround Dart
|
1049
|
// url = url.replace(/=JSONP_CALLBACK(&|$)/, `generated method`);
|
1050
|
var callback = _dom.requestCallback(_this._id);
|
1051
|
var url = req.url;
|
1052
|
if (url.indexOf('=JSONP_CALLBACK&') > -1) {
|
1053
|
url = url.replace('=JSONP_CALLBACK&', "=" + callback + "&");
|
1054
|
}
|
1055
|
else if (url.lastIndexOf('=JSONP_CALLBACK') === url.length - '=JSONP_CALLBACK'.length) {
|
1056
|
url = url.substring(0, url.length - '=JSONP_CALLBACK'.length) + ("=" + callback);
|
1057
|
}
|
1058
|
var script = _this._script = _dom.build(url);
|
1059
|
var onLoad = function (event) {
|
1060
|
if (_this.readyState === ReadyState.Cancelled)
|
1061
|
return;
|
1062
|
_this.readyState = ReadyState.Done;
|
1063
|
_dom.cleanup(script);
|
1064
|
if (!_this._finished) {
|
1065
|
var responseOptions_1 = new ResponseOptions({ body: JSONP_ERR_NO_CALLBACK, type: ResponseType.Error, url: url });
|
1066
|
if (baseResponseOptions) {
|
1067
|
responseOptions_1 = baseResponseOptions.merge(responseOptions_1);
|
1068
|
}
|
1069
|
responseObserver.error(new Response(responseOptions_1));
|
1070
|
return;
|
1071
|
}
|
1072
|
var responseOptions = new ResponseOptions({ body: _this._responseData, url: url });
|
1073
|
if (_this.baseResponseOptions) {
|
1074
|
responseOptions = _this.baseResponseOptions.merge(responseOptions);
|
1075
|
}
|
1076
|
responseObserver.next(new Response(responseOptions));
|
1077
|
responseObserver.complete();
|
1078
|
};
|
1079
|
var onError = function (error) {
|
1080
|
if (_this.readyState === ReadyState.Cancelled)
|
1081
|
return;
|
1082
|
_this.readyState = ReadyState.Done;
|
1083
|
_dom.cleanup(script);
|
1084
|
var responseOptions = new ResponseOptions({ body: error.message, type: ResponseType.Error });
|
1085
|
if (baseResponseOptions) {
|
1086
|
responseOptions = baseResponseOptions.merge(responseOptions);
|
1087
|
}
|
1088
|
responseObserver.error(new Response(responseOptions));
|
1089
|
};
|
1090
|
script.addEventListener('load', onLoad);
|
1091
|
script.addEventListener('error', onError);
|
1092
|
_dom.send(script);
|
1093
|
return function () {
|
1094
|
_this.readyState = ReadyState.Cancelled;
|
1095
|
script.removeEventListener('load', onLoad);
|
1096
|
script.removeEventListener('error', onError);
|
1097
|
_this._dom.cleanup(script);
|
1098
|
};
|
1099
|
});
|
1100
|
return _this;
|
1101
|
}
|
1102
|
/**
|
1103
|
* @param {?=} data
|
1104
|
* @return {?}
|
1105
|
*/
|
1106
|
JSONPConnection_.prototype.finished = function (data) {
|
1107
|
// Don't leak connections
|
1108
|
this._finished = true;
|
1109
|
this._dom.removeConnection(this._id);
|
1110
|
if (this.readyState === ReadyState.Cancelled)
|
1111
|
return;
|
1112
|
this._responseData = data;
|
1113
|
};
|
1114
|
return JSONPConnection_;
|
1115
|
}(JSONPConnection));
|
1116
|
/**
|
1117
|
* A {\@link ConnectionBackend} that uses the JSONP strategy of making requests.
|
1118
|
*
|
1119
|
* \@experimental
|
1120
|
* @abstract
|
1121
|
*/
|
1122
|
var JSONPBackend = (function (_super) {
|
1123
|
tslib_1.__extends(JSONPBackend, _super);
|
1124
|
function JSONPBackend() {
|
1125
|
return _super !== null && _super.apply(this, arguments) || this;
|
1126
|
}
|
1127
|
return JSONPBackend;
|
1128
|
}(ConnectionBackend));
|
1129
|
var JSONPBackend_ = (function (_super) {
|
1130
|
tslib_1.__extends(JSONPBackend_, _super);
|
1131
|
/**
|
1132
|
* @param {?} _browserJSONP
|
1133
|
* @param {?} _baseResponseOptions
|
1134
|
*/
|
1135
|
function JSONPBackend_(_browserJSONP, _baseResponseOptions) {
|
1136
|
var _this = _super.call(this) || this;
|
1137
|
_this._browserJSONP = _browserJSONP;
|
1138
|
_this._baseResponseOptions = _baseResponseOptions;
|
1139
|
return _this;
|
1140
|
}
|
1141
|
/**
|
1142
|
* @param {?} request
|
1143
|
* @return {?}
|
1144
|
*/
|
1145
|
JSONPBackend_.prototype.createConnection = function (request) {
|
1146
|
return new JSONPConnection_(request, this._browserJSONP, this._baseResponseOptions);
|
1147
|
};
|
1148
|
return JSONPBackend_;
|
1149
|
}(JSONPBackend));
|
1150
|
JSONPBackend_.decorators = [
|
1151
|
{ type: Injectable },
|
1152
|
];
|
1153
|
/**
|
1154
|
* @nocollapse
|
1155
|
*/
|
1156
|
JSONPBackend_.ctorParameters = function () { return [
|
1157
|
{ type: BrowserJsonp, },
|
1158
|
{ type: ResponseOptions, },
|
1159
|
]; };
|
1160
|
/**
|
1161
|
* @license
|
1162
|
* Copyright Google Inc. All Rights Reserved.
|
1163
|
*
|
1164
|
* Use of this source code is governed by an MIT-style license that can be
|
1165
|
* found in the LICENSE file at https://angular.io/license
|
1166
|
*/
|
1167
|
var XSSI_PREFIX = /^\)\]\}',?\n/;
|
1168
|
/**
|
1169
|
* Creates connections using `XMLHttpRequest`. Given a fully-qualified
|
1170
|
* request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the
|
1171
|
* request.
|
1172
|
*
|
1173
|
* This class would typically not be created or interacted with directly inside applications, though
|
1174
|
* the {\@link MockConnection} may be interacted with in tests.
|
1175
|
*
|
1176
|
* \@experimental
|
1177
|
*/
|
1178
|
var XHRConnection = (function () {
|
1179
|
/**
|
1180
|
* @param {?} req
|
1181
|
* @param {?} browserXHR
|
1182
|
* @param {?=} baseResponseOptions
|
1183
|
*/
|
1184
|
function XHRConnection(req, browserXHR, baseResponseOptions) {
|
1185
|
var _this = this;
|
1186
|
this.request = req;
|
1187
|
this.response = new Observable(function (responseObserver) {
|
1188
|
var _xhr = browserXHR.build();
|
1189
|
_xhr.open(RequestMethod[req.method].toUpperCase(), req.url);
|
1190
|
if (req.withCredentials != null) {
|
1191
|
_xhr.withCredentials = req.withCredentials;
|
1192
|
}
|
1193
|
// load event handler
|
1194
|
var onLoad = function () {
|
1195
|
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
|
1196
|
var status = _xhr.status === 1223 ? 204 : _xhr.status;
|
1197
|
var body = null;
|
1198
|
// HTTP 204 means no content
|
1199
|
if (status !== 204) {
|
1200
|
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
|
1201
|
// response/responseType properties were introduced in ResourceLoader Level2 spec
|
1202
|
// (supported by IE10)
|
1203
|
body = (typeof _xhr.response === 'undefined') ? _xhr.responseText : _xhr.response;
|
1204
|
// Implicitly strip a potential XSSI prefix.
|
1205
|
if (typeof body === 'string') {
|
1206
|
body = body.replace(XSSI_PREFIX, '');
|
1207
|
}
|
1208
|
}
|
1209
|
// fix status code when it is 0 (0 status is undocumented).
|
1210
|
// Occurs when accessing file resources or on Android 4.1 stock browser
|
1211
|
// while retrieving files from application cache.
|
1212
|
if (status === 0) {
|
1213
|
status = body ? 200 : 0;
|
1214
|
}
|
1215
|
var headers = Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders());
|
1216
|
// IE 9 does not provide the way to get URL of response
|
1217
|
var url = getResponseURL(_xhr) || req.url;
|
1218
|
var statusText = _xhr.statusText || 'OK';
|
1219
|
var responseOptions = new ResponseOptions({ body: body, status: status, headers: headers, statusText: statusText, url: url });
|
1220
|
if (baseResponseOptions != null) {
|
1221
|
responseOptions = baseResponseOptions.merge(responseOptions);
|
1222
|
}
|
1223
|
var response = new Response(responseOptions);
|
1224
|
response.ok = isSuccess(status);
|
1225
|
if (response.ok) {
|
1226
|
responseObserver.next(response);
|
1227
|
// TODO(gdi2290): defer complete if array buffer until done
|
1228
|
responseObserver.complete();
|
1229
|
return;
|
1230
|
}
|
1231
|
responseObserver.error(response);
|
1232
|
};
|
1233
|
// error event handler
|
1234
|
var onError = function (err) {
|
1235
|
var responseOptions = new ResponseOptions({
|
1236
|
body: err,
|
1237
|
type: ResponseType.Error,
|
1238
|
status: _xhr.status,
|
1239
|
statusText: _xhr.statusText,
|
1240
|
});
|
1241
|
if (baseResponseOptions != null) {
|
1242
|
responseOptions = baseResponseOptions.merge(responseOptions);
|
1243
|
}
|
1244
|
responseObserver.error(new Response(responseOptions));
|
1245
|
};
|
1246
|
_this.setDetectedContentType(req, _xhr);
|
1247
|
if (req.headers == null) {
|
1248
|
req.headers = new Headers();
|
1249
|
}
|
1250
|
if (!req.headers.has('Accept')) {
|
1251
|
req.headers.append('Accept', 'application/json, text/plain, */*');
|
1252
|
}
|
1253
|
req.headers.forEach(function (values, name) { return _xhr.setRequestHeader(name, values.join(',')); });
|
1254
|
// Select the correct buffer type to store the response
|
1255
|
if (req.responseType != null && _xhr.responseType != null) {
|
1256
|
switch (req.responseType) {
|
1257
|
case ResponseContentType.ArrayBuffer:
|
1258
|
_xhr.responseType = 'arraybuffer';
|
1259
|
break;
|
1260
|
case ResponseContentType.Json:
|
1261
|
_xhr.responseType = 'json';
|
1262
|
break;
|
1263
|
case ResponseContentType.Text:
|
1264
|
_xhr.responseType = 'text';
|
1265
|
break;
|
1266
|
case ResponseContentType.Blob:
|
1267
|
_xhr.responseType = 'blob';
|
1268
|
break;
|
1269
|
default:
|
1270
|
throw new Error('The selected responseType is not supported');
|
1271
|
}
|
1272
|
}
|
1273
|
_xhr.addEventListener('load', onLoad);
|
1274
|
_xhr.addEventListener('error', onError);
|
1275
|
_xhr.send(_this.request.getBody());
|
1276
|
return function () {
|
1277
|
_xhr.removeEventListener('load', onLoad);
|
1278
|
_xhr.removeEventListener('error', onError);
|
1279
|
_xhr.abort();
|
1280
|
};
|
1281
|
});
|
1282
|
}
|
1283
|
/**
|
1284
|
* @param {?} req
|
1285
|
* @param {?} _xhr
|
1286
|
* @return {?}
|
1287
|
*/
|
1288
|
XHRConnection.prototype.setDetectedContentType = function (req /** TODO Request */, _xhr /** XMLHttpRequest */) {
|
1289
|
// Skip if a custom Content-Type header is provided
|
1290
|
if (req.headers != null && req.headers.get('Content-Type') != null) {
|
1291
|
return;
|
1292
|
}
|
1293
|
// Set the detected content type
|
1294
|
switch (req.contentType) {
|
1295
|
case ContentType.NONE:
|
1296
|
break;
|
1297
|
case ContentType.JSON:
|
1298
|
_xhr.setRequestHeader('content-type', 'application/json');
|
1299
|
break;
|
1300
|
case ContentType.FORM:
|
1301
|
_xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
1302
|
break;
|
1303
|
case ContentType.TEXT:
|
1304
|
_xhr.setRequestHeader('content-type', 'text/plain');
|
1305
|
break;
|
1306
|
case ContentType.BLOB:
|
1307
|
var /** @type {?} */ blob = req.blob();
|
1308
|
if (blob.type) {
|
1309
|
_xhr.setRequestHeader('content-type', blob.type);
|
1310
|
}
|
1311
|
break;
|
1312
|
}
|
1313
|
};
|
1314
|
return XHRConnection;
|
1315
|
}());
|
1316
|
/**
|
1317
|
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application
|
1318
|
* using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
|
1319
|
* for more information on XSRF.
|
1320
|
*
|
1321
|
* Applications can configure custom cookie and header names by binding an instance of this class
|
1322
|
* with different `cookieName` and `headerName` values. See the main HTTP documentation for more
|
1323
|
* details.
|
1324
|
*
|
1325
|
* \@experimental
|
1326
|
*/
|
1327
|
var CookieXSRFStrategy = (function () {
|
1328
|
/**
|
1329
|
* @param {?=} _cookieName
|
1330
|
* @param {?=} _headerName
|
1331
|
*/
|
1332
|
function CookieXSRFStrategy(_cookieName, _headerName) {
|
1333
|
if (_cookieName === void 0) { _cookieName = 'XSRF-TOKEN'; }
|
1334
|
if (_headerName === void 0) { _headerName = 'X-XSRF-TOKEN'; }
|
1335
|
this._cookieName = _cookieName;
|
1336
|
this._headerName = _headerName;
|
1337
|
}
|
1338
|
/**
|
1339
|
* @param {?} req
|
1340
|
* @return {?}
|
1341
|
*/
|
1342
|
CookieXSRFStrategy.prototype.configureRequest = function (req) {
|
1343
|
var /** @type {?} */ xsrfToken = ɵgetDOM().getCookie(this._cookieName);
|
1344
|
if (xsrfToken) {
|
1345
|
req.headers.set(this._headerName, xsrfToken);
|
1346
|
}
|
1347
|
};
|
1348
|
return CookieXSRFStrategy;
|
1349
|
}());
|
1350
|
/**
|
1351
|
* Creates {\@link XHRConnection} instances.
|
1352
|
*
|
1353
|
* This class would typically not be used by end users, but could be
|
1354
|
* overridden if a different backend implementation should be used,
|
1355
|
* such as in a node backend.
|
1356
|
*
|
1357
|
* ### Example
|
1358
|
*
|
1359
|
* ```
|
1360
|
* import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '\@angular/http';
|
1361
|
* \@Component({
|
1362
|
* viewProviders: [
|
1363
|
* HTTP_PROVIDERS,
|
1364
|
* {provide: Http, useFactory: (backend, options) => {
|
1365
|
* return new Http(backend, options);
|
1366
|
* }, deps: [MyNodeBackend, BaseRequestOptions]}]
|
1367
|
* })
|
1368
|
* class MyComponent {
|
1369
|
* constructor(http:Http) {
|
1370
|
* http.request('people.json').subscribe(res => this.people = res.json());
|
1371
|
* }
|
1372
|
* }
|
1373
|
* ```
|
1374
|
* \@experimental
|
1375
|
*/
|
1376
|
var XHRBackend = (function () {
|
1377
|
/**
|
1378
|
* @param {?} _browserXHR
|
1379
|
* @param {?} _baseResponseOptions
|
1380
|
* @param {?} _xsrfStrategy
|
1381
|
*/
|
1382
|
function XHRBackend(_browserXHR, _baseResponseOptions, _xsrfStrategy) {
|
1383
|
this._browserXHR = _browserXHR;
|
1384
|
this._baseResponseOptions = _baseResponseOptions;
|
1385
|
this._xsrfStrategy = _xsrfStrategy;
|
1386
|
}
|
1387
|
/**
|
1388
|
* @param {?} request
|
1389
|
* @return {?}
|
1390
|
*/
|
1391
|
XHRBackend.prototype.createConnection = function (request) {
|
1392
|
this._xsrfStrategy.configureRequest(request);
|
1393
|
return new XHRConnection(request, this._browserXHR, this._baseResponseOptions);
|
1394
|
};
|
1395
|
return XHRBackend;
|
1396
|
}());
|
1397
|
XHRBackend.decorators = [
|
1398
|
{ type: Injectable },
|
1399
|
];
|
1400
|
/**
|
1401
|
* @nocollapse
|
1402
|
*/
|
1403
|
XHRBackend.ctorParameters = function () { return [
|
1404
|
{ type: BrowserXhr, },
|
1405
|
{ type: ResponseOptions, },
|
1406
|
{ type: XSRFStrategy, },
|
1407
|
]; };
|
1408
|
/**
|
1409
|
* @license
|
1410
|
* Copyright Google Inc. All Rights Reserved.
|
1411
|
*
|
1412
|
* Use of this source code is governed by an MIT-style license that can be
|
1413
|
* found in the LICENSE file at https://angular.io/license
|
1414
|
*/
|
1415
|
/**
|
1416
|
* Creates a request options object to be optionally provided when instantiating a
|
1417
|
* {\@link Request}.
|
1418
|
*
|
1419
|
* This class is based on the `RequestInit` description in the [Fetch
|
1420
|
* Spec](https://fetch.spec.whatwg.org/#requestinit).
|
1421
|
*
|
1422
|
* All values are null by default. Typical defaults can be found in the {\@link BaseRequestOptions}
|
1423
|
* class, which sub-classes `RequestOptions`.
|
1424
|
*
|
1425
|
* ```typescript
|
1426
|
* import {RequestOptions, Request, RequestMethod} from '\@angular/http';
|
1427
|
*
|
1428
|
* const options = new RequestOptions({
|
1429
|
* method: RequestMethod.Post,
|
1430
|
* url: 'https://google.com'
|
1431
|
* });
|
1432
|
* const req = new Request(options);
|
1433
|
* console.log('req.method:', RequestMethod[req.method]); // Post
|
1434
|
* console.log('options.url:', options.url); // https://google.com
|
1435
|
* ```
|
1436
|
*
|
1437
|
* \@experimental
|
1438
|
*/
|
1439
|
var RequestOptions = (function () {
|
1440
|
/**
|
1441
|
* @param {?=} opts
|
1442
|
*/
|
1443
|
function RequestOptions(opts) {
|
1444
|
if (opts === void 0) { opts = {}; }
|
1445
|
var method = opts.method, headers = opts.headers, body = opts.body, url = opts.url, search = opts.search, params = opts.params, withCredentials = opts.withCredentials, responseType = opts.responseType;
|
1446
|
this.method = method != null ? normalizeMethodName(method) : null;
|
1447
|
this.headers = headers != null ? headers : null;
|
1448
|
this.body = body != null ? body : null;
|
1449
|
this.url = url != null ? url : null;
|
1450
|
this.params = this._mergeSearchParams(params || search);
|
1451
|
this.withCredentials = withCredentials != null ? withCredentials : null;
|
1452
|
this.responseType = responseType != null ? responseType : null;
|
1453
|
}
|
1454
|
Object.defineProperty(RequestOptions.prototype, "search", {
|
1455
|
/**
|
1456
|
* @deprecated from 4.0.0. Use params instead.
|
1457
|
* @return {?}
|
1458
|
*/
|
1459
|
get: function () { return this.params; },
|
1460
|
/**
|
1461
|
* @deprecated from 4.0.0. Use params instead.
|
1462
|
* @param {?} params
|
1463
|
* @return {?}
|
1464
|
*/
|
1465
|
set: function (params) { this.params = params; },
|
1466
|
enumerable: true,
|
1467
|
configurable: true
|
1468
|
});
|
1469
|
/**
|
1470
|
* Creates a copy of the `RequestOptions` instance, using the optional input as values to override
|
1471
|
* existing values. This method will not change the values of the instance on which it is being
|
1472
|
* called.
|
1473
|
*
|
1474
|
* Note that `headers` and `search` will override existing values completely if present in
|
1475
|
* the `options` object. If these values should be merged, it should be done prior to calling
|
1476
|
* `merge` on the `RequestOptions` instance.
|
1477
|
*
|
1478
|
* ```typescript
|
1479
|
* import {RequestOptions, Request, RequestMethod} from '\@angular/http';
|
1480
|
*
|
1481
|
* const options = new RequestOptions({
|
1482
|
* method: RequestMethod.Post
|
1483
|
* });
|
1484
|
* const req = new Request(options.merge({
|
1485
|
* url: 'https://google.com'
|
1486
|
* }));
|
1487
|
* console.log('req.method:', RequestMethod[req.method]); // Post
|
1488
|
* console.log('options.url:', options.url); // null
|
1489
|
* console.log('req.url:', req.url); // https://google.com
|
1490
|
* ```
|
1491
|
* @param {?=} options
|
1492
|
* @return {?}
|
1493
|
*/
|
1494
|
RequestOptions.prototype.merge = function (options) {
|
1495
|
return new RequestOptions({
|
1496
|
method: options && options.method != null ? options.method : this.method,
|
1497
|
headers: options && options.headers != null ? options.headers : new Headers(this.headers),
|
1498
|
body: options && options.body != null ? options.body : this.body,
|
1499
|
url: options && options.url != null ? options.url : this.url,
|
1500
|
params: options && this._mergeSearchParams(options.params || options.search),
|
1501
|
withCredentials: options && options.withCredentials != null ? options.withCredentials :
|
1502
|
this.withCredentials,
|
1503
|
responseType: options && options.responseType != null ? options.responseType :
|
1504
|
this.responseType
|
1505
|
});
|
1506
|
};
|
1507
|
/**
|
1508
|
* @param {?=} params
|
1509
|
* @return {?}
|
1510
|
*/
|
1511
|
RequestOptions.prototype._mergeSearchParams = function (params) {
|
1512
|
if (!params)
|
1513
|
return this.params;
|
1514
|
if (params instanceof URLSearchParams) {
|
1515
|
return params.clone();
|
1516
|
}
|
1517
|
if (typeof params === 'string') {
|
1518
|
return new URLSearchParams(params);
|
1519
|
}
|
1520
|
return this._parseParams(params);
|
1521
|
};
|
1522
|
/**
|
1523
|
* @param {?=} objParams
|
1524
|
* @return {?}
|
1525
|
*/
|
1526
|
RequestOptions.prototype._parseParams = function (objParams) {
|
1527
|
var _this = this;
|
1528
|
if (objParams === void 0) { objParams = {}; }
|
1529
|
var /** @type {?} */ params = new URLSearchParams();
|
1530
|
Object.keys(objParams).forEach(function (key) {
|
1531
|
var /** @type {?} */ value = objParams[key];
|
1532
|
if (Array.isArray(value)) {
|
1533
|
value.forEach(function (item) { return _this._appendParam(key, item, params); });
|
1534
|
}
|
1535
|
else {
|
1536
|
_this._appendParam(key, value, params);
|
1537
|
}
|
1538
|
});
|
1539
|
return params;
|
1540
|
};
|
1541
|
/**
|
1542
|
* @param {?} key
|
1543
|
* @param {?} value
|
1544
|
* @param {?} params
|
1545
|
* @return {?}
|
1546
|
*/
|
1547
|
RequestOptions.prototype._appendParam = function (key, value, params) {
|
1548
|
if (typeof value !== 'string') {
|
1549
|
value = JSON.stringify(value);
|
1550
|
}
|
1551
|
params.append(key, value);
|
1552
|
};
|
1553
|
return RequestOptions;
|
1554
|
}());
|
1555
|
/**
|
1556
|
* Subclass of {\@link RequestOptions}, with default values.
|
1557
|
*
|
1558
|
* Default values:
|
1559
|
* * method: {\@link RequestMethod RequestMethod.Get}
|
1560
|
* * headers: empty {\@link Headers} object
|
1561
|
*
|
1562
|
* This class could be extended and bound to the {\@link RequestOptions} class
|
1563
|
* when configuring an {\@link Injector}, in order to override the default options
|
1564
|
* used by {\@link Http} to create and send {\@link Request Requests}.
|
1565
|
*
|
1566
|
* ```typescript
|
1567
|
* import {BaseRequestOptions, RequestOptions} from '\@angular/http';
|
1568
|
*
|
1569
|
* class MyOptions extends BaseRequestOptions {
|
1570
|
* search: string = 'coreTeam=true';
|
1571
|
* }
|
1572
|
*
|
1573
|
* {provide: RequestOptions, useClass: MyOptions};
|
1574
|
* ```
|
1575
|
*
|
1576
|
* The options could also be extended when manually creating a {\@link Request}
|
1577
|
* object.
|
1578
|
*
|
1579
|
* ```
|
1580
|
* import {BaseRequestOptions, Request, RequestMethod} from '\@angular/http';
|
1581
|
*
|
1582
|
* const options = new BaseRequestOptions();
|
1583
|
* const req = new Request(options.merge({
|
1584
|
* method: RequestMethod.Post,
|
1585
|
* url: 'https://google.com'
|
1586
|
* }));
|
1587
|
* console.log('req.method:', RequestMethod[req.method]); // Post
|
1588
|
* console.log('options.url:', options.url); // null
|
1589
|
* console.log('req.url:', req.url); // https://google.com
|
1590
|
* ```
|
1591
|
*
|
1592
|
* \@experimental
|
1593
|
*/
|
1594
|
var BaseRequestOptions = (function (_super) {
|
1595
|
tslib_1.__extends(BaseRequestOptions, _super);
|
1596
|
function BaseRequestOptions() {
|
1597
|
return _super.call(this, { method: RequestMethod.Get, headers: new Headers() }) || this;
|
1598
|
}
|
1599
|
return BaseRequestOptions;
|
1600
|
}(RequestOptions));
|
1601
|
BaseRequestOptions.decorators = [
|
1602
|
{ type: Injectable },
|
1603
|
];
|
1604
|
/**
|
1605
|
* @nocollapse
|
1606
|
*/
|
1607
|
BaseRequestOptions.ctorParameters = function () { return []; };
|
1608
|
/**
|
1609
|
* @license
|
1610
|
* Copyright Google Inc. All Rights Reserved.
|
1611
|
*
|
1612
|
* Use of this source code is governed by an MIT-style license that can be
|
1613
|
* found in the LICENSE file at https://angular.io/license
|
1614
|
*/
|
1615
|
/**
|
1616
|
* Creates `Request` instances from provided values.
|
1617
|
*
|
1618
|
* The Request's interface is inspired by the Request constructor defined in the [Fetch
|
1619
|
* Spec](https://fetch.spec.whatwg.org/#request-class),
|
1620
|
* but is considered a static value whose body can be accessed many times. There are other
|
1621
|
* differences in the implementation, but this is the most significant.
|
1622
|
*
|
1623
|
* `Request` instances are typically created by higher-level classes, like {\@link Http} and
|
1624
|
* {\@link Jsonp}, but it may occasionally be useful to explicitly create `Request` instances.
|
1625
|
* One such example is when creating services that wrap higher-level services, like {\@link Http},
|
1626
|
* where it may be useful to generate a `Request` with arbitrary headers and search params.
|
1627
|
*
|
1628
|
* ```typescript
|
1629
|
* import {Injectable, Injector} from '\@angular/core';
|
1630
|
* import {HTTP_PROVIDERS, Http, Request, RequestMethod} from '\@angular/http';
|
1631
|
*
|
1632
|
* \@Injectable()
|
1633
|
* class AutoAuthenticator {
|
1634
|
* constructor(public http:Http) {}
|
1635
|
* request(url:string) {
|
1636
|
* return this.http.request(new Request({
|
1637
|
* method: RequestMethod.Get,
|
1638
|
* url: url,
|
1639
|
* search: 'password=123'
|
1640
|
* }));
|
1641
|
* }
|
1642
|
* }
|
1643
|
*
|
1644
|
* var injector = Injector.resolveAndCreate([HTTP_PROVIDERS, AutoAuthenticator]);
|
1645
|
* var authenticator = injector.get(AutoAuthenticator);
|
1646
|
* authenticator.request('people.json').subscribe(res => {
|
1647
|
* //URL should have included '?password=123'
|
1648
|
* console.log('people', res.json());
|
1649
|
* });
|
1650
|
* ```
|
1651
|
*
|
1652
|
* \@experimental
|
1653
|
*/
|
1654
|
var Request = (function (_super) {
|
1655
|
tslib_1.__extends(Request, _super);
|
1656
|
/**
|
1657
|
* @param {?} requestOptions
|
1658
|
*/
|
1659
|
function Request(requestOptions) {
|
1660
|
var _this = _super.call(this) || this;
|
1661
|
// TODO: assert that url is present
|
1662
|
var url = requestOptions.url;
|
1663
|
_this.url = requestOptions.url;
|
1664
|
var paramsArg = requestOptions.params || requestOptions.search;
|
1665
|
if (paramsArg) {
|
1666
|
var params = void 0;
|
1667
|
if (typeof paramsArg === 'object' && !(paramsArg instanceof URLSearchParams)) {
|
1668
|
params = urlEncodeParams(paramsArg).toString();
|
1669
|
}
|
1670
|
else {
|
1671
|
params = paramsArg.toString();
|
1672
|
}
|
1673
|
if (params.length > 0) {
|
1674
|
var prefix = '?';
|
1675
|
if (_this.url.indexOf('?') != -1) {
|
1676
|
prefix = (_this.url[_this.url.length - 1] == '&') ? '' : '&';
|
1677
|
}
|
1678
|
// TODO: just delete search-query-looking string in url?
|
1679
|
_this.url = url + prefix + params;
|
1680
|
}
|
1681
|
}
|
1682
|
_this._body = requestOptions.body;
|
1683
|
_this.method = normalizeMethodName(requestOptions.method);
|
1684
|
// TODO(jeffbcross): implement behavior
|
1685
|
// Defaults to 'omit', consistent with browser
|
1686
|
_this.headers = new Headers(requestOptions.headers);
|
1687
|
_this.contentType = _this.detectContentType();
|
1688
|
_this.withCredentials = requestOptions.withCredentials;
|
1689
|
_this.responseType = requestOptions.responseType;
|
1690
|
return _this;
|
1691
|
}
|
1692
|
/**
|
1693
|
* Returns the content type enum based on header options.
|
1694
|
* @return {?}
|
1695
|
*/
|
1696
|
Request.prototype.detectContentType = function () {
|
1697
|
switch (this.headers.get('content-type')) {
|
1698
|
case 'application/json':
|
1699
|
return ContentType.JSON;
|
1700
|
case 'application/x-www-form-urlencoded':
|
1701
|
return ContentType.FORM;
|
1702
|
case 'multipart/form-data':
|
1703
|
return ContentType.FORM_DATA;
|
1704
|
case 'text/plain':
|
1705
|
case 'text/html':
|
1706
|
return ContentType.TEXT;
|
1707
|
case 'application/octet-stream':
|
1708
|
return this._body instanceof ArrayBuffer$1 ? ContentType.ARRAY_BUFFER : ContentType.BLOB;
|
1709
|
default:
|
1710
|
return this.detectContentTypeFromBody();
|
1711
|
}
|
1712
|
};
|
1713
|
/**
|
1714
|
* Returns the content type of request's body based on its type.
|
1715
|
* @return {?}
|
1716
|
*/
|
1717
|
Request.prototype.detectContentTypeFromBody = function () {
|
1718
|
if (this._body == null) {
|
1719
|
return ContentType.NONE;
|
1720
|
}
|
1721
|
else if (this._body instanceof URLSearchParams) {
|
1722
|
return ContentType.FORM;
|
1723
|
}
|
1724
|
else if (this._body instanceof FormData) {
|
1725
|
return ContentType.FORM_DATA;
|
1726
|
}
|
1727
|
else if (this._body instanceof Blob$1) {
|
1728
|
return ContentType.BLOB;
|
1729
|
}
|
1730
|
else if (this._body instanceof ArrayBuffer$1) {
|
1731
|
return ContentType.ARRAY_BUFFER;
|
1732
|
}
|
1733
|
else if (this._body && typeof this._body === 'object') {
|
1734
|
return ContentType.JSON;
|
1735
|
}
|
1736
|
else {
|
1737
|
return ContentType.TEXT;
|
1738
|
}
|
1739
|
};
|
1740
|
/**
|
1741
|
* Returns the request's body according to its type. If body is undefined, return
|
1742
|
* null.
|
1743
|
* @return {?}
|
1744
|
*/
|
1745
|
Request.prototype.getBody = function () {
|
1746
|
switch (this.contentType) {
|
1747
|
case ContentType.JSON:
|
1748
|
return this.text();
|
1749
|
case ContentType.FORM:
|
1750
|
return this.text();
|
1751
|
case ContentType.FORM_DATA:
|
1752
|
return this._body;
|
1753
|
case ContentType.TEXT:
|
1754
|
return this.text();
|
1755
|
case ContentType.BLOB:
|
1756
|
return this.blob();
|
1757
|
case ContentType.ARRAY_BUFFER:
|
1758
|
return this.arrayBuffer();
|
1759
|
default:
|
1760
|
return null;
|
1761
|
}
|
1762
|
};
|
1763
|
return Request;
|
1764
|
}(Body));
|
1765
|
/**
|
1766
|
* @param {?} params
|
1767
|
* @return {?}
|
1768
|
*/
|
1769
|
function urlEncodeParams(params) {
|
1770
|
var /** @type {?} */ searchParams = new URLSearchParams();
|
1771
|
Object.keys(params).forEach(function (key) {
|
1772
|
var /** @type {?} */ value = params[key];
|
1773
|
if (value && Array.isArray(value)) {
|
1774
|
value.forEach(function (element) { return searchParams.append(key, element.toString()); });
|
1775
|
}
|
1776
|
else {
|
1777
|
searchParams.append(key, value.toString());
|
1778
|
}
|
1779
|
});
|
1780
|
return searchParams;
|
1781
|
}
|
1782
|
var noop = function () { };
|
1783
|
var w = typeof window == 'object' ? window : noop;
|
1784
|
var FormData = ((w) /** TODO #9100 */)['FormData'] || noop;
|
1785
|
var Blob$1 = ((w) /** TODO #9100 */)['Blob'] || noop;
|
1786
|
var ArrayBuffer$1 = ((w) /** TODO #9100 */)['ArrayBuffer'] || noop;
|
1787
|
/**
|
1788
|
* @license
|
1789
|
* Copyright Google Inc. All Rights Reserved.
|
1790
|
*
|
1791
|
* Use of this source code is governed by an MIT-style license that can be
|
1792
|
* found in the LICENSE file at https://angular.io/license
|
1793
|
*/
|
1794
|
/**
|
1795
|
* @param {?} backend
|
1796
|
* @param {?} request
|
1797
|
* @return {?}
|
1798
|
*/
|
1799
|
function httpRequest(backend, request) {
|
1800
|
return backend.createConnection(request).response;
|
1801
|
}
|
1802
|
/**
|
1803
|
* @param {?} defaultOpts
|
1804
|
* @param {?} providedOpts
|
1805
|
* @param {?} method
|
1806
|
* @param {?} url
|
1807
|
* @return {?}
|
1808
|
*/
|
1809
|
function mergeOptions(defaultOpts, providedOpts, method, url) {
|
1810
|
var /** @type {?} */ newOptions = defaultOpts;
|
1811
|
if (providedOpts) {
|
1812
|
// Hack so Dart can used named parameters
|
1813
|
return (newOptions.merge(new RequestOptions({
|
1814
|
method: providedOpts.method || method,
|
1815
|
url: providedOpts.url || url,
|
1816
|
search: providedOpts.search,
|
1817
|
params: providedOpts.params,
|
1818
|
headers: providedOpts.headers,
|
1819
|
body: providedOpts.body,
|
1820
|
withCredentials: providedOpts.withCredentials,
|
1821
|
responseType: providedOpts.responseType
|
1822
|
})));
|
1823
|
}
|
1824
|
return (newOptions.merge(new RequestOptions({ method: method, url: url })));
|
1825
|
}
|
1826
|
/**
|
1827
|
* Performs http requests using `XMLHttpRequest` as the default backend.
|
1828
|
*
|
1829
|
* `Http` is available as an injectable class, with methods to perform http requests. Calling
|
1830
|
* `request` returns an `Observable` which will emit a single {\@link Response} when a
|
1831
|
* response is received.
|
1832
|
*
|
1833
|
* ### Example
|
1834
|
*
|
1835
|
* ```typescript
|
1836
|
* import {Http, HTTP_PROVIDERS} from '\@angular/http';
|
1837
|
* import 'rxjs/add/operator/map'
|
1838
|
* \@Component({
|
1839
|
* selector: 'http-app',
|
1840
|
* viewProviders: [HTTP_PROVIDERS],
|
1841
|
* templateUrl: 'people.html'
|
1842
|
* })
|
1843
|
* class PeopleComponent {
|
1844
|
* constructor(http: Http) {
|
1845
|
* http.get('people.json')
|
1846
|
* // Call map on the response observable to get the parsed people object
|
1847
|
* .map(res => res.json())
|
1848
|
* // Subscribe to the observable to get the parsed people object and attach it to the
|
1849
|
* // component
|
1850
|
* .subscribe(people => this.people = people);
|
1851
|
* }
|
1852
|
* }
|
1853
|
* ```
|
1854
|
*
|
1855
|
*
|
1856
|
* ### Example
|
1857
|
*
|
1858
|
* ```
|
1859
|
* http.get('people.json').subscribe((res:Response) => this.people = res.json());
|
1860
|
* ```
|
1861
|
*
|
1862
|
* The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a "Backend" (
|
1863
|
* {\@link XHRBackend} in this case), which could be mocked with dependency injection by replacing
|
1864
|
* the {\@link XHRBackend} provider, as in the following example:
|
1865
|
*
|
1866
|
* ### Example
|
1867
|
*
|
1868
|
* ```typescript
|
1869
|
* import {BaseRequestOptions, Http} from '\@angular/http';
|
1870
|
* import {MockBackend} from '\@angular/http/testing';
|
1871
|
* var injector = Injector.resolveAndCreate([
|
1872
|
* BaseRequestOptions,
|
1873
|
* MockBackend,
|
1874
|
* {provide: Http, useFactory:
|
1875
|
* function(backend, defaultOptions) {
|
1876
|
* return new Http(backend, defaultOptions);
|
1877
|
* },
|
1878
|
* deps: [MockBackend, BaseRequestOptions]}
|
1879
|
* ]);
|
1880
|
* var http = injector.get(Http);
|
1881
|
* http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res));
|
1882
|
* ```
|
1883
|
*
|
1884
|
* \@experimental
|
1885
|
*/
|
1886
|
var Http = (function () {
|
1887
|
/**
|
1888
|
* @param {?} _backend
|
1889
|
* @param {?} _defaultOptions
|
1890
|
*/
|
1891
|
function Http(_backend, _defaultOptions) {
|
1892
|
this._backend = _backend;
|
1893
|
this._defaultOptions = _defaultOptions;
|
1894
|
}
|
1895
|
/**
|
1896
|
* Performs any type of http request. First argument is required, and can either be a url or
|
1897
|
* a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
|
1898
|
* object can be provided as the 2nd argument. The options object will be merged with the values
|
1899
|
* of {\@link BaseRequestOptions} before performing the request.
|
1900
|
* @param {?} url
|
1901
|
* @param {?=} options
|
1902
|
* @return {?}
|
1903
|
*/
|
1904
|
Http.prototype.request = function (url, options) {
|
1905
|
var /** @type {?} */ responseObservable;
|
1906
|
if (typeof url === 'string') {
|
1907
|
responseObservable = httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */ (url))));
|
1908
|
}
|
1909
|
else if (url instanceof Request) {
|
1910
|
responseObservable = httpRequest(this._backend, url);
|
1911
|
}
|
1912
|
else {
|
1913
|
throw new Error('First argument must be a url string or Request instance.');
|
1914
|
}
|
1915
|
return responseObservable;
|
1916
|
};
|
1917
|
/**
|
1918
|
* Performs a request with `get` http method.
|
1919
|
* @param {?} url
|
1920
|
* @param {?=} options
|
1921
|
* @return {?}
|
1922
|
*/
|
1923
|
Http.prototype.get = function (url, options) {
|
1924
|
return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url)));
|
1925
|
};
|
1926
|
/**
|
1927
|
* Performs a request with `post` http method.
|
1928
|
* @param {?} url
|
1929
|
* @param {?} body
|
1930
|
* @param {?=} options
|
1931
|
* @return {?}
|
1932
|
*/
|
1933
|
Http.prototype.post = function (url, body, options) {
|
1934
|
return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Post, url)));
|
1935
|
};
|
1936
|
/**
|
1937
|
* Performs a request with `put` http method.
|
1938
|
* @param {?} url
|
1939
|
* @param {?} body
|
1940
|
* @param {?=} options
|
1941
|
* @return {?}
|
1942
|
*/
|
1943
|
Http.prototype.put = function (url, body, options) {
|
1944
|
return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Put, url)));
|
1945
|
};
|
1946
|
/**
|
1947
|
* Performs a request with `delete` http method.
|
1948
|
* @param {?} url
|
1949
|
* @param {?=} options
|
1950
|
* @return {?}
|
1951
|
*/
|
1952
|
Http.prototype.delete = function (url, options) {
|
1953
|
return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Delete, url)));
|
1954
|
};
|
1955
|
/**
|
1956
|
* Performs a request with `patch` http method.
|
1957
|
* @param {?} url
|
1958
|
* @param {?} body
|
1959
|
* @param {?=} options
|
1960
|
* @return {?}
|
1961
|
*/
|
1962
|
Http.prototype.patch = function (url, body, options) {
|
1963
|
return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Patch, url)));
|
1964
|
};
|
1965
|
/**
|
1966
|
* Performs a request with `head` http method.
|
1967
|
* @param {?} url
|
1968
|
* @param {?=} options
|
1969
|
* @return {?}
|
1970
|
*/
|
1971
|
Http.prototype.head = function (url, options) {
|
1972
|
return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Head, url)));
|
1973
|
};
|
1974
|
/**
|
1975
|
* Performs a request with `options` http method.
|
1976
|
* @param {?} url
|
1977
|
* @param {?=} options
|
1978
|
* @return {?}
|
1979
|
*/
|
1980
|
Http.prototype.options = function (url, options) {
|
1981
|
return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Options, url)));
|
1982
|
};
|
1983
|
return Http;
|
1984
|
}());
|
1985
|
Http.decorators = [
|
1986
|
{ type: Injectable },
|
1987
|
];
|
1988
|
/**
|
1989
|
* @nocollapse
|
1990
|
*/
|
1991
|
Http.ctorParameters = function () { return [
|
1992
|
{ type: ConnectionBackend, },
|
1993
|
{ type: RequestOptions, },
|
1994
|
]; };
|
1995
|
/**
|
1996
|
* \@experimental
|
1997
|
*/
|
1998
|
var Jsonp = (function (_super) {
|
1999
|
tslib_1.__extends(Jsonp, _super);
|
2000
|
/**
|
2001
|
* @param {?} backend
|
2002
|
* @param {?} defaultOptions
|
2003
|
*/
|
2004
|
function Jsonp(backend, defaultOptions) {
|
2005
|
return _super.call(this, backend, defaultOptions) || this;
|
2006
|
}
|
2007
|
/**
|
2008
|
* Performs any type of http request. First argument is required, and can either be a url or
|
2009
|
* a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
|
2010
|
* object can be provided as the 2nd argument. The options object will be merged with the values
|
2011
|
* of {\@link BaseRequestOptions} before performing the request.
|
2012
|
*
|
2013
|
* \@security Regular XHR is the safest alternative to JSONP for most applications, and is
|
2014
|
* supported by all current browsers. Because JSONP creates a `<script>` element with
|
2015
|
* contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
|
2016
|
* source could expose your application to XSS risks. Data exposed by JSONP may also be
|
2017
|
* readable by malicious third-party websites. In addition, JSONP introduces potential risk for
|
2018
|
* future security issues (e.g. content sniffing). For more detail, see the
|
2019
|
* [Security Guide](http://g.co/ng/security).
|
2020
|
* @param {?} url
|
2021
|
* @param {?=} options
|
2022
|
* @return {?}
|
2023
|
*/
|
2024
|
Jsonp.prototype.request = function (url, options) {
|
2025
|
var /** @type {?} */ responseObservable;
|
2026
|
if (typeof url === 'string') {
|
2027
|
url =
|
2028
|
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */ (url)));
|
2029
|
}
|
2030
|
if (url instanceof Request) {
|
2031
|
if (url.method !== RequestMethod.Get) {
|
2032
|
throw new Error('JSONP requests must use GET request method.');
|
2033
|
}
|
2034
|
responseObservable = httpRequest(this._backend, url);
|
2035
|
}
|
2036
|
else {
|
2037
|
throw new Error('First argument must be a url string or Request instance.');
|
2038
|
}
|
2039
|
return responseObservable;
|
2040
|
};
|
2041
|
return Jsonp;
|
2042
|
}(Http));
|
2043
|
Jsonp.decorators = [
|
2044
|
{ type: Injectable },
|
2045
|
];
|
2046
|
/**
|
2047
|
* @nocollapse
|
2048
|
*/
|
2049
|
Jsonp.ctorParameters = function () { return [
|
2050
|
{ type: ConnectionBackend, },
|
2051
|
{ type: RequestOptions, },
|
2052
|
]; };
|
2053
|
/**
|
2054
|
* @license
|
2055
|
* Copyright Google Inc. All Rights Reserved.
|
2056
|
*
|
2057
|
* Use of this source code is governed by an MIT-style license that can be
|
2058
|
* found in the LICENSE file at https://angular.io/license
|
2059
|
*/
|
2060
|
/**
|
2061
|
* @module
|
2062
|
* @description
|
2063
|
* The http module provides services to perform http requests. To get started, see the {@link Http}
|
2064
|
* class.
|
2065
|
*/
|
2066
|
/**
|
2067
|
* @return {?}
|
2068
|
*/
|
2069
|
function _createDefaultCookieXSRFStrategy() {
|
2070
|
return new CookieXSRFStrategy();
|
2071
|
}
|
2072
|
/**
|
2073
|
* @param {?} xhrBackend
|
2074
|
* @param {?} requestOptions
|
2075
|
* @return {?}
|
2076
|
*/
|
2077
|
function httpFactory(xhrBackend, requestOptions) {
|
2078
|
return new Http(xhrBackend, requestOptions);
|
2079
|
}
|
2080
|
/**
|
2081
|
* @param {?} jsonpBackend
|
2082
|
* @param {?} requestOptions
|
2083
|
* @return {?}
|
2084
|
*/
|
2085
|
function jsonpFactory(jsonpBackend, requestOptions) {
|
2086
|
return new Jsonp(jsonpBackend, requestOptions);
|
2087
|
}
|
2088
|
/**
|
2089
|
* The module that includes http's providers
|
2090
|
*
|
2091
|
* \@experimental
|
2092
|
*/
|
2093
|
var HttpModule = (function () {
|
2094
|
function HttpModule() {
|
2095
|
}
|
2096
|
return HttpModule;
|
2097
|
}());
|
2098
|
HttpModule.decorators = [
|
2099
|
{ type: NgModule, args: [{
|
2100
|
providers: [
|
2101
|
// TODO(pascal): use factory type annotations once supported in DI
|
2102
|
// issue: https://github.com/angular/angular/issues/3183
|
2103
|
{ provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions] },
|
2104
|
BrowserXhr,
|
2105
|
{ provide: RequestOptions, useClass: BaseRequestOptions },
|
2106
|
{ provide: ResponseOptions, useClass: BaseResponseOptions },
|
2107
|
XHRBackend,
|
2108
|
{ provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy },
|
2109
|
],
|
2110
|
},] },
|
2111
|
];
|
2112
|
/**
|
2113
|
* @nocollapse
|
2114
|
*/
|
2115
|
HttpModule.ctorParameters = function () { return []; };
|
2116
|
/**
|
2117
|
* The module that includes jsonp's providers
|
2118
|
*
|
2119
|
* \@experimental
|
2120
|
*/
|
2121
|
var JsonpModule = (function () {
|
2122
|
function JsonpModule() {
|
2123
|
}
|
2124
|
return JsonpModule;
|
2125
|
}());
|
2126
|
JsonpModule.decorators = [
|
2127
|
{ type: NgModule, args: [{
|
2128
|
providers: [
|
2129
|
// TODO(pascal): use factory type annotations once supported in DI
|
2130
|
// issue: https://github.com/angular/angular/issues/3183
|
2131
|
{ provide: Jsonp, useFactory: jsonpFactory, deps: [JSONPBackend, RequestOptions] },
|
2132
|
BrowserJsonp,
|
2133
|
{ provide: RequestOptions, useClass: BaseRequestOptions },
|
2134
|
{ provide: ResponseOptions, useClass: BaseResponseOptions },
|
2135
|
{ provide: JSONPBackend, useClass: JSONPBackend_ },
|
2136
|
],
|
2137
|
},] },
|
2138
|
];
|
2139
|
/**
|
2140
|
* @nocollapse
|
2141
|
*/
|
2142
|
JsonpModule.ctorParameters = function () { return []; };
|
2143
|
/**
|
2144
|
* @license
|
2145
|
* Copyright Google Inc. All Rights Reserved.
|
2146
|
*
|
2147
|
* Use of this source code is governed by an MIT-style license that can be
|
2148
|
* found in the LICENSE file at https://angular.io/license
|
2149
|
*/
|
2150
|
/**
|
2151
|
* @module
|
2152
|
* @description
|
2153
|
* Entry point for all public APIs of the common package.
|
2154
|
*/
|
2155
|
/**
|
2156
|
* \@stable
|
2157
|
*/
|
2158
|
var VERSION = new Version('4.4.6');
|
2159
|
/**
|
2160
|
* @license
|
2161
|
* Copyright Google Inc. All Rights Reserved.
|
2162
|
*
|
2163
|
* Use of this source code is governed by an MIT-style license that can be
|
2164
|
* found in the LICENSE file at https://angular.io/license
|
2165
|
*/
|
2166
|
/**
|
2167
|
* @license
|
2168
|
* Copyright Google Inc. All Rights Reserved.
|
2169
|
*
|
2170
|
* Use of this source code is governed by an MIT-style license that can be
|
2171
|
* found in the LICENSE file at https://angular.io/license
|
2172
|
*/
|
2173
|
/**
|
2174
|
* @module
|
2175
|
* @description
|
2176
|
* Entry point for all public APIs of the http package.
|
2177
|
*/
|
2178
|
// This file only reexports content of the `src` folder. Keep it that way.
|
2179
|
/**
|
2180
|
* Generated bundle index. Do not edit.
|
2181
|
*/
|
2182
|
export { BrowserXhr, JSONPBackend, JSONPConnection, CookieXSRFStrategy, XHRBackend, XHRConnection, BaseRequestOptions, RequestOptions, BaseResponseOptions, ResponseOptions, ReadyState, RequestMethod, ResponseContentType, ResponseType, Headers, Http, Jsonp, HttpModule, JsonpModule, Connection, ConnectionBackend, XSRFStrategy, Request, Response, QueryEncoder, URLSearchParams, VERSION, BrowserJsonp as ɵg, JSONPBackend_ as ɵa, Body as ɵf, _createDefaultCookieXSRFStrategy as ɵb, httpFactory as ɵc, jsonpFactory as ɵd };
|
2183
|
//# sourceMappingURL=http.es5.js.map
|