1
|
/**
|
2
|
* @license Angular v4.4.6
|
3
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
4
|
* License: MIT
|
5
|
*/
|
6
|
(function (global, factory) {
|
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('@angular/core'), require('rxjs/observable/of'), require('rxjs/operator/concatMap'), require('rxjs/operator/filter'), require('rxjs/operator/map'), require('@angular/common'), require('rxjs/Observable')) :
|
8
|
typeof define === 'function' && define.amd ? define(['exports', 'tslib', '@angular/core', 'rxjs/observable/of', 'rxjs/operator/concatMap', 'rxjs/operator/filter', 'rxjs/operator/map', '@angular/common', 'rxjs/Observable'], factory) :
|
9
|
(factory((global.ng = global.ng || {}, global.ng.common = global.ng.common || {}, global.ng.common.http = global.ng.common.http || {}),global.tslib_1,global.ng.core,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global._angular_common,global.Rx));
|
10
|
}(this, (function (exports,tslib_1,_angular_core,rxjs_observable_of,rxjs_operator_concatMap,rxjs_operator_filter,rxjs_operator_map,_angular_common,rxjs_Observable) { 'use strict';
|
11
|
|
12
|
/**
|
13
|
* @license Angular v4.4.6
|
14
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
15
|
* License: MIT
|
16
|
*/
|
17
|
/**
|
18
|
* @license
|
19
|
* Copyright Google Inc. All Rights Reserved.
|
20
|
*
|
21
|
* Use of this source code is governed by an MIT-style license that can be
|
22
|
* found in the LICENSE file at https://angular.io/license
|
23
|
*/
|
24
|
/**
|
25
|
* Transforms an `HttpRequest` into a stream of `HttpEvent`s, one of which will likely be a
|
26
|
* `HttpResponse`.
|
27
|
*
|
28
|
* `HttpHandler` is injectable. When injected, the handler instance dispatches requests to the
|
29
|
* first interceptor in the chain, which dispatches to the second, etc, eventually reaching the
|
30
|
* `HttpBackend`.
|
31
|
*
|
32
|
* In an `HttpInterceptor`, the `HttpHandler` parameter is the next interceptor in the chain.
|
33
|
*
|
34
|
* \@experimental
|
35
|
* @abstract
|
36
|
*/
|
37
|
var HttpHandler = (function () {
|
38
|
function HttpHandler() {
|
39
|
}
|
40
|
/**
|
41
|
* @abstract
|
42
|
* @param {?} req
|
43
|
* @return {?}
|
44
|
*/
|
45
|
HttpHandler.prototype.handle = function (req) { };
|
46
|
return HttpHandler;
|
47
|
}());
|
48
|
/**
|
49
|
* A final `HttpHandler` which will dispatch the request via browser HTTP APIs to a backend.
|
50
|
*
|
51
|
* Interceptors sit between the `HttpClient` interface and the `HttpBackend`.
|
52
|
*
|
53
|
* When injected, `HttpBackend` dispatches requests directly to the backend, without going
|
54
|
* through the interceptor chain.
|
55
|
*
|
56
|
* \@experimental
|
57
|
* @abstract
|
58
|
*/
|
59
|
var HttpBackend = (function () {
|
60
|
function HttpBackend() {
|
61
|
}
|
62
|
/**
|
63
|
* @abstract
|
64
|
* @param {?} req
|
65
|
* @return {?}
|
66
|
*/
|
67
|
HttpBackend.prototype.handle = function (req) { };
|
68
|
return HttpBackend;
|
69
|
}());
|
70
|
/**
|
71
|
* @license
|
72
|
* Copyright Google Inc. All Rights Reserved.
|
73
|
*
|
74
|
* Use of this source code is governed by an MIT-style license that can be
|
75
|
* found in the LICENSE file at https://angular.io/license
|
76
|
*/
|
77
|
/**
|
78
|
* A `HttpParameterCodec` that uses `encodeURIComponent` and `decodeURIComponent` to
|
79
|
* serialize and parse URL parameter keys and values.
|
80
|
*
|
81
|
* \@experimental
|
82
|
*/
|
83
|
var HttpUrlEncodingCodec = (function () {
|
84
|
function HttpUrlEncodingCodec() {
|
85
|
}
|
86
|
/**
|
87
|
* @param {?} k
|
88
|
* @return {?}
|
89
|
*/
|
90
|
HttpUrlEncodingCodec.prototype.encodeKey = function (k) { return standardEncoding(k); };
|
91
|
/**
|
92
|
* @param {?} v
|
93
|
* @return {?}
|
94
|
*/
|
95
|
HttpUrlEncodingCodec.prototype.encodeValue = function (v) { return standardEncoding(v); };
|
96
|
/**
|
97
|
* @param {?} k
|
98
|
* @return {?}
|
99
|
*/
|
100
|
HttpUrlEncodingCodec.prototype.decodeKey = function (k) { return decodeURIComponent(k); };
|
101
|
/**
|
102
|
* @param {?} v
|
103
|
* @return {?}
|
104
|
*/
|
105
|
HttpUrlEncodingCodec.prototype.decodeValue = function (v) { return decodeURIComponent(v); };
|
106
|
return HttpUrlEncodingCodec;
|
107
|
}());
|
108
|
/**
|
109
|
* @param {?} rawParams
|
110
|
* @param {?} codec
|
111
|
* @return {?}
|
112
|
*/
|
113
|
function paramParser(rawParams, codec) {
|
114
|
var /** @type {?} */ map$$1 = new Map();
|
115
|
if (rawParams.length > 0) {
|
116
|
var /** @type {?} */ params = rawParams.split('&');
|
117
|
params.forEach(function (param) {
|
118
|
var /** @type {?} */ eqIdx = param.indexOf('=');
|
119
|
var _a = eqIdx == -1 ?
|
120
|
[codec.decodeKey(param), ''] :
|
121
|
[codec.decodeKey(param.slice(0, eqIdx)), codec.decodeValue(param.slice(eqIdx + 1))], key = _a[0], val = _a[1];
|
122
|
var /** @type {?} */ list = map$$1.get(key) || [];
|
123
|
list.push(val);
|
124
|
map$$1.set(key, list);
|
125
|
});
|
126
|
}
|
127
|
return map$$1;
|
128
|
}
|
129
|
/**
|
130
|
* @param {?} v
|
131
|
* @return {?}
|
132
|
*/
|
133
|
function standardEncoding(v) {
|
134
|
return encodeURIComponent(v)
|
135
|
.replace(/%40/gi, '@')
|
136
|
.replace(/%3A/gi, ':')
|
137
|
.replace(/%24/gi, '$')
|
138
|
.replace(/%2C/gi, ',')
|
139
|
.replace(/%3B/gi, ';')
|
140
|
.replace(/%2B/gi, '+')
|
141
|
.replace(/%3D/gi, '=')
|
142
|
.replace(/%3F/gi, '?')
|
143
|
.replace(/%2F/gi, '/');
|
144
|
}
|
145
|
/**
|
146
|
* An HTTP request/response body that represents serialized parameters,
|
147
|
* per the MIME type `application/x-www-form-urlencoded`.
|
148
|
*
|
149
|
* This class is immuatable - all mutation operations return a new instance.
|
150
|
*
|
151
|
* \@experimental
|
152
|
*/
|
153
|
var HttpParams = (function () {
|
154
|
/**
|
155
|
* @param {?=} options
|
156
|
*/
|
157
|
function HttpParams(options) {
|
158
|
if (options === void 0) { options = {}; }
|
159
|
this.updates = null;
|
160
|
this.cloneFrom = null;
|
161
|
this.encoder = options.encoder || new HttpUrlEncodingCodec();
|
162
|
this.map = !!options.fromString ? paramParser(options.fromString, this.encoder) : null;
|
163
|
}
|
164
|
/**
|
165
|
* Check whether the body has one or more values for the given parameter name.
|
166
|
* @param {?} param
|
167
|
* @return {?}
|
168
|
*/
|
169
|
HttpParams.prototype.has = function (param) {
|
170
|
this.init();
|
171
|
return ((this.map)).has(param);
|
172
|
};
|
173
|
/**
|
174
|
* Get the first value for the given parameter name, or `null` if it's not present.
|
175
|
* @param {?} param
|
176
|
* @return {?}
|
177
|
*/
|
178
|
HttpParams.prototype.get = function (param) {
|
179
|
this.init();
|
180
|
var /** @type {?} */ res = ((this.map)).get(param);
|
181
|
return !!res ? res[0] : null;
|
182
|
};
|
183
|
/**
|
184
|
* Get all values for the given parameter name, or `null` if it's not present.
|
185
|
* @param {?} param
|
186
|
* @return {?}
|
187
|
*/
|
188
|
HttpParams.prototype.getAll = function (param) {
|
189
|
this.init();
|
190
|
return ((this.map)).get(param) || null;
|
191
|
};
|
192
|
/**
|
193
|
* Get all the parameter names for this body.
|
194
|
* @return {?}
|
195
|
*/
|
196
|
HttpParams.prototype.keys = function () {
|
197
|
this.init();
|
198
|
return Array.from(/** @type {?} */ ((this.map)).keys());
|
199
|
};
|
200
|
/**
|
201
|
* Construct a new body with an appended value for the given parameter name.
|
202
|
* @param {?} param
|
203
|
* @param {?} value
|
204
|
* @return {?}
|
205
|
*/
|
206
|
HttpParams.prototype.append = function (param, value) { return this.clone({ param: param, value: value, op: 'a' }); };
|
207
|
/**
|
208
|
* Construct a new body with a new value for the given parameter name.
|
209
|
* @param {?} param
|
210
|
* @param {?} value
|
211
|
* @return {?}
|
212
|
*/
|
213
|
HttpParams.prototype.set = function (param, value) { return this.clone({ param: param, value: value, op: 's' }); };
|
214
|
/**
|
215
|
* Construct a new body with either the given value for the given parameter
|
216
|
* removed, if a value is given, or all values for the given parameter removed
|
217
|
* if not.
|
218
|
* @param {?} param
|
219
|
* @param {?=} value
|
220
|
* @return {?}
|
221
|
*/
|
222
|
HttpParams.prototype.delete = function (param, value) { return this.clone({ param: param, value: value, op: 'd' }); };
|
223
|
/**
|
224
|
* Serialize the body to an encoded string, where key-value pairs (separated by `=`) are
|
225
|
* separated by `&`s.
|
226
|
* @return {?}
|
227
|
*/
|
228
|
HttpParams.prototype.toString = function () {
|
229
|
var _this = this;
|
230
|
this.init();
|
231
|
return this.keys()
|
232
|
.map(function (key) {
|
233
|
var /** @type {?} */ eKey = _this.encoder.encodeKey(key);
|
234
|
return ((((_this.map)).get(key))).map(function (value) { return eKey + '=' + _this.encoder.encodeValue(value); })
|
235
|
.join('&');
|
236
|
})
|
237
|
.join('&');
|
238
|
};
|
239
|
/**
|
240
|
* @param {?} update
|
241
|
* @return {?}
|
242
|
*/
|
243
|
HttpParams.prototype.clone = function (update) {
|
244
|
var /** @type {?} */ clone = new HttpParams({ encoder: this.encoder });
|
245
|
clone.cloneFrom = this.cloneFrom || this;
|
246
|
clone.updates = (this.updates || []).concat([update]);
|
247
|
return clone;
|
248
|
};
|
249
|
/**
|
250
|
* @return {?}
|
251
|
*/
|
252
|
HttpParams.prototype.init = function () {
|
253
|
var _this = this;
|
254
|
if (this.map === null) {
|
255
|
this.map = new Map();
|
256
|
}
|
257
|
if (this.cloneFrom !== null) {
|
258
|
this.cloneFrom.init();
|
259
|
this.cloneFrom.keys().forEach(function (key) { return ((_this.map)).set(key, /** @type {?} */ ((((((_this.cloneFrom)).map)).get(key)))); }); /** @type {?} */
|
260
|
((this.updates)).forEach(function (update) {
|
261
|
switch (update.op) {
|
262
|
case 'a':
|
263
|
case 's':
|
264
|
var /** @type {?} */ base = (update.op === 'a' ? ((_this.map)).get(update.param) : undefined) || [];
|
265
|
base.push(/** @type {?} */ ((update.value))); /** @type {?} */
|
266
|
((_this.map)).set(update.param, base);
|
267
|
break;
|
268
|
case 'd':
|
269
|
if (update.value !== undefined) {
|
270
|
var /** @type {?} */ base_1 = ((_this.map)).get(update.param) || [];
|
271
|
var /** @type {?} */ idx = base_1.indexOf(update.value);
|
272
|
if (idx !== -1) {
|
273
|
base_1.splice(idx, 1);
|
274
|
}
|
275
|
if (base_1.length > 0) {
|
276
|
((_this.map)).set(update.param, base_1);
|
277
|
}
|
278
|
else {
|
279
|
((_this.map)).delete(update.param);
|
280
|
}
|
281
|
}
|
282
|
else {
|
283
|
((_this.map)).delete(update.param);
|
284
|
break;
|
285
|
}
|
286
|
}
|
287
|
});
|
288
|
this.cloneFrom = null;
|
289
|
}
|
290
|
};
|
291
|
return HttpParams;
|
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
|
* Immutable set of Http headers, with lazy parsing.
|
302
|
* \@experimental
|
303
|
*/
|
304
|
var HttpHeaders = (function () {
|
305
|
/**
|
306
|
* @param {?=} headers
|
307
|
*/
|
308
|
function HttpHeaders(headers) {
|
309
|
var _this = this;
|
310
|
/**
|
311
|
* Internal map of lowercased header names to the normalized
|
312
|
* form of the name (the form seen first).
|
313
|
*/
|
314
|
this.normalizedNames = new Map();
|
315
|
/**
|
316
|
* Queued updates to be materialized the next initialization.
|
317
|
*/
|
318
|
this.lazyUpdate = null;
|
319
|
if (!headers) {
|
320
|
this.headers = new Map();
|
321
|
}
|
322
|
else if (typeof headers === 'string') {
|
323
|
this.lazyInit = function () {
|
324
|
_this.headers = new Map();
|
325
|
headers.split('\n').forEach(function (line) {
|
326
|
var index = line.indexOf(':');
|
327
|
if (index > 0) {
|
328
|
var name = line.slice(0, index);
|
329
|
var key = name.toLowerCase();
|
330
|
var value = line.slice(index + 1).trim();
|
331
|
_this.maybeSetNormalizedName(name, key);
|
332
|
if (_this.headers.has(key)) {
|
333
|
_this.headers.get(key).push(value);
|
334
|
}
|
335
|
else {
|
336
|
_this.headers.set(key, [value]);
|
337
|
}
|
338
|
}
|
339
|
});
|
340
|
};
|
341
|
}
|
342
|
else {
|
343
|
this.lazyInit = function () {
|
344
|
_this.headers = new Map();
|
345
|
Object.keys(headers).forEach(function (name) {
|
346
|
var values = headers[name];
|
347
|
var key = name.toLowerCase();
|
348
|
if (typeof values === 'string') {
|
349
|
values = [values];
|
350
|
}
|
351
|
if (values.length > 0) {
|
352
|
_this.headers.set(key, values);
|
353
|
_this.maybeSetNormalizedName(name, key);
|
354
|
}
|
355
|
});
|
356
|
};
|
357
|
}
|
358
|
}
|
359
|
/**
|
360
|
* Checks for existence of header by given name.
|
361
|
* @param {?} name
|
362
|
* @return {?}
|
363
|
*/
|
364
|
HttpHeaders.prototype.has = function (name) {
|
365
|
this.init();
|
366
|
return this.headers.has(name.toLowerCase());
|
367
|
};
|
368
|
/**
|
369
|
* Returns first header that matches given name.
|
370
|
* @param {?} name
|
371
|
* @return {?}
|
372
|
*/
|
373
|
HttpHeaders.prototype.get = function (name) {
|
374
|
this.init();
|
375
|
var /** @type {?} */ values = this.headers.get(name.toLowerCase());
|
376
|
return values && values.length > 0 ? values[0] : null;
|
377
|
};
|
378
|
/**
|
379
|
* Returns the names of the headers
|
380
|
* @return {?}
|
381
|
*/
|
382
|
HttpHeaders.prototype.keys = function () {
|
383
|
this.init();
|
384
|
return Array.from(this.normalizedNames.values());
|
385
|
};
|
386
|
/**
|
387
|
* Returns list of header values for a given name.
|
388
|
* @param {?} name
|
389
|
* @return {?}
|
390
|
*/
|
391
|
HttpHeaders.prototype.getAll = function (name) {
|
392
|
this.init();
|
393
|
return this.headers.get(name.toLowerCase()) || null;
|
394
|
};
|
395
|
/**
|
396
|
* @param {?} name
|
397
|
* @param {?} value
|
398
|
* @return {?}
|
399
|
*/
|
400
|
HttpHeaders.prototype.append = function (name, value) {
|
401
|
return this.clone({ name: name, value: value, op: 'a' });
|
402
|
};
|
403
|
/**
|
404
|
* @param {?} name
|
405
|
* @param {?} value
|
406
|
* @return {?}
|
407
|
*/
|
408
|
HttpHeaders.prototype.set = function (name, value) {
|
409
|
return this.clone({ name: name, value: value, op: 's' });
|
410
|
};
|
411
|
/**
|
412
|
* @param {?} name
|
413
|
* @param {?=} value
|
414
|
* @return {?}
|
415
|
*/
|
416
|
HttpHeaders.prototype.delete = function (name, value) {
|
417
|
return this.clone({ name: name, value: value, op: 'd' });
|
418
|
};
|
419
|
/**
|
420
|
* @param {?} name
|
421
|
* @param {?} lcName
|
422
|
* @return {?}
|
423
|
*/
|
424
|
HttpHeaders.prototype.maybeSetNormalizedName = function (name, lcName) {
|
425
|
if (!this.normalizedNames.has(lcName)) {
|
426
|
this.normalizedNames.set(lcName, name);
|
427
|
}
|
428
|
};
|
429
|
/**
|
430
|
* @return {?}
|
431
|
*/
|
432
|
HttpHeaders.prototype.init = function () {
|
433
|
var _this = this;
|
434
|
if (!!this.lazyInit) {
|
435
|
if (this.lazyInit instanceof HttpHeaders) {
|
436
|
this.copyFrom(this.lazyInit);
|
437
|
}
|
438
|
else {
|
439
|
this.lazyInit();
|
440
|
}
|
441
|
this.lazyInit = null;
|
442
|
if (!!this.lazyUpdate) {
|
443
|
this.lazyUpdate.forEach(function (update) { return _this.applyUpdate(update); });
|
444
|
this.lazyUpdate = null;
|
445
|
}
|
446
|
}
|
447
|
};
|
448
|
/**
|
449
|
* @param {?} other
|
450
|
* @return {?}
|
451
|
*/
|
452
|
HttpHeaders.prototype.copyFrom = function (other) {
|
453
|
var _this = this;
|
454
|
other.init();
|
455
|
Array.from(other.headers.keys()).forEach(function (key) {
|
456
|
_this.headers.set(key, /** @type {?} */ ((other.headers.get(key))));
|
457
|
_this.normalizedNames.set(key, /** @type {?} */ ((other.normalizedNames.get(key))));
|
458
|
});
|
459
|
};
|
460
|
/**
|
461
|
* @param {?} update
|
462
|
* @return {?}
|
463
|
*/
|
464
|
HttpHeaders.prototype.clone = function (update) {
|
465
|
var /** @type {?} */ clone = new HttpHeaders();
|
466
|
clone.lazyInit =
|
467
|
(!!this.lazyInit && this.lazyInit instanceof HttpHeaders) ? this.lazyInit : this;
|
468
|
clone.lazyUpdate = (this.lazyUpdate || []).concat([update]);
|
469
|
return clone;
|
470
|
};
|
471
|
/**
|
472
|
* @param {?} update
|
473
|
* @return {?}
|
474
|
*/
|
475
|
HttpHeaders.prototype.applyUpdate = function (update) {
|
476
|
var /** @type {?} */ key = update.name.toLowerCase();
|
477
|
switch (update.op) {
|
478
|
case 'a':
|
479
|
case 's':
|
480
|
var /** @type {?} */ value = ((update.value));
|
481
|
if (typeof value === 'string') {
|
482
|
value = [value];
|
483
|
}
|
484
|
if (value.length === 0) {
|
485
|
return;
|
486
|
}
|
487
|
this.maybeSetNormalizedName(update.name, key);
|
488
|
var /** @type {?} */ base = (update.op === 'a' ? this.headers.get(key) : undefined) || [];
|
489
|
base.push.apply(base, value);
|
490
|
this.headers.set(key, base);
|
491
|
break;
|
492
|
case 'd':
|
493
|
var /** @type {?} */ toDelete_1 = (update.value);
|
494
|
if (!toDelete_1) {
|
495
|
this.headers.delete(key);
|
496
|
this.normalizedNames.delete(key);
|
497
|
}
|
498
|
else {
|
499
|
var /** @type {?} */ existing = this.headers.get(key);
|
500
|
if (!existing) {
|
501
|
return;
|
502
|
}
|
503
|
existing = existing.filter(function (value) { return toDelete_1.indexOf(value) === -1; });
|
504
|
if (existing.length === 0) {
|
505
|
this.headers.delete(key);
|
506
|
this.normalizedNames.delete(key);
|
507
|
}
|
508
|
else {
|
509
|
this.headers.set(key, existing);
|
510
|
}
|
511
|
}
|
512
|
break;
|
513
|
}
|
514
|
};
|
515
|
/**
|
516
|
* \@internal
|
517
|
* @param {?} fn
|
518
|
* @return {?}
|
519
|
*/
|
520
|
HttpHeaders.prototype.forEach = function (fn) {
|
521
|
var _this = this;
|
522
|
this.init();
|
523
|
Array.from(this.normalizedNames.keys())
|
524
|
.forEach(function (key) { return fn(/** @type {?} */ ((_this.normalizedNames.get(key))), /** @type {?} */ ((_this.headers.get(key)))); });
|
525
|
};
|
526
|
return HttpHeaders;
|
527
|
}());
|
528
|
/**
|
529
|
* @license
|
530
|
* Copyright Google Inc. All Rights Reserved.
|
531
|
*
|
532
|
* Use of this source code is governed by an MIT-style license that can be
|
533
|
* found in the LICENSE file at https://angular.io/license
|
534
|
*/
|
535
|
/**
|
536
|
* Determine whether the given HTTP method may include a body.
|
537
|
* @param {?} method
|
538
|
* @return {?}
|
539
|
*/
|
540
|
function mightHaveBody(method) {
|
541
|
switch (method) {
|
542
|
case 'DELETE':
|
543
|
case 'GET':
|
544
|
case 'HEAD':
|
545
|
case 'OPTIONS':
|
546
|
case 'JSONP':
|
547
|
return false;
|
548
|
default:
|
549
|
return true;
|
550
|
}
|
551
|
}
|
552
|
/**
|
553
|
* Safely assert whether the given value is an ArrayBuffer.
|
554
|
*
|
555
|
* In some execution environments ArrayBuffer is not defined.
|
556
|
* @param {?} value
|
557
|
* @return {?}
|
558
|
*/
|
559
|
function isArrayBuffer(value) {
|
560
|
return typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;
|
561
|
}
|
562
|
/**
|
563
|
* Safely assert whether the given value is a Blob.
|
564
|
*
|
565
|
* In some execution environments Blob is not defined.
|
566
|
* @param {?} value
|
567
|
* @return {?}
|
568
|
*/
|
569
|
function isBlob(value) {
|
570
|
return typeof Blob !== 'undefined' && value instanceof Blob;
|
571
|
}
|
572
|
/**
|
573
|
* Safely assert whether the given value is a FormData instance.
|
574
|
*
|
575
|
* In some execution environments FormData is not defined.
|
576
|
* @param {?} value
|
577
|
* @return {?}
|
578
|
*/
|
579
|
function isFormData(value) {
|
580
|
return typeof FormData !== 'undefined' && value instanceof FormData;
|
581
|
}
|
582
|
/**
|
583
|
* An outgoing HTTP request with an optional typed body.
|
584
|
*
|
585
|
* `HttpRequest` represents an outgoing request, including URL, method,
|
586
|
* headers, body, and other request configuration options. Instances should be
|
587
|
* assumed to be immutable. To modify a `HttpRequest`, the `clone`
|
588
|
* method should be used.
|
589
|
*
|
590
|
* \@experimental
|
591
|
*/
|
592
|
var HttpRequest = (function () {
|
593
|
/**
|
594
|
* @param {?} method
|
595
|
* @param {?} url
|
596
|
* @param {?=} third
|
597
|
* @param {?=} fourth
|
598
|
*/
|
599
|
function HttpRequest(method, url, third, fourth) {
|
600
|
this.url = url;
|
601
|
/**
|
602
|
* The request body, or `null` if one isn't set.
|
603
|
*
|
604
|
* Bodies are not enforced to be immutable, as they can include a reference to any
|
605
|
* user-defined data type. However, interceptors should take care to preserve
|
606
|
* idempotence by treating them as such.
|
607
|
*/
|
608
|
this.body = null;
|
609
|
/**
|
610
|
* Whether this request should be made in a way that exposes progress events.
|
611
|
*
|
612
|
* Progress events are expensive (change detection runs on each event) and so
|
613
|
* they should only be requested if the consumer intends to monitor them.
|
614
|
*/
|
615
|
this.reportProgress = false;
|
616
|
/**
|
617
|
* Whether this request should be sent with outgoing credentials (cookies).
|
618
|
*/
|
619
|
this.withCredentials = false;
|
620
|
/**
|
621
|
* The expected response type of the server.
|
622
|
*
|
623
|
* This is used to parse the response appropriately before returning it to
|
624
|
* the requestee.
|
625
|
*/
|
626
|
this.responseType = 'json';
|
627
|
this.method = method.toUpperCase();
|
628
|
// Next, need to figure out which argument holds the HttpRequestInit
|
629
|
// options, if any.
|
630
|
var options;
|
631
|
// Check whether a body argument is expected. The only valid way to omit
|
632
|
// the body argument is to use a known no-body method like GET.
|
633
|
if (mightHaveBody(this.method) || !!fourth) {
|
634
|
// Body is the third argument, options are the fourth.
|
635
|
this.body = third || null;
|
636
|
options = fourth;
|
637
|
}
|
638
|
else {
|
639
|
// No body required, options are the third argument. The body stays null.
|
640
|
options = third;
|
641
|
}
|
642
|
// If options have been passed, interpret them.
|
643
|
if (options) {
|
644
|
// Normalize reportProgress and withCredentials.
|
645
|
this.reportProgress = !!options.reportProgress;
|
646
|
this.withCredentials = !!options.withCredentials;
|
647
|
// Override default response type of 'json' if one is provided.
|
648
|
if (!!options.responseType) {
|
649
|
this.responseType = options.responseType;
|
650
|
}
|
651
|
// Override headers if they're provided.
|
652
|
if (!!options.headers) {
|
653
|
this.headers = options.headers;
|
654
|
}
|
655
|
if (!!options.params) {
|
656
|
this.params = options.params;
|
657
|
}
|
658
|
}
|
659
|
// If no headers have been passed in, construct a new HttpHeaders instance.
|
660
|
if (!this.headers) {
|
661
|
this.headers = new HttpHeaders();
|
662
|
}
|
663
|
// If no parameters have been passed in, construct a new HttpUrlEncodedParams instance.
|
664
|
if (!this.params) {
|
665
|
this.params = new HttpParams();
|
666
|
this.urlWithParams = url;
|
667
|
}
|
668
|
else {
|
669
|
// Encode the parameters to a string in preparation for inclusion in the URL.
|
670
|
var params = this.params.toString();
|
671
|
if (params.length === 0) {
|
672
|
// No parameters, the visible URL is just the URL given at creation time.
|
673
|
this.urlWithParams = url;
|
674
|
}
|
675
|
else {
|
676
|
// Does the URL already have query parameters? Look for '?'.
|
677
|
var qIdx = url.indexOf('?');
|
678
|
// There are 3 cases to handle:
|
679
|
// 1) No existing parameters -> append '?' followed by params.
|
680
|
// 2) '?' exists and is followed by existing query string ->
|
681
|
// append '&' followed by params.
|
682
|
// 3) '?' exists at the end of the url -> append params directly.
|
683
|
// This basically amounts to determining the character, if any, with
|
684
|
// which to join the URL and parameters.
|
685
|
var sep = qIdx === -1 ? '?' : (qIdx < url.length - 1 ? '&' : '');
|
686
|
this.urlWithParams = url + sep + params;
|
687
|
}
|
688
|
}
|
689
|
}
|
690
|
/**
|
691
|
* Transform the free-form body into a serialized format suitable for
|
692
|
* transmission to the server.
|
693
|
* @return {?}
|
694
|
*/
|
695
|
HttpRequest.prototype.serializeBody = function () {
|
696
|
// If no body is present, no need to serialize it.
|
697
|
if (this.body === null) {
|
698
|
return null;
|
699
|
}
|
700
|
// Check whether the body is already in a serialized form. If so,
|
701
|
// it can just be returned directly.
|
702
|
if (isArrayBuffer(this.body) || isBlob(this.body) || isFormData(this.body) ||
|
703
|
typeof this.body === 'string') {
|
704
|
return this.body;
|
705
|
}
|
706
|
// Check whether the body is an instance of HttpUrlEncodedParams.
|
707
|
if (this.body instanceof HttpParams) {
|
708
|
return this.body.toString();
|
709
|
}
|
710
|
// Check whether the body is an object or array, and serialize with JSON if so.
|
711
|
if (typeof this.body === 'object' || typeof this.body === 'boolean' ||
|
712
|
Array.isArray(this.body)) {
|
713
|
return JSON.stringify(this.body);
|
714
|
}
|
715
|
// Fall back on toString() for everything else.
|
716
|
return ((this.body)).toString();
|
717
|
};
|
718
|
/**
|
719
|
* Examine the body and attempt to infer an appropriate MIME type
|
720
|
* for it.
|
721
|
*
|
722
|
* If no such type can be inferred, this method will return `null`.
|
723
|
* @return {?}
|
724
|
*/
|
725
|
HttpRequest.prototype.detectContentTypeHeader = function () {
|
726
|
// An empty body has no content type.
|
727
|
if (this.body === null) {
|
728
|
return null;
|
729
|
}
|
730
|
// FormData bodies rely on the browser's content type assignment.
|
731
|
if (isFormData(this.body)) {
|
732
|
return null;
|
733
|
}
|
734
|
// Blobs usually have their own content type. If it doesn't, then
|
735
|
// no type can be inferred.
|
736
|
if (isBlob(this.body)) {
|
737
|
return this.body.type || null;
|
738
|
}
|
739
|
// Array buffers have unknown contents and thus no type can be inferred.
|
740
|
if (isArrayBuffer(this.body)) {
|
741
|
return null;
|
742
|
}
|
743
|
// Technically, strings could be a form of JSON data, but it's safe enough
|
744
|
// to assume they're plain strings.
|
745
|
if (typeof this.body === 'string') {
|
746
|
return 'text/plain';
|
747
|
}
|
748
|
// `HttpUrlEncodedParams` has its own content-type.
|
749
|
if (this.body instanceof HttpParams) {
|
750
|
return 'application/x-www-form-urlencoded;charset=UTF-8';
|
751
|
}
|
752
|
// Arrays, objects, and numbers will be encoded as JSON.
|
753
|
if (typeof this.body === 'object' || typeof this.body === 'number' ||
|
754
|
Array.isArray(this.body)) {
|
755
|
return 'application/json';
|
756
|
}
|
757
|
// No type could be inferred.
|
758
|
return null;
|
759
|
};
|
760
|
/**
|
761
|
* @param {?=} update
|
762
|
* @return {?}
|
763
|
*/
|
764
|
HttpRequest.prototype.clone = function (update) {
|
765
|
if (update === void 0) { update = {}; }
|
766
|
// For method, url, and responseType, take the current value unless
|
767
|
// it is overridden in the update hash.
|
768
|
var /** @type {?} */ method = update.method || this.method;
|
769
|
var /** @type {?} */ url = update.url || this.url;
|
770
|
var /** @type {?} */ responseType = update.responseType || this.responseType;
|
771
|
// The body is somewhat special - a `null` value in update.body means
|
772
|
// whatever current body is present is being overridden with an empty
|
773
|
// body, whereas an `undefined` value in update.body implies no
|
774
|
// override.
|
775
|
var /** @type {?} */ body = (update.body !== undefined) ? update.body : this.body;
|
776
|
// Carefully handle the boolean options to differentiate between
|
777
|
// `false` and `undefined` in the update args.
|
778
|
var /** @type {?} */ withCredentials = (update.withCredentials !== undefined) ? update.withCredentials : this.withCredentials;
|
779
|
var /** @type {?} */ reportProgress = (update.reportProgress !== undefined) ? update.reportProgress : this.reportProgress;
|
780
|
// Headers and params may be appended to if `setHeaders` or
|
781
|
// `setParams` are used.
|
782
|
var /** @type {?} */ headers = update.headers || this.headers;
|
783
|
var /** @type {?} */ params = update.params || this.params;
|
784
|
// Check whether the caller has asked to add headers.
|
785
|
if (update.setHeaders !== undefined) {
|
786
|
// Set every requested header.
|
787
|
headers =
|
788
|
Object.keys(update.setHeaders)
|
789
|
.reduce(function (headers, name) { return headers.set(name, /** @type {?} */ ((update.setHeaders))[name]); }, headers);
|
790
|
}
|
791
|
// Check whether the caller has asked to set params.
|
792
|
if (update.setParams) {
|
793
|
// Set every requested param.
|
794
|
params = Object.keys(update.setParams)
|
795
|
.reduce(function (params, param) { return params.set(param, /** @type {?} */ ((update.setParams))[param]); }, params);
|
796
|
}
|
797
|
// Finally, construct the new HttpRequest using the pieces from above.
|
798
|
return new HttpRequest(method, url, body, {
|
799
|
params: params, headers: headers, reportProgress: reportProgress, responseType: responseType, withCredentials: withCredentials,
|
800
|
});
|
801
|
};
|
802
|
return HttpRequest;
|
803
|
}());
|
804
|
/**
|
805
|
* @license
|
806
|
* Copyright Google Inc. All Rights Reserved.
|
807
|
*
|
808
|
* Use of this source code is governed by an MIT-style license that can be
|
809
|
* found in the LICENSE file at https://angular.io/license
|
810
|
*/
|
811
|
var HttpEventType = {};
|
812
|
HttpEventType.Sent = 0;
|
813
|
HttpEventType.UploadProgress = 1;
|
814
|
HttpEventType.ResponseHeader = 2;
|
815
|
HttpEventType.DownloadProgress = 3;
|
816
|
HttpEventType.Response = 4;
|
817
|
HttpEventType.User = 5;
|
818
|
HttpEventType[HttpEventType.Sent] = "Sent";
|
819
|
HttpEventType[HttpEventType.UploadProgress] = "UploadProgress";
|
820
|
HttpEventType[HttpEventType.ResponseHeader] = "ResponseHeader";
|
821
|
HttpEventType[HttpEventType.DownloadProgress] = "DownloadProgress";
|
822
|
HttpEventType[HttpEventType.Response] = "Response";
|
823
|
HttpEventType[HttpEventType.User] = "User";
|
824
|
/**
|
825
|
* Base class for both `HttpResponse` and `HttpHeaderResponse`.
|
826
|
*
|
827
|
* \@experimental
|
828
|
* @abstract
|
829
|
*/
|
830
|
var HttpResponseBase = (function () {
|
831
|
/**
|
832
|
* Super-constructor for all responses.
|
833
|
*
|
834
|
* The single parameter accepted is an initialization hash. Any properties
|
835
|
* of the response passed there will override the default values.
|
836
|
* @param {?} init
|
837
|
* @param {?=} defaultStatus
|
838
|
* @param {?=} defaultStatusText
|
839
|
*/
|
840
|
function HttpResponseBase(init, defaultStatus, defaultStatusText) {
|
841
|
if (defaultStatus === void 0) { defaultStatus = 200; }
|
842
|
if (defaultStatusText === void 0) { defaultStatusText = 'OK'; }
|
843
|
// If the hash has values passed, use them to initialize the response.
|
844
|
// Otherwise use the default values.
|
845
|
this.headers = init.headers || new HttpHeaders();
|
846
|
this.status = init.status !== undefined ? init.status : defaultStatus;
|
847
|
this.statusText = init.statusText || defaultStatusText;
|
848
|
this.url = init.url || null;
|
849
|
// Cache the ok value to avoid defining a getter.
|
850
|
this.ok = this.status >= 200 && this.status < 300;
|
851
|
}
|
852
|
return HttpResponseBase;
|
853
|
}());
|
854
|
/**
|
855
|
* A partial HTTP response which only includes the status and header data,
|
856
|
* but no response body.
|
857
|
*
|
858
|
* `HttpHeaderResponse` is a `HttpEvent` available on the response
|
859
|
* event stream, only when progress events are requested.
|
860
|
*
|
861
|
* \@experimental
|
862
|
*/
|
863
|
var HttpHeaderResponse = (function (_super) {
|
864
|
tslib_1.__extends(HttpHeaderResponse, _super);
|
865
|
/**
|
866
|
* Create a new `HttpHeaderResponse` with the given parameters.
|
867
|
* @param {?=} init
|
868
|
*/
|
869
|
function HttpHeaderResponse(init) {
|
870
|
if (init === void 0) { init = {}; }
|
871
|
var _this = _super.call(this, init) || this;
|
872
|
_this.type = HttpEventType.ResponseHeader;
|
873
|
return _this;
|
874
|
}
|
875
|
/**
|
876
|
* Copy this `HttpHeaderResponse`, overriding its contents with the
|
877
|
* given parameter hash.
|
878
|
* @param {?=} update
|
879
|
* @return {?}
|
880
|
*/
|
881
|
HttpHeaderResponse.prototype.clone = function (update) {
|
882
|
if (update === void 0) { update = {}; }
|
883
|
// Perform a straightforward initialization of the new HttpHeaderResponse,
|
884
|
// overriding the current parameters with new ones if given.
|
885
|
return new HttpHeaderResponse({
|
886
|
headers: update.headers || this.headers,
|
887
|
status: update.status !== undefined ? update.status : this.status,
|
888
|
statusText: update.statusText || this.statusText,
|
889
|
url: update.url || this.url || undefined,
|
890
|
});
|
891
|
};
|
892
|
return HttpHeaderResponse;
|
893
|
}(HttpResponseBase));
|
894
|
/**
|
895
|
* A full HTTP response, including a typed response body (which may be `null`
|
896
|
* if one was not returned).
|
897
|
*
|
898
|
* `HttpResponse` is a `HttpEvent` available on the response event
|
899
|
* stream.
|
900
|
*
|
901
|
* \@experimental
|
902
|
*/
|
903
|
var HttpResponse = (function (_super) {
|
904
|
tslib_1.__extends(HttpResponse, _super);
|
905
|
/**
|
906
|
* Construct a new `HttpResponse`.
|
907
|
* @param {?=} init
|
908
|
*/
|
909
|
function HttpResponse(init) {
|
910
|
if (init === void 0) { init = {}; }
|
911
|
var _this = _super.call(this, init) || this;
|
912
|
_this.type = HttpEventType.Response;
|
913
|
_this.body = init.body || null;
|
914
|
return _this;
|
915
|
}
|
916
|
/**
|
917
|
* @param {?=} update
|
918
|
* @return {?}
|
919
|
*/
|
920
|
HttpResponse.prototype.clone = function (update) {
|
921
|
if (update === void 0) { update = {}; }
|
922
|
return new HttpResponse({
|
923
|
body: (update.body !== undefined) ? update.body : this.body,
|
924
|
headers: update.headers || this.headers,
|
925
|
status: (update.status !== undefined) ? update.status : this.status,
|
926
|
statusText: update.statusText || this.statusText,
|
927
|
url: update.url || this.url || undefined,
|
928
|
});
|
929
|
};
|
930
|
return HttpResponse;
|
931
|
}(HttpResponseBase));
|
932
|
/**
|
933
|
* A response that represents an error or failure, either from a
|
934
|
* non-successful HTTP status, an error while executing the request,
|
935
|
* or some other failure which occurred during the parsing of the response.
|
936
|
*
|
937
|
* Any error returned on the `Observable` response stream will be
|
938
|
* wrapped in an `HttpErrorResponse` to provide additional context about
|
939
|
* the state of the HTTP layer when the error occurred. The error property
|
940
|
* will contain either a wrapped Error object or the error response returned
|
941
|
* from the server.
|
942
|
*
|
943
|
* \@experimental
|
944
|
*/
|
945
|
var HttpErrorResponse = (function (_super) {
|
946
|
tslib_1.__extends(HttpErrorResponse, _super);
|
947
|
/**
|
948
|
* @param {?} init
|
949
|
*/
|
950
|
function HttpErrorResponse(init) {
|
951
|
var _this =
|
952
|
// Initialize with a default status of 0 / Unknown Error.
|
953
|
_super.call(this, init, 0, 'Unknown Error') || this;
|
954
|
_this.name = 'HttpErrorResponse';
|
955
|
/**
|
956
|
* Errors are never okay, even when the status code is in the 2xx success range.
|
957
|
*/
|
958
|
_this.ok = false;
|
959
|
// If the response was successful, then this was a parse error. Otherwise, it was
|
960
|
// a protocol-level failure of some sort. Either the request failed in transit
|
961
|
// or the server returned an unsuccessful status code.
|
962
|
if (_this.status >= 200 && _this.status < 300) {
|
963
|
_this.message = "Http failure during parsing for " + (init.url || '(unknown url)');
|
964
|
}
|
965
|
else {
|
966
|
_this.message =
|
967
|
"Http failure response for " + (init.url || '(unknown url)') + ": " + init.status + " " + init.statusText;
|
968
|
}
|
969
|
_this.error = init.error || null;
|
970
|
return _this;
|
971
|
}
|
972
|
return HttpErrorResponse;
|
973
|
}(HttpResponseBase));
|
974
|
/**
|
975
|
* @license
|
976
|
* Copyright Google Inc. All Rights Reserved.
|
977
|
*
|
978
|
* Use of this source code is governed by an MIT-style license that can be
|
979
|
* found in the LICENSE file at https://angular.io/license
|
980
|
*/
|
981
|
/**
|
982
|
* Construct an instance of `HttpRequestOptions<T>` from a source `HttpMethodOptions` and
|
983
|
* the given `body`. Basically, this clones the object and adds the body.
|
984
|
* @template T
|
985
|
* @param {?} options
|
986
|
* @param {?} body
|
987
|
* @return {?}
|
988
|
*/
|
989
|
function addBody(options, body) {
|
990
|
return {
|
991
|
body: body,
|
992
|
headers: options.headers,
|
993
|
observe: options.observe,
|
994
|
params: options.params,
|
995
|
reportProgress: options.reportProgress,
|
996
|
responseType: options.responseType,
|
997
|
withCredentials: options.withCredentials,
|
998
|
};
|
999
|
}
|
1000
|
/**
|
1001
|
* Perform HTTP requests.
|
1002
|
*
|
1003
|
* `HttpClient` is available as an injectable class, with methods to perform HTTP requests.
|
1004
|
* Each request method has multiple signatures, and the return type varies according to which
|
1005
|
* signature is called (mainly the values of `observe` and `responseType`).
|
1006
|
*
|
1007
|
* \@experimental
|
1008
|
*/
|
1009
|
var HttpClient = (function () {
|
1010
|
/**
|
1011
|
* @param {?} handler
|
1012
|
*/
|
1013
|
function HttpClient(handler) {
|
1014
|
this.handler = handler;
|
1015
|
}
|
1016
|
/**
|
1017
|
* Constructs an `Observable` for a particular HTTP request that, when subscribed,
|
1018
|
* fires the request through the chain of registered interceptors and on to the
|
1019
|
* server.
|
1020
|
*
|
1021
|
* This method can be called in one of two ways. Either an `HttpRequest`
|
1022
|
* instance can be passed directly as the only parameter, or a method can be
|
1023
|
* passed as the first parameter, a string URL as the second, and an
|
1024
|
* options hash as the third.
|
1025
|
*
|
1026
|
* If a `HttpRequest` object is passed directly, an `Observable` of the
|
1027
|
* raw `HttpEvent` stream will be returned.
|
1028
|
*
|
1029
|
* If a request is instead built by providing a URL, the options object
|
1030
|
* determines the return type of `request()`. In addition to configuring
|
1031
|
* request parameters such as the outgoing headers and/or the body, the options
|
1032
|
* hash specifies two key pieces of information about the request: the
|
1033
|
* `responseType` and what to `observe`.
|
1034
|
*
|
1035
|
* The `responseType` value determines how a successful response body will be
|
1036
|
* parsed. If `responseType` is the default `json`, a type interface for the
|
1037
|
* resulting object may be passed as a type parameter to `request()`.
|
1038
|
*
|
1039
|
* The `observe` value determines the return type of `request()`, based on what
|
1040
|
* the consumer is interested in observing. A value of `events` will return an
|
1041
|
* `Observable<HttpEvent>` representing the raw `HttpEvent` stream,
|
1042
|
* including progress events by default. A value of `response` will return an
|
1043
|
* `Observable<HttpResponse<T>>` where the `T` parameter of `HttpResponse`
|
1044
|
* depends on the `responseType` and any optionally provided type parameter.
|
1045
|
* A value of `body` will return an `Observable<T>` with the same `T` body type.
|
1046
|
* @param {?} first
|
1047
|
* @param {?=} url
|
1048
|
* @param {?=} options
|
1049
|
* @return {?}
|
1050
|
*/
|
1051
|
HttpClient.prototype.request = function (first, url, options) {
|
1052
|
var _this = this;
|
1053
|
if (options === void 0) { options = {}; }
|
1054
|
var /** @type {?} */ req;
|
1055
|
// Firstly, check whether the primary argument is an instance of `HttpRequest`.
|
1056
|
if (first instanceof HttpRequest) {
|
1057
|
// It is. The other arguments must be undefined (per the signatures) and can be
|
1058
|
// ignored.
|
1059
|
req = (first);
|
1060
|
}
|
1061
|
else {
|
1062
|
// It's a string, so it represents a URL. Construct a request based on it,
|
1063
|
// and incorporate the remaining arguments (assuming GET unless a method is
|
1064
|
// provided.
|
1065
|
req = new HttpRequest(first, /** @type {?} */ ((url)), options.body || null, {
|
1066
|
headers: options.headers,
|
1067
|
params: options.params,
|
1068
|
reportProgress: options.reportProgress,
|
1069
|
// By default, JSON is assumed to be returned for all calls.
|
1070
|
responseType: options.responseType || 'json',
|
1071
|
withCredentials: options.withCredentials,
|
1072
|
});
|
1073
|
}
|
1074
|
// Start with an Observable.of() the initial request, and run the handler (which
|
1075
|
// includes all interceptors) inside a concatMap(). This way, the handler runs
|
1076
|
// inside an Observable chain, which causes interceptors to be re-run on every
|
1077
|
// subscription (this also makes retries re-run the handler, including interceptors).
|
1078
|
var /** @type {?} */ events$ = rxjs_operator_concatMap.concatMap.call(rxjs_observable_of.of(req), function (req) { return _this.handler.handle(req); });
|
1079
|
// If coming via the API signature which accepts a previously constructed HttpRequest,
|
1080
|
// the only option is to get the event stream. Otherwise, return the event stream if
|
1081
|
// that is what was requested.
|
1082
|
if (first instanceof HttpRequest || options.observe === 'events') {
|
1083
|
return events$;
|
1084
|
}
|
1085
|
// The requested stream contains either the full response or the body. In either
|
1086
|
// case, the first step is to filter the event stream to extract a stream of
|
1087
|
// responses(s).
|
1088
|
var /** @type {?} */ res$ = rxjs_operator_filter.filter.call(events$, function (event) { return event instanceof HttpResponse; });
|
1089
|
// Decide which stream to return.
|
1090
|
switch (options.observe || 'body') {
|
1091
|
case 'body':
|
1092
|
// The requested stream is the body. Map the response stream to the response
|
1093
|
// body. This could be done more simply, but a misbehaving interceptor might
|
1094
|
// transform the response body into a different format and ignore the requested
|
1095
|
// responseType. Guard against this by validating that the response is of the
|
1096
|
// requested type.
|
1097
|
switch (req.responseType) {
|
1098
|
case 'arraybuffer':
|
1099
|
return rxjs_operator_map.map.call(res$, function (res) {
|
1100
|
// Validate that the body is an ArrayBuffer.
|
1101
|
if (res.body !== null && !(res.body instanceof ArrayBuffer)) {
|
1102
|
throw new Error('Response is not an ArrayBuffer.');
|
1103
|
}
|
1104
|
return res.body;
|
1105
|
});
|
1106
|
case 'blob':
|
1107
|
return rxjs_operator_map.map.call(res$, function (res) {
|
1108
|
// Validate that the body is a Blob.
|
1109
|
if (res.body !== null && !(res.body instanceof Blob)) {
|
1110
|
throw new Error('Response is not a Blob.');
|
1111
|
}
|
1112
|
return res.body;
|
1113
|
});
|
1114
|
case 'text':
|
1115
|
return rxjs_operator_map.map.call(res$, function (res) {
|
1116
|
// Validate that the body is a string.
|
1117
|
if (res.body !== null && typeof res.body !== 'string') {
|
1118
|
throw new Error('Response is not a string.');
|
1119
|
}
|
1120
|
return res.body;
|
1121
|
});
|
1122
|
case 'json':
|
1123
|
default:
|
1124
|
// No validation needed for JSON responses, as they can be of any type.
|
1125
|
return rxjs_operator_map.map.call(res$, function (res) { return res.body; });
|
1126
|
}
|
1127
|
case 'response':
|
1128
|
// The response stream was requested directly, so return it.
|
1129
|
return res$;
|
1130
|
default:
|
1131
|
// Guard against new future observe types being added.
|
1132
|
throw new Error("Unreachable: unhandled observe type " + options.observe + "}");
|
1133
|
}
|
1134
|
};
|
1135
|
/**
|
1136
|
* Constructs an `Observable` which, when subscribed, will cause the configured
|
1137
|
* DELETE request to be executed on the server. See the individual overloads for
|
1138
|
* details of `delete()`'s return type based on the provided options.
|
1139
|
* @param {?} url
|
1140
|
* @param {?=} options
|
1141
|
* @return {?}
|
1142
|
*/
|
1143
|
HttpClient.prototype.delete = function (url, options) {
|
1144
|
if (options === void 0) { options = {}; }
|
1145
|
return this.request('DELETE', url, /** @type {?} */ (options));
|
1146
|
};
|
1147
|
/**
|
1148
|
* Constructs an `Observable` which, when subscribed, will cause the configured
|
1149
|
* GET request to be executed on the server. See the individual overloads for
|
1150
|
* details of `get()`'s return type based on the provided options.
|
1151
|
* @param {?} url
|
1152
|
* @param {?=} options
|
1153
|
* @return {?}
|
1154
|
*/
|
1155
|
HttpClient.prototype.get = function (url, options) {
|
1156
|
if (options === void 0) { options = {}; }
|
1157
|
return this.request('GET', url, /** @type {?} */ (options));
|
1158
|
};
|
1159
|
/**
|
1160
|
* Constructs an `Observable` which, when subscribed, will cause the configured
|
1161
|
* HEAD request to be executed on the server. See the individual overloads for
|
1162
|
* details of `head()`'s return type based on the provided options.
|
1163
|
* @param {?} url
|
1164
|
* @param {?=} options
|
1165
|
* @return {?}
|
1166
|
*/
|
1167
|
HttpClient.prototype.head = function (url, options) {
|
1168
|
if (options === void 0) { options = {}; }
|
1169
|
return this.request('HEAD', url, /** @type {?} */ (options));
|
1170
|
};
|
1171
|
/**
|
1172
|
* Constructs an `Observable` which, when subscribed, will cause a request
|
1173
|
* with the special method `JSONP` to be dispatched via the interceptor pipeline.
|
1174
|
*
|
1175
|
* A suitable interceptor must be installed (e.g. via the `HttpClientJsonpModule`).
|
1176
|
* If no such interceptor is reached, then the `JSONP` request will likely be
|
1177
|
* rejected by the configured backend.
|
1178
|
* @template T
|
1179
|
* @param {?} url
|
1180
|
* @param {?} callbackParam
|
1181
|
* @return {?}
|
1182
|
*/
|
1183
|
HttpClient.prototype.jsonp = function (url, callbackParam) {
|
1184
|
return this.request('JSONP', url, {
|
1185
|
params: new HttpParams().append(callbackParam, 'JSONP_CALLBACK'),
|
1186
|
observe: 'body',
|
1187
|
responseType: 'json',
|
1188
|
});
|
1189
|
};
|
1190
|
/**
|
1191
|
* Constructs an `Observable` which, when subscribed, will cause the configured
|
1192
|
* OPTIONS request to be executed on the server. See the individual overloads for
|
1193
|
* details of `options()`'s return type based on the provided options.
|
1194
|
* @param {?} url
|
1195
|
* @param {?=} options
|
1196
|
* @return {?}
|
1197
|
*/
|
1198
|
HttpClient.prototype.options = function (url, options) {
|
1199
|
if (options === void 0) { options = {}; }
|
1200
|
return this.request('OPTIONS', url, /** @type {?} */ (options));
|
1201
|
};
|
1202
|
/**
|
1203
|
* Constructs an `Observable` which, when subscribed, will cause the configured
|
1204
|
* PATCH request to be executed on the server. See the individual overloads for
|
1205
|
* details of `patch()`'s return type based on the provided options.
|
1206
|
* @param {?} url
|
1207
|
* @param {?} body
|
1208
|
* @param {?=} options
|
1209
|
* @return {?}
|
1210
|
*/
|
1211
|
HttpClient.prototype.patch = function (url, body, options) {
|
1212
|
if (options === void 0) { options = {}; }
|
1213
|
return this.request('PATCH', url, addBody(options, body));
|
1214
|
};
|
1215
|
/**
|
1216
|
* Constructs an `Observable` which, when subscribed, will cause the configured
|
1217
|
* POST request to be executed on the server. See the individual overloads for
|
1218
|
* details of `post()`'s return type based on the provided options.
|
1219
|
* @param {?} url
|
1220
|
* @param {?} body
|
1221
|
* @param {?=} options
|
1222
|
* @return {?}
|
1223
|
*/
|
1224
|
HttpClient.prototype.post = function (url, body, options) {
|
1225
|
if (options === void 0) { options = {}; }
|
1226
|
return this.request('POST', url, addBody(options, body));
|
1227
|
};
|
1228
|
/**
|
1229
|
* Constructs an `Observable` which, when subscribed, will cause the configured
|
1230
|
* POST request to be executed on the server. See the individual overloads for
|
1231
|
* details of `post()`'s return type based on the provided options.
|
1232
|
* @param {?} url
|
1233
|
* @param {?} body
|
1234
|
* @param {?=} options
|
1235
|
* @return {?}
|
1236
|
*/
|
1237
|
HttpClient.prototype.put = function (url, body, options) {
|
1238
|
if (options === void 0) { options = {}; }
|
1239
|
return this.request('PUT', url, addBody(options, body));
|
1240
|
};
|
1241
|
return HttpClient;
|
1242
|
}());
|
1243
|
HttpClient.decorators = [
|
1244
|
{ type: _angular_core.Injectable },
|
1245
|
];
|
1246
|
/**
|
1247
|
* @nocollapse
|
1248
|
*/
|
1249
|
HttpClient.ctorParameters = function () { return [
|
1250
|
{ type: HttpHandler, },
|
1251
|
]; };
|
1252
|
/**
|
1253
|
* @license
|
1254
|
* Copyright Google Inc. All Rights Reserved.
|
1255
|
*
|
1256
|
* Use of this source code is governed by an MIT-style license that can be
|
1257
|
* found in the LICENSE file at https://angular.io/license
|
1258
|
*/
|
1259
|
/**
|
1260
|
* `HttpHandler` which applies an `HttpInterceptor` to an `HttpRequest`.
|
1261
|
*
|
1262
|
* \@experimental
|
1263
|
*/
|
1264
|
var HttpInterceptorHandler = (function () {
|
1265
|
/**
|
1266
|
* @param {?} next
|
1267
|
* @param {?} interceptor
|
1268
|
*/
|
1269
|
function HttpInterceptorHandler(next, interceptor) {
|
1270
|
this.next = next;
|
1271
|
this.interceptor = interceptor;
|
1272
|
}
|
1273
|
/**
|
1274
|
* @param {?} req
|
1275
|
* @return {?}
|
1276
|
*/
|
1277
|
HttpInterceptorHandler.prototype.handle = function (req) {
|
1278
|
return this.interceptor.intercept(req, this.next);
|
1279
|
};
|
1280
|
return HttpInterceptorHandler;
|
1281
|
}());
|
1282
|
/**
|
1283
|
* A multi-provider token which represents the array of `HttpInterceptor`s that
|
1284
|
* are registered.
|
1285
|
*
|
1286
|
* \@experimental
|
1287
|
*/
|
1288
|
var HTTP_INTERCEPTORS = new _angular_core.InjectionToken('HTTP_INTERCEPTORS');
|
1289
|
var NoopInterceptor = (function () {
|
1290
|
function NoopInterceptor() {
|
1291
|
}
|
1292
|
/**
|
1293
|
* @param {?} req
|
1294
|
* @param {?} next
|
1295
|
* @return {?}
|
1296
|
*/
|
1297
|
NoopInterceptor.prototype.intercept = function (req, next) {
|
1298
|
return next.handle(req);
|
1299
|
};
|
1300
|
return NoopInterceptor;
|
1301
|
}());
|
1302
|
NoopInterceptor.decorators = [
|
1303
|
{ type: _angular_core.Injectable },
|
1304
|
];
|
1305
|
/**
|
1306
|
* @nocollapse
|
1307
|
*/
|
1308
|
NoopInterceptor.ctorParameters = function () { return []; };
|
1309
|
/**
|
1310
|
* @license
|
1311
|
* Copyright Google Inc. All Rights Reserved.
|
1312
|
*
|
1313
|
* Use of this source code is governed by an MIT-style license that can be
|
1314
|
* found in the LICENSE file at https://angular.io/license
|
1315
|
*/
|
1316
|
// Every request made through JSONP needs a callback name that's unique across the
|
1317
|
// whole page. Each request is assigned an id and the callback name is constructed
|
1318
|
// from that. The next id to be assigned is tracked in a global variable here that
|
1319
|
// is shared among all applications on the page.
|
1320
|
var nextRequestId = 0;
|
1321
|
// Error text given when a JSONP script is injected, but doesn't invoke the callback
|
1322
|
// passed in its URL.
|
1323
|
var JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
|
1324
|
// Error text given when a request is passed to the JsonpClientBackend that doesn't
|
1325
|
// have a request method JSONP.
|
1326
|
var JSONP_ERR_WRONG_METHOD = 'JSONP requests must use JSONP request method.';
|
1327
|
var JSONP_ERR_WRONG_RESPONSE_TYPE = 'JSONP requests must use Json response type.';
|
1328
|
/**
|
1329
|
* DI token/abstract type representing a map of JSONP callbacks.
|
1330
|
*
|
1331
|
* In the browser, this should always be the `window` object.
|
1332
|
*
|
1333
|
* \@experimental
|
1334
|
* @abstract
|
1335
|
*/
|
1336
|
var JsonpCallbackContext = (function () {
|
1337
|
function JsonpCallbackContext() {
|
1338
|
}
|
1339
|
return JsonpCallbackContext;
|
1340
|
}());
|
1341
|
/**
|
1342
|
* `HttpBackend` that only processes `HttpRequest` with the JSONP method,
|
1343
|
* by performing JSONP style requests.
|
1344
|
*
|
1345
|
* \@experimental
|
1346
|
*/
|
1347
|
var JsonpClientBackend = (function () {
|
1348
|
/**
|
1349
|
* @param {?} callbackMap
|
1350
|
* @param {?} document
|
1351
|
*/
|
1352
|
function JsonpClientBackend(callbackMap, document) {
|
1353
|
this.callbackMap = callbackMap;
|
1354
|
this.document = document;
|
1355
|
}
|
1356
|
/**
|
1357
|
* Get the name of the next callback method, by incrementing the global `nextRequestId`.
|
1358
|
* @return {?}
|
1359
|
*/
|
1360
|
JsonpClientBackend.prototype.nextCallback = function () { return "ng_jsonp_callback_" + nextRequestId++; };
|
1361
|
/**
|
1362
|
* Process a JSONP request and return an event stream of the results.
|
1363
|
* @param {?} req
|
1364
|
* @return {?}
|
1365
|
*/
|
1366
|
JsonpClientBackend.prototype.handle = function (req) {
|
1367
|
var _this = this;
|
1368
|
// Firstly, check both the method and response type. If either doesn't match
|
1369
|
// then the request was improperly routed here and cannot be handled.
|
1370
|
if (req.method !== 'JSONP') {
|
1371
|
throw new Error(JSONP_ERR_WRONG_METHOD);
|
1372
|
}
|
1373
|
else if (req.responseType !== 'json') {
|
1374
|
throw new Error(JSONP_ERR_WRONG_RESPONSE_TYPE);
|
1375
|
}
|
1376
|
// Everything else happens inside the Observable boundary.
|
1377
|
return new rxjs_Observable.Observable(function (observer) {
|
1378
|
// The first step to make a request is to generate the callback name, and replace the
|
1379
|
// callback placeholder in the URL with the name. Care has to be taken here to ensure
|
1380
|
// a trailing &, if matched, gets inserted back into the URL in the correct place.
|
1381
|
var /** @type {?} */ callback = _this.nextCallback();
|
1382
|
var /** @type {?} */ url = req.urlWithParams.replace(/=JSONP_CALLBACK(&|$)/, "=" + callback + "$1");
|
1383
|
// Construct the <script> tag and point it at the URL.
|
1384
|
var /** @type {?} */ node = _this.document.createElement('script');
|
1385
|
node.src = url;
|
1386
|
// A JSONP request requires waiting for multiple callbacks. These variables
|
1387
|
// are closed over and track state across those callbacks.
|
1388
|
// The response object, if one has been received, or null otherwise.
|
1389
|
var /** @type {?} */ body = null;
|
1390
|
// Whether the response callback has been called.
|
1391
|
var /** @type {?} */ finished = false;
|
1392
|
// Whether the request has been cancelled (and thus any other callbacks)
|
1393
|
// should be ignored.
|
1394
|
var /** @type {?} */ cancelled = false;
|
1395
|
// Set the response callback in this.callbackMap (which will be the window
|
1396
|
// object in the browser. The script being loaded via the <script> tag will
|
1397
|
// eventually call this callback.
|
1398
|
_this.callbackMap[callback] = function (data) {
|
1399
|
// Data has been received from the JSONP script. Firstly, delete this callback.
|
1400
|
delete _this.callbackMap[callback];
|
1401
|
// Next, make sure the request wasn't cancelled in the meantime.
|
1402
|
if (cancelled) {
|
1403
|
return;
|
1404
|
}
|
1405
|
// Set state to indicate data was received.
|
1406
|
body = data;
|
1407
|
finished = true;
|
1408
|
};
|
1409
|
// cleanup() is a utility closure that removes the <script> from the page and
|
1410
|
// the response callback from the window. This logic is used in both the
|
1411
|
// success, error, and cancellation paths, so it's extracted out for convenience.
|
1412
|
var /** @type {?} */ cleanup = function () {
|
1413
|
// Remove the <script> tag if it's still on the page.
|
1414
|
if (node.parentNode) {
|
1415
|
node.parentNode.removeChild(node);
|
1416
|
}
|
1417
|
// Remove the response callback from the callbackMap (window object in the
|
1418
|
// browser).
|
1419
|
delete _this.callbackMap[callback];
|
1420
|
};
|
1421
|
// onLoad() is the success callback which runs after the response callback
|
1422
|
// if the JSONP script loads successfully. The event itself is unimportant.
|
1423
|
// If something went wrong, onLoad() may run without the response callback
|
1424
|
// having been invoked.
|
1425
|
var /** @type {?} */ onLoad = function (event) {
|
1426
|
// Do nothing if the request has been cancelled.
|
1427
|
if (cancelled) {
|
1428
|
return;
|
1429
|
}
|
1430
|
// Cleanup the page.
|
1431
|
cleanup();
|
1432
|
// Check whether the response callback has run.
|
1433
|
if (!finished) {
|
1434
|
// It hasn't, something went wrong with the request. Return an error via
|
1435
|
// the Observable error path. All JSONP errors have status 0.
|
1436
|
observer.error(new HttpErrorResponse({
|
1437
|
url: url,
|
1438
|
status: 0,
|
1439
|
statusText: 'JSONP Error',
|
1440
|
error: new Error(JSONP_ERR_NO_CALLBACK),
|
1441
|
}));
|
1442
|
return;
|
1443
|
}
|
1444
|
// Success. body either contains the response body or null if none was
|
1445
|
// returned.
|
1446
|
observer.next(new HttpResponse({
|
1447
|
body: body,
|
1448
|
status: 200,
|
1449
|
statusText: 'OK', url: url,
|
1450
|
}));
|
1451
|
// Complete the stream, the resposne is over.
|
1452
|
observer.complete();
|
1453
|
};
|
1454
|
// onError() is the error callback, which runs if the script returned generates
|
1455
|
// a Javascript error. It emits the error via the Observable error channel as
|
1456
|
// a HttpErrorResponse.
|
1457
|
var /** @type {?} */ onError = function (error) {
|
1458
|
// If the request was already cancelled, no need to emit anything.
|
1459
|
if (cancelled) {
|
1460
|
return;
|
1461
|
}
|
1462
|
cleanup();
|
1463
|
// Wrap the error in a HttpErrorResponse.
|
1464
|
observer.error(new HttpErrorResponse({
|
1465
|
error: error,
|
1466
|
status: 0,
|
1467
|
statusText: 'JSONP Error', url: url,
|
1468
|
}));
|
1469
|
};
|
1470
|
// Subscribe to both the success (load) and error events on the <script> tag,
|
1471
|
// and add it to the page.
|
1472
|
node.addEventListener('load', onLoad);
|
1473
|
node.addEventListener('error', onError);
|
1474
|
_this.document.body.appendChild(node);
|
1475
|
// The request has now been successfully sent.
|
1476
|
observer.next({ type: HttpEventType.Sent });
|
1477
|
// Cancellation handler.
|
1478
|
return function () {
|
1479
|
// Track the cancellation so event listeners won't do anything even if already scheduled.
|
1480
|
cancelled = true;
|
1481
|
// Remove the event listeners so they won't run if the events later fire.
|
1482
|
node.removeEventListener('load', onLoad);
|
1483
|
node.removeEventListener('error', onError);
|
1484
|
// And finally, clean up the page.
|
1485
|
cleanup();
|
1486
|
};
|
1487
|
});
|
1488
|
};
|
1489
|
return JsonpClientBackend;
|
1490
|
}());
|
1491
|
JsonpClientBackend.decorators = [
|
1492
|
{ type: _angular_core.Injectable },
|
1493
|
];
|
1494
|
/**
|
1495
|
* @nocollapse
|
1496
|
*/
|
1497
|
JsonpClientBackend.ctorParameters = function () { return [
|
1498
|
{ type: JsonpCallbackContext, },
|
1499
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_common.DOCUMENT,] },] },
|
1500
|
]; };
|
1501
|
/**
|
1502
|
* An `HttpInterceptor` which identifies requests with the method JSONP and
|
1503
|
* shifts them to the `JsonpClientBackend`.
|
1504
|
*
|
1505
|
* \@experimental
|
1506
|
*/
|
1507
|
var JsonpInterceptor = (function () {
|
1508
|
/**
|
1509
|
* @param {?} jsonp
|
1510
|
*/
|
1511
|
function JsonpInterceptor(jsonp) {
|
1512
|
this.jsonp = jsonp;
|
1513
|
}
|
1514
|
/**
|
1515
|
* @param {?} req
|
1516
|
* @param {?} next
|
1517
|
* @return {?}
|
1518
|
*/
|
1519
|
JsonpInterceptor.prototype.intercept = function (req, next) {
|
1520
|
if (req.method === 'JSONP') {
|
1521
|
return this.jsonp.handle(/** @type {?} */ (req));
|
1522
|
}
|
1523
|
// Fall through for normal HTTP requests.
|
1524
|
return next.handle(req);
|
1525
|
};
|
1526
|
return JsonpInterceptor;
|
1527
|
}());
|
1528
|
JsonpInterceptor.decorators = [
|
1529
|
{ type: _angular_core.Injectable },
|
1530
|
];
|
1531
|
/**
|
1532
|
* @nocollapse
|
1533
|
*/
|
1534
|
JsonpInterceptor.ctorParameters = function () { return [
|
1535
|
{ type: JsonpClientBackend, },
|
1536
|
]; };
|
1537
|
/**
|
1538
|
* @license
|
1539
|
* Copyright Google Inc. All Rights Reserved.
|
1540
|
*
|
1541
|
* Use of this source code is governed by an MIT-style license that can be
|
1542
|
* found in the LICENSE file at https://angular.io/license
|
1543
|
*/
|
1544
|
var XSSI_PREFIX = /^\)\]\}',?\n/;
|
1545
|
/**
|
1546
|
* Determine an appropriate URL for the response, by checking either
|
1547
|
* XMLHttpRequest.responseURL or the X-Request-URL header.
|
1548
|
* @param {?} xhr
|
1549
|
* @return {?}
|
1550
|
*/
|
1551
|
function getResponseUrl(xhr) {
|
1552
|
if ('responseURL' in xhr && xhr.responseURL) {
|
1553
|
return xhr.responseURL;
|
1554
|
}
|
1555
|
if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
|
1556
|
return xhr.getResponseHeader('X-Request-URL');
|
1557
|
}
|
1558
|
return null;
|
1559
|
}
|
1560
|
/**
|
1561
|
* A wrapper around the `XMLHttpRequest` constructor.
|
1562
|
*
|
1563
|
* \@experimental
|
1564
|
* @abstract
|
1565
|
*/
|
1566
|
var XhrFactory = (function () {
|
1567
|
function XhrFactory() {
|
1568
|
}
|
1569
|
/**
|
1570
|
* @abstract
|
1571
|
* @return {?}
|
1572
|
*/
|
1573
|
XhrFactory.prototype.build = function () { };
|
1574
|
return XhrFactory;
|
1575
|
}());
|
1576
|
/**
|
1577
|
* A factory for \@{link HttpXhrBackend} that uses the `XMLHttpRequest` browser API.
|
1578
|
*
|
1579
|
* \@experimental
|
1580
|
*/
|
1581
|
var BrowserXhr = (function () {
|
1582
|
function BrowserXhr() {
|
1583
|
}
|
1584
|
/**
|
1585
|
* @return {?}
|
1586
|
*/
|
1587
|
BrowserXhr.prototype.build = function () { return ((new XMLHttpRequest())); };
|
1588
|
return BrowserXhr;
|
1589
|
}());
|
1590
|
BrowserXhr.decorators = [
|
1591
|
{ type: _angular_core.Injectable },
|
1592
|
];
|
1593
|
/**
|
1594
|
* @nocollapse
|
1595
|
*/
|
1596
|
BrowserXhr.ctorParameters = function () { return []; };
|
1597
|
/**
|
1598
|
* An `HttpBackend` which uses the XMLHttpRequest API to send
|
1599
|
* requests to a backend server.
|
1600
|
*
|
1601
|
* \@experimental
|
1602
|
*/
|
1603
|
var HttpXhrBackend = (function () {
|
1604
|
/**
|
1605
|
* @param {?} xhrFactory
|
1606
|
*/
|
1607
|
function HttpXhrBackend(xhrFactory) {
|
1608
|
this.xhrFactory = xhrFactory;
|
1609
|
}
|
1610
|
/**
|
1611
|
* Process a request and return a stream of response events.
|
1612
|
* @param {?} req
|
1613
|
* @return {?}
|
1614
|
*/
|
1615
|
HttpXhrBackend.prototype.handle = function (req) {
|
1616
|
var _this = this;
|
1617
|
// Quick check to give a better error message when a user attempts to use
|
1618
|
// HttpClient.jsonp() without installing the JsonpClientModule
|
1619
|
if (req.method === 'JSONP') {
|
1620
|
throw new Error("Attempted to construct Jsonp request without JsonpClientModule installed.");
|
1621
|
}
|
1622
|
// Everything happens on Observable subscription.
|
1623
|
return new rxjs_Observable.Observable(function (observer) {
|
1624
|
// Start by setting up the XHR object with request method, URL, and withCredentials flag.
|
1625
|
var /** @type {?} */ xhr = _this.xhrFactory.build();
|
1626
|
xhr.open(req.method, req.urlWithParams);
|
1627
|
if (!!req.withCredentials) {
|
1628
|
xhr.withCredentials = true;
|
1629
|
}
|
1630
|
// Add all the requested headers.
|
1631
|
req.headers.forEach(function (name, values) { return xhr.setRequestHeader(name, values.join(',')); });
|
1632
|
// Add an Accept header if one isn't present already.
|
1633
|
if (!req.headers.has('Accept')) {
|
1634
|
xhr.setRequestHeader('Accept', 'application/json, text/plain, */*');
|
1635
|
}
|
1636
|
// Auto-detect the Content-Type header if one isn't present already.
|
1637
|
if (!req.headers.has('Content-Type')) {
|
1638
|
var /** @type {?} */ detectedType = req.detectContentTypeHeader();
|
1639
|
// Sometimes Content-Type detection fails.
|
1640
|
if (detectedType !== null) {
|
1641
|
xhr.setRequestHeader('Content-Type', detectedType);
|
1642
|
}
|
1643
|
}
|
1644
|
// Set the responseType if one was requested.
|
1645
|
if (req.responseType) {
|
1646
|
var /** @type {?} */ responseType = req.responseType.toLowerCase();
|
1647
|
// JSON responses need to be processed as text. This is because if the server
|
1648
|
// returns an XSSI-prefixed JSON response, the browser will fail to parse it,
|
1649
|
// xhr.response will be null, and xhr.responseText cannot be accessed to
|
1650
|
// retrieve the prefixed JSON data in order to strip the prefix. Thus, all JSON
|
1651
|
// is parsed by first requesting text and then applying JSON.parse.
|
1652
|
xhr.responseType = (((responseType !== 'json') ? responseType : 'text'));
|
1653
|
}
|
1654
|
// Serialize the request body if one is present. If not, this will be set to null.
|
1655
|
var /** @type {?} */ reqBody = req.serializeBody();
|
1656
|
// If progress events are enabled, response headers will be delivered
|
1657
|
// in two events - the HttpHeaderResponse event and the full HttpResponse
|
1658
|
// event. However, since response headers don't change in between these
|
1659
|
// two events, it doesn't make sense to parse them twice. So headerResponse
|
1660
|
// caches the data extracted from the response whenever it's first parsed,
|
1661
|
// to ensure parsing isn't duplicated.
|
1662
|
var /** @type {?} */ headerResponse = null;
|
1663
|
// partialFromXhr extracts the HttpHeaderResponse from the current XMLHttpRequest
|
1664
|
// state, and memoizes it into headerResponse.
|
1665
|
var /** @type {?} */ partialFromXhr = function () {
|
1666
|
if (headerResponse !== null) {
|
1667
|
return headerResponse;
|
1668
|
}
|
1669
|
// Read status and normalize an IE9 bug (http://bugs.jquery.com/ticket/1450).
|
1670
|
var /** @type {?} */ status = xhr.status === 1223 ? 204 : xhr.status;
|
1671
|
var /** @type {?} */ statusText = xhr.statusText || 'OK';
|
1672
|
// Parse headers from XMLHttpRequest - this step is lazy.
|
1673
|
var /** @type {?} */ headers = new HttpHeaders(xhr.getAllResponseHeaders());
|
1674
|
// Read the response URL from the XMLHttpResponse instance and fall back on the
|
1675
|
// request URL.
|
1676
|
var /** @type {?} */ url = getResponseUrl(xhr) || req.url;
|
1677
|
// Construct the HttpHeaderResponse and memoize it.
|
1678
|
headerResponse = new HttpHeaderResponse({ headers: headers, status: status, statusText: statusText, url: url });
|
1679
|
return headerResponse;
|
1680
|
};
|
1681
|
// Next, a few closures are defined for the various events which XMLHttpRequest can
|
1682
|
// emit. This allows them to be unregistered as event listeners later.
|
1683
|
// First up is the load event, which represents a response being fully available.
|
1684
|
var /** @type {?} */ onLoad = function () {
|
1685
|
// Read response state from the memoized partial data.
|
1686
|
var _a = partialFromXhr(), headers = _a.headers, status = _a.status, statusText = _a.statusText, url = _a.url;
|
1687
|
// The body will be read out if present.
|
1688
|
var /** @type {?} */ body = null;
|
1689
|
if (status !== 204) {
|
1690
|
// Use XMLHttpRequest.response if set, responseText otherwise.
|
1691
|
body = (typeof xhr.response === 'undefined') ? xhr.responseText : xhr.response;
|
1692
|
}
|
1693
|
// Normalize another potential bug (this one comes from CORS).
|
1694
|
if (status === 0) {
|
1695
|
status = !!body ? 200 : 0;
|
1696
|
}
|
1697
|
// ok determines whether the response will be transmitted on the event or
|
1698
|
// error channel. Unsuccessful status codes (not 2xx) will always be errors,
|
1699
|
// but a successful status code can still result in an error if the user
|
1700
|
// asked for JSON data and the body cannot be parsed as such.
|
1701
|
var /** @type {?} */ ok = status >= 200 && status < 300;
|
1702
|
// Check whether the body needs to be parsed as JSON (in many cases the browser
|
1703
|
// will have done that already).
|
1704
|
if (ok && req.responseType === 'json' && typeof body === 'string') {
|
1705
|
// Attempt the parse. If it fails, a parse error should be delivered to the user.
|
1706
|
body = body.replace(XSSI_PREFIX, '');
|
1707
|
try {
|
1708
|
body = JSON.parse(body);
|
1709
|
}
|
1710
|
catch (error) {
|
1711
|
// Even though the response status was 2xx, this is still an error.
|
1712
|
ok = false;
|
1713
|
// The parse error contains the text of the body that failed to parse.
|
1714
|
body = ({ error: error, text: body });
|
1715
|
}
|
1716
|
}
|
1717
|
else if (!ok && req.responseType === 'json' && typeof body === 'string') {
|
1718
|
try {
|
1719
|
// Attempt to parse the body as JSON.
|
1720
|
body = JSON.parse(body);
|
1721
|
}
|
1722
|
catch (error) {
|
1723
|
// Cannot be certain that the body was meant to be parsed as JSON.
|
1724
|
// Leave the body as a string.
|
1725
|
}
|
1726
|
}
|
1727
|
if (ok) {
|
1728
|
// A successful response is delivered on the event stream.
|
1729
|
observer.next(new HttpResponse({
|
1730
|
body: body,
|
1731
|
headers: headers,
|
1732
|
status: status,
|
1733
|
statusText: statusText,
|
1734
|
url: url || undefined,
|
1735
|
}));
|
1736
|
// The full body has been received and delivered, no further events
|
1737
|
// are possible. This request is complete.
|
1738
|
observer.complete();
|
1739
|
}
|
1740
|
else {
|
1741
|
// An unsuccessful request is delivered on the error channel.
|
1742
|
observer.error(new HttpErrorResponse({
|
1743
|
// The error in this case is the response body (error from the server).
|
1744
|
error: body,
|
1745
|
headers: headers,
|
1746
|
status: status,
|
1747
|
statusText: statusText,
|
1748
|
url: url || undefined,
|
1749
|
}));
|
1750
|
}
|
1751
|
};
|
1752
|
// The onError callback is called when something goes wrong at the network level.
|
1753
|
// Connection timeout, DNS error, offline, etc. These are actual errors, and are
|
1754
|
// transmitted on the error channel.
|
1755
|
var /** @type {?} */ onError = function (error) {
|
1756
|
var /** @type {?} */ res = new HttpErrorResponse({
|
1757
|
error: error,
|
1758
|
status: xhr.status || 0,
|
1759
|
statusText: xhr.statusText || 'Unknown Error',
|
1760
|
});
|
1761
|
observer.error(res);
|
1762
|
};
|
1763
|
// The sentHeaders flag tracks whether the HttpResponseHeaders event
|
1764
|
// has been sent on the stream. This is necessary to track if progress
|
1765
|
// is enabled since the event will be sent on only the first download
|
1766
|
// progerss event.
|
1767
|
var /** @type {?} */ sentHeaders = false;
|
1768
|
// The download progress event handler, which is only registered if
|
1769
|
// progress events are enabled.
|
1770
|
var /** @type {?} */ onDownProgress = function (event) {
|
1771
|
// Send the HttpResponseHeaders event if it hasn't been sent already.
|
1772
|
if (!sentHeaders) {
|
1773
|
observer.next(partialFromXhr());
|
1774
|
sentHeaders = true;
|
1775
|
}
|
1776
|
// Start building the download progress event to deliver on the response
|
1777
|
// event stream.
|
1778
|
var /** @type {?} */ progressEvent = {
|
1779
|
type: HttpEventType.DownloadProgress,
|
1780
|
loaded: event.loaded,
|
1781
|
};
|
1782
|
// Set the total number of bytes in the event if it's available.
|
1783
|
if (event.lengthComputable) {
|
1784
|
progressEvent.total = event.total;
|
1785
|
}
|
1786
|
// If the request was for text content and a partial response is
|
1787
|
// available on XMLHttpRequest, include it in the progress event
|
1788
|
// to allow for streaming reads.
|
1789
|
if (req.responseType === 'text' && !!xhr.responseText) {
|
1790
|
progressEvent.partialText = xhr.responseText;
|
1791
|
}
|
1792
|
// Finally, fire the event.
|
1793
|
observer.next(progressEvent);
|
1794
|
};
|
1795
|
// The upload progress event handler, which is only registered if
|
1796
|
// progress events are enabled.
|
1797
|
var /** @type {?} */ onUpProgress = function (event) {
|
1798
|
// Upload progress events are simpler. Begin building the progress
|
1799
|
// event.
|
1800
|
var /** @type {?} */ progress = {
|
1801
|
type: HttpEventType.UploadProgress,
|
1802
|
loaded: event.loaded,
|
1803
|
};
|
1804
|
// If the total number of bytes being uploaded is available, include
|
1805
|
// it.
|
1806
|
if (event.lengthComputable) {
|
1807
|
progress.total = event.total;
|
1808
|
}
|
1809
|
// Send the event.
|
1810
|
observer.next(progress);
|
1811
|
};
|
1812
|
// By default, register for load and error events.
|
1813
|
xhr.addEventListener('load', onLoad);
|
1814
|
xhr.addEventListener('error', onError);
|
1815
|
// Progress events are only enabled if requested.
|
1816
|
if (req.reportProgress) {
|
1817
|
// Download progress is always enabled if requested.
|
1818
|
xhr.addEventListener('progress', onDownProgress);
|
1819
|
// Upload progress depends on whether there is a body to upload.
|
1820
|
if (reqBody !== null && xhr.upload) {
|
1821
|
xhr.upload.addEventListener('progress', onUpProgress);
|
1822
|
}
|
1823
|
}
|
1824
|
// Fire the request, and notify the event stream that it was fired.
|
1825
|
xhr.send(reqBody);
|
1826
|
observer.next({ type: HttpEventType.Sent });
|
1827
|
// This is the return from the Observable function, which is the
|
1828
|
// request cancellation handler.
|
1829
|
return function () {
|
1830
|
// On a cancellation, remove all registered event listeners.
|
1831
|
xhr.removeEventListener('error', onError);
|
1832
|
xhr.removeEventListener('load', onLoad);
|
1833
|
if (req.reportProgress) {
|
1834
|
xhr.removeEventListener('progress', onDownProgress);
|
1835
|
if (reqBody !== null && xhr.upload) {
|
1836
|
xhr.upload.removeEventListener('progress', onUpProgress);
|
1837
|
}
|
1838
|
}
|
1839
|
// Finally, abort the in-flight request.
|
1840
|
xhr.abort();
|
1841
|
};
|
1842
|
});
|
1843
|
};
|
1844
|
return HttpXhrBackend;
|
1845
|
}());
|
1846
|
HttpXhrBackend.decorators = [
|
1847
|
{ type: _angular_core.Injectable },
|
1848
|
];
|
1849
|
/**
|
1850
|
* @nocollapse
|
1851
|
*/
|
1852
|
HttpXhrBackend.ctorParameters = function () { return [
|
1853
|
{ type: XhrFactory, },
|
1854
|
]; };
|
1855
|
/**
|
1856
|
* @license
|
1857
|
* Copyright Google Inc. All Rights Reserved.
|
1858
|
*
|
1859
|
* Use of this source code is governed by an MIT-style license that can be
|
1860
|
* found in the LICENSE file at https://angular.io/license
|
1861
|
*/
|
1862
|
var XSRF_COOKIE_NAME = new _angular_core.InjectionToken('XSRF_COOKIE_NAME');
|
1863
|
var XSRF_HEADER_NAME = new _angular_core.InjectionToken('XSRF_HEADER_NAME');
|
1864
|
/**
|
1865
|
* Retrieves the current XSRF token to use with the next outgoing request.
|
1866
|
*
|
1867
|
* \@experimental
|
1868
|
* @abstract
|
1869
|
*/
|
1870
|
var HttpXsrfTokenExtractor = (function () {
|
1871
|
function HttpXsrfTokenExtractor() {
|
1872
|
}
|
1873
|
/**
|
1874
|
* Get the XSRF token to use with an outgoing request.
|
1875
|
*
|
1876
|
* Will be called for every request, so the token may change between requests.
|
1877
|
* @abstract
|
1878
|
* @return {?}
|
1879
|
*/
|
1880
|
HttpXsrfTokenExtractor.prototype.getToken = function () { };
|
1881
|
return HttpXsrfTokenExtractor;
|
1882
|
}());
|
1883
|
/**
|
1884
|
* `HttpXsrfTokenExtractor` which retrieves the token from a cookie.
|
1885
|
*/
|
1886
|
var HttpXsrfCookieExtractor = (function () {
|
1887
|
/**
|
1888
|
* @param {?} doc
|
1889
|
* @param {?} platform
|
1890
|
* @param {?} cookieName
|
1891
|
*/
|
1892
|
function HttpXsrfCookieExtractor(doc, platform, cookieName) {
|
1893
|
this.doc = doc;
|
1894
|
this.platform = platform;
|
1895
|
this.cookieName = cookieName;
|
1896
|
this.lastCookieString = '';
|
1897
|
this.lastToken = null;
|
1898
|
/**
|
1899
|
* \@internal for testing
|
1900
|
*/
|
1901
|
this.parseCount = 0;
|
1902
|
}
|
1903
|
/**
|
1904
|
* @return {?}
|
1905
|
*/
|
1906
|
HttpXsrfCookieExtractor.prototype.getToken = function () {
|
1907
|
if (this.platform === 'server') {
|
1908
|
return null;
|
1909
|
}
|
1910
|
var /** @type {?} */ cookieString = this.doc.cookie || '';
|
1911
|
if (cookieString !== this.lastCookieString) {
|
1912
|
this.parseCount++;
|
1913
|
this.lastToken = _angular_common.ɵparseCookieValue(cookieString, this.cookieName);
|
1914
|
this.lastCookieString = cookieString;
|
1915
|
}
|
1916
|
return this.lastToken;
|
1917
|
};
|
1918
|
return HttpXsrfCookieExtractor;
|
1919
|
}());
|
1920
|
HttpXsrfCookieExtractor.decorators = [
|
1921
|
{ type: _angular_core.Injectable },
|
1922
|
];
|
1923
|
/**
|
1924
|
* @nocollapse
|
1925
|
*/
|
1926
|
HttpXsrfCookieExtractor.ctorParameters = function () { return [
|
1927
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_common.DOCUMENT,] },] },
|
1928
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.PLATFORM_ID,] },] },
|
1929
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [XSRF_COOKIE_NAME,] },] },
|
1930
|
]; };
|
1931
|
/**
|
1932
|
* `HttpInterceptor` which adds an XSRF token to eligible outgoing requests.
|
1933
|
*/
|
1934
|
var HttpXsrfInterceptor = (function () {
|
1935
|
/**
|
1936
|
* @param {?} tokenService
|
1937
|
* @param {?} headerName
|
1938
|
*/
|
1939
|
function HttpXsrfInterceptor(tokenService, headerName) {
|
1940
|
this.tokenService = tokenService;
|
1941
|
this.headerName = headerName;
|
1942
|
}
|
1943
|
/**
|
1944
|
* @param {?} req
|
1945
|
* @param {?} next
|
1946
|
* @return {?}
|
1947
|
*/
|
1948
|
HttpXsrfInterceptor.prototype.intercept = function (req, next) {
|
1949
|
var /** @type {?} */ lcUrl = req.url.toLowerCase();
|
1950
|
// Skip both non-mutating requests and absolute URLs.
|
1951
|
// Non-mutating requests don't require a token, and absolute URLs require special handling
|
1952
|
// anyway as the cookie set
|
1953
|
// on our origin is not the same as the token expected by another origin.
|
1954
|
if (req.method === 'GET' || req.method === 'HEAD' || lcUrl.startsWith('http://') ||
|
1955
|
lcUrl.startsWith('https://')) {
|
1956
|
return next.handle(req);
|
1957
|
}
|
1958
|
var /** @type {?} */ token = this.tokenService.getToken();
|
1959
|
// Be careful not to overwrite an existing header of the same name.
|
1960
|
if (token !== null && !req.headers.has(this.headerName)) {
|
1961
|
req = req.clone({ headers: req.headers.set(this.headerName, token) });
|
1962
|
}
|
1963
|
return next.handle(req);
|
1964
|
};
|
1965
|
return HttpXsrfInterceptor;
|
1966
|
}());
|
1967
|
HttpXsrfInterceptor.decorators = [
|
1968
|
{ type: _angular_core.Injectable },
|
1969
|
];
|
1970
|
/**
|
1971
|
* @nocollapse
|
1972
|
*/
|
1973
|
HttpXsrfInterceptor.ctorParameters = function () { return [
|
1974
|
{ type: HttpXsrfTokenExtractor, },
|
1975
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [XSRF_HEADER_NAME,] },] },
|
1976
|
]; };
|
1977
|
/**
|
1978
|
* @license
|
1979
|
* Copyright Google Inc. All Rights Reserved.
|
1980
|
*
|
1981
|
* Use of this source code is governed by an MIT-style license that can be
|
1982
|
* found in the LICENSE file at https://angular.io/license
|
1983
|
*/
|
1984
|
/**
|
1985
|
* Constructs an `HttpHandler` that applies a bunch of `HttpInterceptor`s
|
1986
|
* to a request before passing it to the given `HttpBackend`.
|
1987
|
*
|
1988
|
* Meant to be used as a factory function within `HttpClientModule`.
|
1989
|
*
|
1990
|
* \@experimental
|
1991
|
* @param {?} backend
|
1992
|
* @param {?=} interceptors
|
1993
|
* @return {?}
|
1994
|
*/
|
1995
|
function interceptingHandler(backend, interceptors) {
|
1996
|
if (interceptors === void 0) { interceptors = []; }
|
1997
|
if (!interceptors) {
|
1998
|
return backend;
|
1999
|
}
|
2000
|
return interceptors.reduceRight(function (next, interceptor) { return new HttpInterceptorHandler(next, interceptor); }, backend);
|
2001
|
}
|
2002
|
/**
|
2003
|
* Factory function that determines where to store JSONP callbacks.
|
2004
|
*
|
2005
|
* Ordinarily JSONP callbacks are stored on the `window` object, but this may not exist
|
2006
|
* in test environments. In that case, callbacks are stored on an anonymous object instead.
|
2007
|
*
|
2008
|
* \@experimental
|
2009
|
* @return {?}
|
2010
|
*/
|
2011
|
function jsonpCallbackContext() {
|
2012
|
if (typeof window === 'object') {
|
2013
|
return window;
|
2014
|
}
|
2015
|
return {};
|
2016
|
}
|
2017
|
/**
|
2018
|
* `NgModule` which adds XSRF protection support to outgoing requests.
|
2019
|
*
|
2020
|
* Provided the server supports a cookie-based XSRF protection system, this
|
2021
|
* module can be used directly to configure XSRF protection with the correct
|
2022
|
* cookie and header names.
|
2023
|
*
|
2024
|
* If no such names are provided, the default is to use `X-XSRF-TOKEN` for
|
2025
|
* the header name and `XSRF-TOKEN` for the cookie name.
|
2026
|
*
|
2027
|
* \@experimental
|
2028
|
*/
|
2029
|
var HttpClientXsrfModule = (function () {
|
2030
|
function HttpClientXsrfModule() {
|
2031
|
}
|
2032
|
/**
|
2033
|
* Disable the default XSRF protection.
|
2034
|
* @return {?}
|
2035
|
*/
|
2036
|
HttpClientXsrfModule.disable = function () {
|
2037
|
return {
|
2038
|
ngModule: HttpClientXsrfModule,
|
2039
|
providers: [
|
2040
|
{ provide: HttpXsrfInterceptor, useClass: NoopInterceptor },
|
2041
|
],
|
2042
|
};
|
2043
|
};
|
2044
|
/**
|
2045
|
* Configure XSRF protection to use the given cookie name or header name,
|
2046
|
* or the default names (as described above) if not provided.
|
2047
|
* @param {?=} options
|
2048
|
* @return {?}
|
2049
|
*/
|
2050
|
HttpClientXsrfModule.withOptions = function (options) {
|
2051
|
if (options === void 0) { options = {}; }
|
2052
|
return {
|
2053
|
ngModule: HttpClientXsrfModule,
|
2054
|
providers: [
|
2055
|
options.cookieName ? { provide: XSRF_COOKIE_NAME, useValue: options.cookieName } : [],
|
2056
|
options.headerName ? { provide: XSRF_HEADER_NAME, useValue: options.headerName } : [],
|
2057
|
],
|
2058
|
};
|
2059
|
};
|
2060
|
return HttpClientXsrfModule;
|
2061
|
}());
|
2062
|
HttpClientXsrfModule.decorators = [
|
2063
|
{ type: _angular_core.NgModule, args: [{
|
2064
|
providers: [
|
2065
|
HttpXsrfInterceptor,
|
2066
|
{ provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true },
|
2067
|
{ provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor },
|
2068
|
{ provide: XSRF_COOKIE_NAME, useValue: 'XSRF-TOKEN' },
|
2069
|
{ provide: XSRF_HEADER_NAME, useValue: 'X-XSRF-TOKEN' },
|
2070
|
],
|
2071
|
},] },
|
2072
|
];
|
2073
|
/**
|
2074
|
* @nocollapse
|
2075
|
*/
|
2076
|
HttpClientXsrfModule.ctorParameters = function () { return []; };
|
2077
|
/**
|
2078
|
* `NgModule` which provides the `HttpClient` and associated services.
|
2079
|
*
|
2080
|
* Interceptors can be added to the chain behind `HttpClient` by binding them
|
2081
|
* to the multiprovider for `HTTP_INTERCEPTORS`.
|
2082
|
*
|
2083
|
* \@experimental
|
2084
|
*/
|
2085
|
var HttpClientModule = (function () {
|
2086
|
function HttpClientModule() {
|
2087
|
}
|
2088
|
return HttpClientModule;
|
2089
|
}());
|
2090
|
HttpClientModule.decorators = [
|
2091
|
{ type: _angular_core.NgModule, args: [{
|
2092
|
imports: [
|
2093
|
HttpClientXsrfModule.withOptions({
|
2094
|
cookieName: 'XSRF-TOKEN',
|
2095
|
headerName: 'X-XSRF-TOKEN',
|
2096
|
}),
|
2097
|
],
|
2098
|
providers: [
|
2099
|
HttpClient,
|
2100
|
// HttpHandler is the backend + interceptors and is constructed
|
2101
|
// using the interceptingHandler factory function.
|
2102
|
{
|
2103
|
provide: HttpHandler,
|
2104
|
useFactory: interceptingHandler,
|
2105
|
deps: [HttpBackend, [new _angular_core.Optional(), new _angular_core.Inject(HTTP_INTERCEPTORS)]],
|
2106
|
},
|
2107
|
HttpXhrBackend,
|
2108
|
{ provide: HttpBackend, useExisting: HttpXhrBackend },
|
2109
|
BrowserXhr,
|
2110
|
{ provide: XhrFactory, useExisting: BrowserXhr },
|
2111
|
],
|
2112
|
},] },
|
2113
|
];
|
2114
|
/**
|
2115
|
* @nocollapse
|
2116
|
*/
|
2117
|
HttpClientModule.ctorParameters = function () { return []; };
|
2118
|
/**
|
2119
|
* `NgModule` which enables JSONP support in `HttpClient`.
|
2120
|
*
|
2121
|
* Without this module, Jsonp requests will reach the backend
|
2122
|
* with method JSONP, where they'll be rejected.
|
2123
|
*
|
2124
|
* \@experimental
|
2125
|
*/
|
2126
|
var HttpClientJsonpModule = (function () {
|
2127
|
function HttpClientJsonpModule() {
|
2128
|
}
|
2129
|
return HttpClientJsonpModule;
|
2130
|
}());
|
2131
|
HttpClientJsonpModule.decorators = [
|
2132
|
{ type: _angular_core.NgModule, args: [{
|
2133
|
providers: [
|
2134
|
JsonpClientBackend,
|
2135
|
{ provide: JsonpCallbackContext, useFactory: jsonpCallbackContext },
|
2136
|
{ provide: HTTP_INTERCEPTORS, useClass: JsonpInterceptor, multi: true },
|
2137
|
],
|
2138
|
},] },
|
2139
|
];
|
2140
|
/**
|
2141
|
* @nocollapse
|
2142
|
*/
|
2143
|
HttpClientJsonpModule.ctorParameters = function () { return []; };
|
2144
|
|
2145
|
exports.HttpBackend = HttpBackend;
|
2146
|
exports.HttpHandler = HttpHandler;
|
2147
|
exports.HttpClient = HttpClient;
|
2148
|
exports.HttpHeaders = HttpHeaders;
|
2149
|
exports.HTTP_INTERCEPTORS = HTTP_INTERCEPTORS;
|
2150
|
exports.JsonpClientBackend = JsonpClientBackend;
|
2151
|
exports.JsonpInterceptor = JsonpInterceptor;
|
2152
|
exports.HttpClientJsonpModule = HttpClientJsonpModule;
|
2153
|
exports.HttpClientModule = HttpClientModule;
|
2154
|
exports.HttpClientXsrfModule = HttpClientXsrfModule;
|
2155
|
exports.ɵinterceptingHandler = interceptingHandler;
|
2156
|
exports.HttpParams = HttpParams;
|
2157
|
exports.HttpUrlEncodingCodec = HttpUrlEncodingCodec;
|
2158
|
exports.HttpRequest = HttpRequest;
|
2159
|
exports.HttpErrorResponse = HttpErrorResponse;
|
2160
|
exports.HttpEventType = HttpEventType;
|
2161
|
exports.HttpHeaderResponse = HttpHeaderResponse;
|
2162
|
exports.HttpResponse = HttpResponse;
|
2163
|
exports.HttpResponseBase = HttpResponseBase;
|
2164
|
exports.HttpXhrBackend = HttpXhrBackend;
|
2165
|
exports.XhrFactory = XhrFactory;
|
2166
|
exports.HttpXsrfTokenExtractor = HttpXsrfTokenExtractor;
|
2167
|
exports.ɵa = NoopInterceptor;
|
2168
|
exports.ɵb = JsonpCallbackContext;
|
2169
|
exports.ɵc = jsonpCallbackContext;
|
2170
|
exports.ɵd = BrowserXhr;
|
2171
|
exports.ɵg = HttpXsrfCookieExtractor;
|
2172
|
exports.ɵh = HttpXsrfInterceptor;
|
2173
|
exports.ɵe = XSRF_COOKIE_NAME;
|
2174
|
exports.ɵf = XSRF_HEADER_NAME;
|
2175
|
|
2176
|
Object.defineProperty(exports, '__esModule', { value: true });
|
2177
|
|
2178
|
})));
|
2179
|
//# sourceMappingURL=common-http.umd.js.map
|