source: trip-planner-front/node_modules/@angular/common/esm2015/http/src/xhr.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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