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