@alterior/http 3.11.1 → 3.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/backend.d.ts +38 -38
  2. package/dist/backend.js +38 -38
  3. package/dist/client.d.ts +2108 -2108
  4. package/dist/client.js +265 -265
  5. package/dist/client.js.map +1 -1
  6. package/dist/headers.d.ts +57 -57
  7. package/dist/headers.js +187 -187
  8. package/dist/headers.js.map +1 -1
  9. package/dist/index.d.ts +18 -18
  10. package/dist/index.js +42 -42
  11. package/dist/interceptor.d.ts +63 -63
  12. package/dist/interceptor.js +43 -43
  13. package/dist/interceptor.js.map +1 -1
  14. package/dist/module.d.ts +101 -101
  15. package/dist/module.js +188 -188
  16. package/dist/module.js.map +1 -1
  17. package/dist/params.d.ts +98 -98
  18. package/dist/params.js +184 -184
  19. package/dist/params.js.map +1 -1
  20. package/dist/request.d.ts +130 -130
  21. package/dist/request.js +260 -260
  22. package/dist/request.js.map +1 -1
  23. package/dist/response.d.ts +267 -267
  24. package/dist/response.js +165 -165
  25. package/dist/response.js.map +1 -1
  26. package/dist/server.d.ts +28 -28
  27. package/dist/server.js +119 -119
  28. package/dist/server.js.map +1 -1
  29. package/dist/test/client.test.d.ts +8 -8
  30. package/dist/test/client.test.js +163 -163
  31. package/dist/test/client.test.js.map +1 -1
  32. package/dist/test/headers.test.d.ts +1 -1
  33. package/dist/test/headers.test.js +126 -126
  34. package/dist/test/module.test.d.ts +1 -1
  35. package/dist/test/module.test.js +117 -117
  36. package/dist/test/module.test.js.map +1 -1
  37. package/dist/test/params.test.d.ts +1 -1
  38. package/dist/test/params.test.js +63 -63
  39. package/dist/test/request.test.d.ts +8 -8
  40. package/dist/test/request.test.js +159 -159
  41. package/dist/test/request.test.js.map +1 -1
  42. package/dist/test/response.test.d.ts +1 -1
  43. package/dist/test/response.test.js +79 -79
  44. package/dist/test/response.test.js.map +1 -1
  45. package/dist/test/test.d.ts +1 -1
  46. package/dist/test/test.js +16 -16
  47. package/dist/test/xhr.mock.d.ts +48 -48
  48. package/dist/test/xhr.mock.js +94 -94
  49. package/dist/test/xhr.mock.js.map +1 -1
  50. package/dist/test/xhr.test.d.ts +1 -1
  51. package/dist/test/xhr.test.js +344 -344
  52. package/dist/test/xhr.test.js.map +1 -1
  53. package/dist/test/xsrf.test.d.ts +1 -1
  54. package/dist/test/xsrf.test.js +63 -63
  55. package/dist/test/xsrf.test.js.map +1 -1
  56. package/dist/testing/api.d.ts +102 -102
  57. package/dist/testing/api.js +19 -19
  58. package/dist/testing/backend.d.ts +63 -63
  59. package/dist/testing/backend.js +141 -141
  60. package/dist/testing/backend.js.map +1 -1
  61. package/dist/testing/index.d.ts +10 -10
  62. package/dist/testing/index.js +16 -16
  63. package/dist/testing/module.d.ts +16 -16
  64. package/dist/testing/module.js +38 -38
  65. package/dist/testing/module.js.map +1 -1
  66. package/dist/testing/request.d.ts +56 -56
  67. package/dist/testing/request.js +177 -177
  68. package/dist/testing/request.js.map +1 -1
  69. package/dist/testing/request.test.d.ts +8 -8
  70. package/dist/testing/request.test.js +24 -24
  71. package/dist/xhr.d.ts +42 -42
  72. package/dist/xhr.js +298 -298
  73. package/dist/xhr.js.map +1 -1
  74. package/dist/xsrf.d.ts +37 -37
  75. package/dist/xsrf.js +55 -55
  76. package/dist/xsrf.js.map +1 -1
  77. package/dist.esm/backend.d.ts +38 -38
  78. package/dist.esm/backend.js +33 -33
  79. package/dist.esm/client.d.ts +2108 -2108
  80. package/dist.esm/client.js +262 -262
  81. package/dist.esm/client.js.map +1 -1
  82. package/dist.esm/headers.d.ts +57 -57
  83. package/dist.esm/headers.js +183 -183
  84. package/dist.esm/headers.js.map +1 -1
  85. package/dist.esm/index.d.ts +18 -18
  86. package/dist.esm/index.js +18 -18
  87. package/dist.esm/interceptor.d.ts +63 -63
  88. package/dist.esm/interceptor.js +39 -39
  89. package/dist.esm/interceptor.js.map +1 -1
  90. package/dist.esm/module.d.ts +101 -101
  91. package/dist.esm/module.js +183 -183
  92. package/dist.esm/module.js.map +1 -1
  93. package/dist.esm/params.d.ts +98 -98
  94. package/dist.esm/params.js +179 -179
  95. package/dist.esm/params.js.map +1 -1
  96. package/dist.esm/request.d.ts +130 -130
  97. package/dist.esm/request.js +256 -256
  98. package/dist.esm/request.js.map +1 -1
  99. package/dist.esm/response.d.ts +267 -267
  100. package/dist.esm/response.js +158 -158
  101. package/dist.esm/response.js.map +1 -1
  102. package/dist.esm/server.d.ts +28 -28
  103. package/dist.esm/server.js +113 -113
  104. package/dist.esm/server.js.map +1 -1
  105. package/dist.esm/test/client.test.d.ts +8 -8
  106. package/dist.esm/test/client.test.js +161 -161
  107. package/dist.esm/test/client.test.js.map +1 -1
  108. package/dist.esm/test/headers.test.d.ts +1 -1
  109. package/dist.esm/test/headers.test.js +124 -124
  110. package/dist.esm/test/module.test.d.ts +1 -1
  111. package/dist.esm/test/module.test.js +115 -115
  112. package/dist.esm/test/module.test.js.map +1 -1
  113. package/dist.esm/test/params.test.d.ts +1 -1
  114. package/dist.esm/test/params.test.js +61 -61
  115. package/dist.esm/test/request.test.d.ts +8 -8
  116. package/dist.esm/test/request.test.js +157 -157
  117. package/dist.esm/test/request.test.js.map +1 -1
  118. package/dist.esm/test/response.test.d.ts +1 -1
  119. package/dist.esm/test/response.test.js +77 -77
  120. package/dist.esm/test/response.test.js.map +1 -1
  121. package/dist.esm/test/test.d.ts +1 -1
  122. package/dist.esm/test/test.js +14 -14
  123. package/dist.esm/test/xhr.mock.d.ts +48 -48
  124. package/dist.esm/test/xhr.mock.js +88 -88
  125. package/dist.esm/test/xhr.mock.js.map +1 -1
  126. package/dist.esm/test/xhr.test.d.ts +1 -1
  127. package/dist.esm/test/xhr.test.js +342 -342
  128. package/dist.esm/test/xhr.test.js.map +1 -1
  129. package/dist.esm/test/xsrf.test.d.ts +1 -1
  130. package/dist.esm/test/xsrf.test.js +61 -61
  131. package/dist.esm/test/xsrf.test.js.map +1 -1
  132. package/dist.esm/testing/api.d.ts +102 -102
  133. package/dist.esm/testing/api.js +15 -15
  134. package/dist.esm/testing/backend.d.ts +63 -63
  135. package/dist.esm/testing/backend.js +138 -138
  136. package/dist.esm/testing/backend.js.map +1 -1
  137. package/dist.esm/testing/index.d.ts +10 -10
  138. package/dist.esm/testing/index.js +10 -10
  139. package/dist.esm/testing/module.d.ts +16 -16
  140. package/dist.esm/testing/module.js +35 -35
  141. package/dist.esm/testing/module.js.map +1 -1
  142. package/dist.esm/testing/request.d.ts +56 -56
  143. package/dist.esm/testing/request.js +173 -173
  144. package/dist.esm/testing/request.js.map +1 -1
  145. package/dist.esm/testing/request.test.d.ts +8 -8
  146. package/dist.esm/testing/request.test.js +22 -22
  147. package/dist.esm/xhr.d.ts +42 -42
  148. package/dist.esm/xhr.js +294 -294
  149. package/dist.esm/xhr.js.map +1 -1
  150. package/dist.esm/xsrf.d.ts +37 -37
  151. package/dist.esm/xsrf.js +51 -51
  152. package/dist.esm/xsrf.js.map +1 -1
  153. package/package.json +11 -11
  154. package/tsconfig.esm.tsbuildinfo +1 -0
  155. package/tsconfig.json +0 -2
  156. package/tsconfig.tsbuildinfo +1 -8046
package/dist/xhr.js CHANGED
@@ -1,299 +1,299 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google Inc. All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.HttpXhrBackend = exports.BrowserXhr = exports.XhrFactory = void 0;
11
- const tslib_1 = require("tslib");
12
- const di_1 = require("@alterior/di");
13
- const rxjs_1 = require("rxjs");
14
- const headers_1 = require("./headers");
15
- const response_1 = require("./response");
16
- const XSSI_PREFIX = /^\)\]\}',?\n/;
17
- /**
18
- * Determine an appropriate URL for the response, by checking either
19
- * XMLHttpRequest.responseURL or the X-Request-URL header.
20
- */
21
- function getResponseUrl(xhr) {
22
- if ('responseURL' in xhr && xhr.responseURL) {
23
- return xhr.responseURL;
24
- }
25
- if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
26
- return xhr.getResponseHeader('X-Request-URL');
27
- }
28
- return null;
29
- }
30
- /**
31
- * A wrapper around the `XMLHttpRequest` constructor.
32
- *
33
- *
34
- */
35
- class XhrFactory {
36
- }
37
- exports.XhrFactory = XhrFactory;
38
- /**
39
- * A factory for @{link HttpXhrBackend} that uses the `XMLHttpRequest` browser API.
40
- *
41
- *
42
- */
43
- let BrowserXhr = class BrowserXhr {
44
- constructor() { }
45
- build() { return (new XMLHttpRequest()); }
46
- };
47
- BrowserXhr = tslib_1.__decorate([
48
- (0, di_1.Injectable)(),
49
- tslib_1.__metadata("design:paramtypes", [])
50
- ], BrowserXhr);
51
- exports.BrowserXhr = BrowserXhr;
52
- /**
53
- * An `HttpBackend` which uses the XMLHttpRequest API to send
54
- * requests to a backend server.
55
- *
56
- *
57
- */
58
- let HttpXhrBackend = class HttpXhrBackend {
59
- constructor(xhrFactory) {
60
- this.xhrFactory = xhrFactory;
61
- }
62
- /**
63
- * Process a request and return a stream of response events.
64
- */
65
- handle(req) {
66
- // Quick check to give a better error message when a user attempts to use
67
- // HttpClient.jsonp() without installing the JsonpClientModule
68
- if (req.method === 'JSONP') {
69
- throw new Error(`Attempted to construct Jsonp request without JsonpClientModule installed.`);
70
- }
71
- // Everything happens on Observable subscription.
72
- return new rxjs_1.Observable((observer) => {
73
- // Start by setting up the XHR object with request method, URL, and withCredentials flag.
74
- const xhr = this.xhrFactory.build();
75
- xhr.open(req.method, req.urlWithParams);
76
- if (!!req.withCredentials) {
77
- xhr.withCredentials = true;
78
- }
79
- // Add all the requested headers.
80
- req.headers.forEach((name, values) => xhr.setRequestHeader(name, values.join(',')));
81
- // Add an Accept header if one isn't present already.
82
- if (!req.headers.has('Accept')) {
83
- xhr.setRequestHeader('Accept', 'application/json, text/plain, */*');
84
- }
85
- // Auto-detect the Content-Type header if one isn't present already.
86
- if (!req.headers.has('Content-Type')) {
87
- const detectedType = req.detectContentTypeHeader();
88
- // Sometimes Content-Type detection fails.
89
- if (detectedType !== null) {
90
- xhr.setRequestHeader('Content-Type', detectedType);
91
- }
92
- }
93
- // Set the responseType if one was requested.
94
- if (req.responseType) {
95
- const responseType = req.responseType.toLowerCase();
96
- // JSON responses need to be processed as text. This is because if the server
97
- // returns an XSSI-prefixed JSON response, the browser will fail to parse it,
98
- // xhr.response will be null, and xhr.responseText cannot be accessed to
99
- // retrieve the prefixed JSON data in order to strip the prefix. Thus, all JSON
100
- // is parsed by first requesting text and then applying JSON.parse.
101
- xhr.responseType = ((responseType !== 'json') ? responseType : 'text');
102
- }
103
- // Serialize the request body if one is present. If not, this will be set to null.
104
- const reqBody = req.serializeBody();
105
- // If progress events are enabled, response headers will be delivered
106
- // in two events - the HttpHeaderResponse event and the full HttpResponse
107
- // event. However, since response headers don't change in between these
108
- // two events, it doesn't make sense to parse them twice. So headerResponse
109
- // caches the data extracted from the response whenever it's first parsed,
110
- // to ensure parsing isn't duplicated.
111
- let headerResponse = null;
112
- // partialFromXhr extracts the HttpHeaderResponse from the current XMLHttpRequest
113
- // state, and memoizes it into headerResponse.
114
- const partialFromXhr = () => {
115
- if (headerResponse !== null) {
116
- return headerResponse;
117
- }
118
- // Read status and normalize an IE9 bug (http://bugs.jquery.com/ticket/1450).
119
- const status = xhr.status === 1223 ? 204 : xhr.status;
120
- const statusText = xhr.statusText || 'OK';
121
- // Parse headers from XMLHttpRequest - this step is lazy.
122
- const headers = new headers_1.HttpHeaders(xhr.getAllResponseHeaders());
123
- // Read the response URL from the XMLHttpResponse instance and fall back on the
124
- // request URL.
125
- const url = getResponseUrl(xhr) || req.url;
126
- // Construct the HttpHeaderResponse and memoize it.
127
- headerResponse = new response_1.HttpHeaderResponse({ headers, status, statusText, url });
128
- return headerResponse;
129
- };
130
- // Next, a few closures are defined for the various events which XMLHttpRequest can
131
- // emit. This allows them to be unregistered as event listeners later.
132
- // First up is the load event, which represents a response being fully available.
133
- const onLoad = () => {
134
- // Read response state from the memoized partial data.
135
- let { headers, status, statusText, url } = partialFromXhr();
136
- // The body will be read out if present.
137
- let body = null;
138
- if (status !== 204) {
139
- // Use XMLHttpRequest.response if set, responseText otherwise.
140
- body = (typeof xhr.response === 'undefined') ? xhr.responseText : xhr.response;
141
- }
142
- // Normalize another potential bug (this one comes from CORS).
143
- if (status === 0) {
144
- status = !!body ? 200 : 0;
145
- }
146
- // ok determines whether the response will be transmitted on the event or
147
- // error channel. Unsuccessful status codes (not 2xx) will always be errors,
148
- // but a successful status code can still result in an error if the user
149
- // asked for JSON data and the body cannot be parsed as such.
150
- let ok = status >= 200 && status < 300;
151
- // Check whether the body needs to be parsed as JSON (in many cases the browser
152
- // will have done that already).
153
- if (req.responseType === 'json' && typeof body === 'string') {
154
- // Save the original body, before attempting XSSI prefix stripping.
155
- const originalBody = body;
156
- body = body.replace(XSSI_PREFIX, '');
157
- try {
158
- // Attempt the parse. If it fails, a parse error should be delivered to the user.
159
- body = body !== '' ? JSON.parse(body) : null;
160
- }
161
- catch (error) {
162
- // Since the JSON.parse failed, it's reasonable to assume this might not have been a
163
- // JSON response. Restore the original body (including any XSSI prefix) to deliver
164
- // a better error response.
165
- body = originalBody;
166
- // If this was an error request to begin with, leave it as a string, it probably
167
- // just isn't JSON. Otherwise, deliver the parsing error to the user.
168
- if (ok) {
169
- // Even though the response status was 2xx, this is still an error.
170
- ok = false;
171
- // The parse error contains the text of the body that failed to parse.
172
- body = { error, text: body };
173
- }
174
- }
175
- }
176
- if (ok) {
177
- // A successful response is delivered on the event stream.
178
- observer.next(new response_1.HttpResponse({
179
- body,
180
- headers,
181
- status,
182
- statusText,
183
- url: url || undefined,
184
- }));
185
- // The full body has been received and delivered, no further events
186
- // are possible. This request is complete.
187
- observer.complete();
188
- }
189
- else {
190
- // An unsuccessful request is delivered on the error channel.
191
- observer.error(new response_1.HttpErrorResponse({
192
- // The error in this case is the response body (error from the server).
193
- error: body,
194
- headers,
195
- status,
196
- statusText,
197
- url: url || undefined,
198
- }));
199
- }
200
- };
201
- // The onError callback is called when something goes wrong at the network level.
202
- // Connection timeout, DNS error, offline, etc. These are actual errors, and are
203
- // transmitted on the error channel.
204
- const onError = (error) => {
205
- const res = new response_1.HttpErrorResponse({
206
- error,
207
- status: xhr.status || 0,
208
- statusText: xhr.statusText || 'Unknown Error',
209
- });
210
- observer.error(res);
211
- };
212
- // The sentHeaders flag tracks whether the HttpResponseHeaders event
213
- // has been sent on the stream. This is necessary to track if progress
214
- // is enabled since the event will be sent on only the first download
215
- // progerss event.
216
- let sentHeaders = false;
217
- // The download progress event handler, which is only registered if
218
- // progress events are enabled.
219
- const onDownProgress = (event) => {
220
- // Send the HttpResponseHeaders event if it hasn't been sent already.
221
- if (!sentHeaders) {
222
- observer.next(partialFromXhr());
223
- sentHeaders = true;
224
- }
225
- // Start building the download progress event to deliver on the response
226
- // event stream.
227
- let progressEvent = {
228
- type: response_1.HttpEventType.DownloadProgress,
229
- loaded: event.loaded,
230
- };
231
- // Set the total number of bytes in the event if it's available.
232
- if (event.lengthComputable) {
233
- progressEvent.total = event.total;
234
- }
235
- // If the request was for text content and a partial response is
236
- // available on XMLHttpRequest, include it in the progress event
237
- // to allow for streaming reads.
238
- if (req.responseType === 'text' && !!xhr.responseText) {
239
- progressEvent.partialText = xhr.responseText;
240
- }
241
- // Finally, fire the event.
242
- observer.next(progressEvent);
243
- };
244
- // The upload progress event handler, which is only registered if
245
- // progress events are enabled.
246
- const onUpProgress = (event) => {
247
- // Upload progress events are simpler. Begin building the progress
248
- // event.
249
- let progress = {
250
- type: response_1.HttpEventType.UploadProgress,
251
- loaded: event.loaded,
252
- };
253
- // If the total number of bytes being uploaded is available, include
254
- // it.
255
- if (event.lengthComputable) {
256
- progress.total = event.total;
257
- }
258
- // Send the event.
259
- observer.next(progress);
260
- };
261
- // By default, register for load and error events.
262
- xhr.addEventListener('load', onLoad);
263
- xhr.addEventListener('error', onError);
264
- // Progress events are only enabled if requested.
265
- if (req.reportProgress) {
266
- // Download progress is always enabled if requested.
267
- xhr.addEventListener('progress', onDownProgress);
268
- // Upload progress depends on whether there is a body to upload.
269
- if (reqBody !== null && xhr.upload) {
270
- xhr.upload.addEventListener('progress', onUpProgress);
271
- }
272
- }
273
- // Fire the request, and notify the event stream that it was fired.
274
- xhr.send(reqBody);
275
- observer.next({ type: response_1.HttpEventType.Sent });
276
- // This is the return from the Observable function, which is the
277
- // request cancellation handler.
278
- return () => {
279
- // On a cancellation, remove all registered event listeners.
280
- xhr.removeEventListener('error', onError);
281
- xhr.removeEventListener('load', onLoad);
282
- if (req.reportProgress) {
283
- xhr.removeEventListener('progress', onDownProgress);
284
- if (reqBody !== null && xhr.upload) {
285
- xhr.upload.removeEventListener('progress', onUpProgress);
286
- }
287
- }
288
- // Finally, abort the in-flight request.
289
- xhr.abort();
290
- };
291
- });
292
- }
293
- };
294
- HttpXhrBackend = tslib_1.__decorate([
295
- (0, di_1.Injectable)(),
296
- tslib_1.__metadata("design:paramtypes", [XhrFactory])
297
- ], HttpXhrBackend);
298
- exports.HttpXhrBackend = HttpXhrBackend;
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google Inc. All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.HttpXhrBackend = exports.BrowserXhr = exports.XhrFactory = void 0;
11
+ const tslib_1 = require("tslib");
12
+ const di_1 = require("@alterior/di");
13
+ const rxjs_1 = require("rxjs");
14
+ const headers_1 = require("./headers");
15
+ const response_1 = require("./response");
16
+ const XSSI_PREFIX = /^\)\]\}',?\n/;
17
+ /**
18
+ * Determine an appropriate URL for the response, by checking either
19
+ * XMLHttpRequest.responseURL or the X-Request-URL header.
20
+ */
21
+ function getResponseUrl(xhr) {
22
+ if ('responseURL' in xhr && xhr.responseURL) {
23
+ return xhr.responseURL;
24
+ }
25
+ if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
26
+ return xhr.getResponseHeader('X-Request-URL');
27
+ }
28
+ return null;
29
+ }
30
+ /**
31
+ * A wrapper around the `XMLHttpRequest` constructor.
32
+ *
33
+ *
34
+ */
35
+ class XhrFactory {
36
+ }
37
+ exports.XhrFactory = XhrFactory;
38
+ /**
39
+ * A factory for @{link HttpXhrBackend} that uses the `XMLHttpRequest` browser API.
40
+ *
41
+ *
42
+ */
43
+ let BrowserXhr = class BrowserXhr {
44
+ constructor() { }
45
+ build() { return (new XMLHttpRequest()); }
46
+ };
47
+ exports.BrowserXhr = BrowserXhr;
48
+ exports.BrowserXhr = BrowserXhr = tslib_1.__decorate([
49
+ (0, di_1.Injectable)(),
50
+ tslib_1.__metadata("design:paramtypes", [])
51
+ ], BrowserXhr);
52
+ /**
53
+ * An `HttpBackend` which uses the XMLHttpRequest API to send
54
+ * requests to a backend server.
55
+ *
56
+ *
57
+ */
58
+ let HttpXhrBackend = class HttpXhrBackend {
59
+ constructor(xhrFactory) {
60
+ this.xhrFactory = xhrFactory;
61
+ }
62
+ /**
63
+ * Process a request and return a stream of response events.
64
+ */
65
+ handle(req) {
66
+ // Quick check to give a better error message when a user attempts to use
67
+ // HttpClient.jsonp() without installing the JsonpClientModule
68
+ if (req.method === 'JSONP') {
69
+ throw new Error(`Attempted to construct Jsonp request without JsonpClientModule installed.`);
70
+ }
71
+ // Everything happens on Observable subscription.
72
+ return new rxjs_1.Observable((observer) => {
73
+ // Start by setting up the XHR object with request method, URL, and withCredentials flag.
74
+ const xhr = this.xhrFactory.build();
75
+ xhr.open(req.method, req.urlWithParams);
76
+ if (!!req.withCredentials) {
77
+ xhr.withCredentials = true;
78
+ }
79
+ // Add all the requested headers.
80
+ req.headers.forEach((name, values) => xhr.setRequestHeader(name, values.join(',')));
81
+ // Add an Accept header if one isn't present already.
82
+ if (!req.headers.has('Accept')) {
83
+ xhr.setRequestHeader('Accept', 'application/json, text/plain, */*');
84
+ }
85
+ // Auto-detect the Content-Type header if one isn't present already.
86
+ if (!req.headers.has('Content-Type')) {
87
+ const detectedType = req.detectContentTypeHeader();
88
+ // Sometimes Content-Type detection fails.
89
+ if (detectedType !== null) {
90
+ xhr.setRequestHeader('Content-Type', detectedType);
91
+ }
92
+ }
93
+ // Set the responseType if one was requested.
94
+ if (req.responseType) {
95
+ const responseType = req.responseType.toLowerCase();
96
+ // JSON responses need to be processed as text. This is because if the server
97
+ // returns an XSSI-prefixed JSON response, the browser will fail to parse it,
98
+ // xhr.response will be null, and xhr.responseText cannot be accessed to
99
+ // retrieve the prefixed JSON data in order to strip the prefix. Thus, all JSON
100
+ // is parsed by first requesting text and then applying JSON.parse.
101
+ xhr.responseType = ((responseType !== 'json') ? responseType : 'text');
102
+ }
103
+ // Serialize the request body if one is present. If not, this will be set to null.
104
+ const reqBody = req.serializeBody();
105
+ // If progress events are enabled, response headers will be delivered
106
+ // in two events - the HttpHeaderResponse event and the full HttpResponse
107
+ // event. However, since response headers don't change in between these
108
+ // two events, it doesn't make sense to parse them twice. So headerResponse
109
+ // caches the data extracted from the response whenever it's first parsed,
110
+ // to ensure parsing isn't duplicated.
111
+ let headerResponse = null;
112
+ // partialFromXhr extracts the HttpHeaderResponse from the current XMLHttpRequest
113
+ // state, and memoizes it into headerResponse.
114
+ const partialFromXhr = () => {
115
+ if (headerResponse !== null) {
116
+ return headerResponse;
117
+ }
118
+ // Read status and normalize an IE9 bug (http://bugs.jquery.com/ticket/1450).
119
+ const status = xhr.status === 1223 ? 204 : xhr.status;
120
+ const statusText = xhr.statusText || 'OK';
121
+ // Parse headers from XMLHttpRequest - this step is lazy.
122
+ const headers = new headers_1.HttpHeaders(xhr.getAllResponseHeaders());
123
+ // Read the response URL from the XMLHttpResponse instance and fall back on the
124
+ // request URL.
125
+ const url = getResponseUrl(xhr) || req.url;
126
+ // Construct the HttpHeaderResponse and memoize it.
127
+ headerResponse = new response_1.HttpHeaderResponse({ headers, status, statusText, url });
128
+ return headerResponse;
129
+ };
130
+ // Next, a few closures are defined for the various events which XMLHttpRequest can
131
+ // emit. This allows them to be unregistered as event listeners later.
132
+ // First up is the load event, which represents a response being fully available.
133
+ const onLoad = () => {
134
+ // Read response state from the memoized partial data.
135
+ let { headers, status, statusText, url } = partialFromXhr();
136
+ // The body will be read out if present.
137
+ let body = null;
138
+ if (status !== 204) {
139
+ // Use XMLHttpRequest.response if set, responseText otherwise.
140
+ body = (typeof xhr.response === 'undefined') ? xhr.responseText : xhr.response;
141
+ }
142
+ // Normalize another potential bug (this one comes from CORS).
143
+ if (status === 0) {
144
+ status = !!body ? 200 : 0;
145
+ }
146
+ // ok determines whether the response will be transmitted on the event or
147
+ // error channel. Unsuccessful status codes (not 2xx) will always be errors,
148
+ // but a successful status code can still result in an error if the user
149
+ // asked for JSON data and the body cannot be parsed as such.
150
+ let ok = status >= 200 && status < 300;
151
+ // Check whether the body needs to be parsed as JSON (in many cases the browser
152
+ // will have done that already).
153
+ if (req.responseType === 'json' && typeof body === 'string') {
154
+ // Save the original body, before attempting XSSI prefix stripping.
155
+ const originalBody = body;
156
+ body = body.replace(XSSI_PREFIX, '');
157
+ try {
158
+ // Attempt the parse. If it fails, a parse error should be delivered to the user.
159
+ body = body !== '' ? JSON.parse(body) : null;
160
+ }
161
+ catch (error) {
162
+ // Since the JSON.parse failed, it's reasonable to assume this might not have been a
163
+ // JSON response. Restore the original body (including any XSSI prefix) to deliver
164
+ // a better error response.
165
+ body = originalBody;
166
+ // If this was an error request to begin with, leave it as a string, it probably
167
+ // just isn't JSON. Otherwise, deliver the parsing error to the user.
168
+ if (ok) {
169
+ // Even though the response status was 2xx, this is still an error.
170
+ ok = false;
171
+ // The parse error contains the text of the body that failed to parse.
172
+ body = { error, text: body };
173
+ }
174
+ }
175
+ }
176
+ if (ok) {
177
+ // A successful response is delivered on the event stream.
178
+ observer.next(new response_1.HttpResponse({
179
+ body,
180
+ headers,
181
+ status,
182
+ statusText,
183
+ url: url || undefined,
184
+ }));
185
+ // The full body has been received and delivered, no further events
186
+ // are possible. This request is complete.
187
+ observer.complete();
188
+ }
189
+ else {
190
+ // An unsuccessful request is delivered on the error channel.
191
+ observer.error(new response_1.HttpErrorResponse({
192
+ // The error in this case is the response body (error from the server).
193
+ error: body,
194
+ headers,
195
+ status,
196
+ statusText,
197
+ url: url || undefined,
198
+ }));
199
+ }
200
+ };
201
+ // The onError callback is called when something goes wrong at the network level.
202
+ // Connection timeout, DNS error, offline, etc. These are actual errors, and are
203
+ // transmitted on the error channel.
204
+ const onError = (error) => {
205
+ const res = new response_1.HttpErrorResponse({
206
+ error,
207
+ status: xhr.status || 0,
208
+ statusText: xhr.statusText || 'Unknown Error',
209
+ });
210
+ observer.error(res);
211
+ };
212
+ // The sentHeaders flag tracks whether the HttpResponseHeaders event
213
+ // has been sent on the stream. This is necessary to track if progress
214
+ // is enabled since the event will be sent on only the first download
215
+ // progerss event.
216
+ let sentHeaders = false;
217
+ // The download progress event handler, which is only registered if
218
+ // progress events are enabled.
219
+ const onDownProgress = (event) => {
220
+ // Send the HttpResponseHeaders event if it hasn't been sent already.
221
+ if (!sentHeaders) {
222
+ observer.next(partialFromXhr());
223
+ sentHeaders = true;
224
+ }
225
+ // Start building the download progress event to deliver on the response
226
+ // event stream.
227
+ let progressEvent = {
228
+ type: response_1.HttpEventType.DownloadProgress,
229
+ loaded: event.loaded,
230
+ };
231
+ // Set the total number of bytes in the event if it's available.
232
+ if (event.lengthComputable) {
233
+ progressEvent.total = event.total;
234
+ }
235
+ // If the request was for text content and a partial response is
236
+ // available on XMLHttpRequest, include it in the progress event
237
+ // to allow for streaming reads.
238
+ if (req.responseType === 'text' && !!xhr.responseText) {
239
+ progressEvent.partialText = xhr.responseText;
240
+ }
241
+ // Finally, fire the event.
242
+ observer.next(progressEvent);
243
+ };
244
+ // The upload progress event handler, which is only registered if
245
+ // progress events are enabled.
246
+ const onUpProgress = (event) => {
247
+ // Upload progress events are simpler. Begin building the progress
248
+ // event.
249
+ let progress = {
250
+ type: response_1.HttpEventType.UploadProgress,
251
+ loaded: event.loaded,
252
+ };
253
+ // If the total number of bytes being uploaded is available, include
254
+ // it.
255
+ if (event.lengthComputable) {
256
+ progress.total = event.total;
257
+ }
258
+ // Send the event.
259
+ observer.next(progress);
260
+ };
261
+ // By default, register for load and error events.
262
+ xhr.addEventListener('load', onLoad);
263
+ xhr.addEventListener('error', onError);
264
+ // Progress events are only enabled if requested.
265
+ if (req.reportProgress) {
266
+ // Download progress is always enabled if requested.
267
+ xhr.addEventListener('progress', onDownProgress);
268
+ // Upload progress depends on whether there is a body to upload.
269
+ if (reqBody !== null && xhr.upload) {
270
+ xhr.upload.addEventListener('progress', onUpProgress);
271
+ }
272
+ }
273
+ // Fire the request, and notify the event stream that it was fired.
274
+ xhr.send(reqBody);
275
+ observer.next({ type: response_1.HttpEventType.Sent });
276
+ // This is the return from the Observable function, which is the
277
+ // request cancellation handler.
278
+ return () => {
279
+ // On a cancellation, remove all registered event listeners.
280
+ xhr.removeEventListener('error', onError);
281
+ xhr.removeEventListener('load', onLoad);
282
+ if (req.reportProgress) {
283
+ xhr.removeEventListener('progress', onDownProgress);
284
+ if (reqBody !== null && xhr.upload) {
285
+ xhr.upload.removeEventListener('progress', onUpProgress);
286
+ }
287
+ }
288
+ // Finally, abort the in-flight request.
289
+ xhr.abort();
290
+ };
291
+ });
292
+ }
293
+ };
294
+ exports.HttpXhrBackend = HttpXhrBackend;
295
+ exports.HttpXhrBackend = HttpXhrBackend = tslib_1.__decorate([
296
+ (0, di_1.Injectable)(),
297
+ tslib_1.__metadata("design:paramtypes", [XhrFactory])
298
+ ], HttpXhrBackend);
299
299
  //# sourceMappingURL=xhr.js.map
package/dist/xhr.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"xhr.js","sourceRoot":"","sources":["../src/xhr.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,qCAAwC;AACxC,+BAA0C;AAG1C,uCAAsC;AAEtC,yCAAiL;AAEjL,M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