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

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

initial commit

  • Property mode set to 100644
File size: 37.9 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 { HttpContext } from './context';
9import { HttpHeaders } from './headers';
10import { HttpParams } from './params';
11/**
12 * Determine whether the given HTTP method may include a body.
13 */
14function mightHaveBody(method) {
15 switch (method) {
16 case 'DELETE':
17 case 'GET':
18 case 'HEAD':
19 case 'OPTIONS':
20 case 'JSONP':
21 return false;
22 default:
23 return true;
24 }
25}
26/**
27 * Safely assert whether the given value is an ArrayBuffer.
28 *
29 * In some execution environments ArrayBuffer is not defined.
30 */
31function isArrayBuffer(value) {
32 return typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;
33}
34/**
35 * Safely assert whether the given value is a Blob.
36 *
37 * In some execution environments Blob is not defined.
38 */
39function isBlob(value) {
40 return typeof Blob !== 'undefined' && value instanceof Blob;
41}
42/**
43 * Safely assert whether the given value is a FormData instance.
44 *
45 * In some execution environments FormData is not defined.
46 */
47function isFormData(value) {
48 return typeof FormData !== 'undefined' && value instanceof FormData;
49}
50/**
51 * Safely assert whether the given value is a URLSearchParams instance.
52 *
53 * In some execution environments URLSearchParams is not defined.
54 */
55function isUrlSearchParams(value) {
56 return typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams;
57}
58/**
59 * An outgoing HTTP request with an optional typed body.
60 *
61 * `HttpRequest` represents an outgoing request, including URL, method,
62 * headers, body, and other request configuration options. Instances should be
63 * assumed to be immutable. To modify a `HttpRequest`, the `clone`
64 * method should be used.
65 *
66 * @publicApi
67 */
68export class HttpRequest {
69 constructor(method, url, third, fourth) {
70 this.url = url;
71 /**
72 * The request body, or `null` if one isn't set.
73 *
74 * Bodies are not enforced to be immutable, as they can include a reference to any
75 * user-defined data type. However, interceptors should take care to preserve
76 * idempotence by treating them as such.
77 */
78 this.body = null;
79 /**
80 * Whether this request should be made in a way that exposes progress events.
81 *
82 * Progress events are expensive (change detection runs on each event) and so
83 * they should only be requested if the consumer intends to monitor them.
84 */
85 this.reportProgress = false;
86 /**
87 * Whether this request should be sent with outgoing credentials (cookies).
88 */
89 this.withCredentials = false;
90 /**
91 * The expected response type of the server.
92 *
93 * This is used to parse the response appropriately before returning it to
94 * the requestee.
95 */
96 this.responseType = 'json';
97 this.method = method.toUpperCase();
98 // Next, need to figure out which argument holds the HttpRequestInit
99 // options, if any.
100 let options;
101 // Check whether a body argument is expected. The only valid way to omit
102 // the body argument is to use a known no-body method like GET.
103 if (mightHaveBody(this.method) || !!fourth) {
104 // Body is the third argument, options are the fourth.
105 this.body = (third !== undefined) ? third : null;
106 options = fourth;
107 }
108 else {
109 // No body required, options are the third argument. The body stays null.
110 options = third;
111 }
112 // If options have been passed, interpret them.
113 if (options) {
114 // Normalize reportProgress and withCredentials.
115 this.reportProgress = !!options.reportProgress;
116 this.withCredentials = !!options.withCredentials;
117 // Override default response type of 'json' if one is provided.
118 if (!!options.responseType) {
119 this.responseType = options.responseType;
120 }
121 // Override headers if they're provided.
122 if (!!options.headers) {
123 this.headers = options.headers;
124 }
125 if (!!options.context) {
126 this.context = options.context;
127 }
128 if (!!options.params) {
129 this.params = options.params;
130 }
131 }
132 // If no headers have been passed in, construct a new HttpHeaders instance.
133 if (!this.headers) {
134 this.headers = new HttpHeaders();
135 }
136 // If no context have been passed in, construct a new HttpContext instance.
137 if (!this.context) {
138 this.context = new HttpContext();
139 }
140 // If no parameters have been passed in, construct a new HttpUrlEncodedParams instance.
141 if (!this.params) {
142 this.params = new HttpParams();
143 this.urlWithParams = url;
144 }
145 else {
146 // Encode the parameters to a string in preparation for inclusion in the URL.
147 const params = this.params.toString();
148 if (params.length === 0) {
149 // No parameters, the visible URL is just the URL given at creation time.
150 this.urlWithParams = url;
151 }
152 else {
153 // Does the URL already have query parameters? Look for '?'.
154 const qIdx = url.indexOf('?');
155 // There are 3 cases to handle:
156 // 1) No existing parameters -> append '?' followed by params.
157 // 2) '?' exists and is followed by existing query string ->
158 // append '&' followed by params.
159 // 3) '?' exists at the end of the url -> append params directly.
160 // This basically amounts to determining the character, if any, with
161 // which to join the URL and parameters.
162 const sep = qIdx === -1 ? '?' : (qIdx < url.length - 1 ? '&' : '');
163 this.urlWithParams = url + sep + params;
164 }
165 }
166 }
167 /**
168 * Transform the free-form body into a serialized format suitable for
169 * transmission to the server.
170 */
171 serializeBody() {
172 // If no body is present, no need to serialize it.
173 if (this.body === null) {
174 return null;
175 }
176 // Check whether the body is already in a serialized form. If so,
177 // it can just be returned directly.
178 if (isArrayBuffer(this.body) || isBlob(this.body) || isFormData(this.body) ||
179 isUrlSearchParams(this.body) || typeof this.body === 'string') {
180 return this.body;
181 }
182 // Check whether the body is an instance of HttpUrlEncodedParams.
183 if (this.body instanceof HttpParams) {
184 return this.body.toString();
185 }
186 // Check whether the body is an object or array, and serialize with JSON if so.
187 if (typeof this.body === 'object' || typeof this.body === 'boolean' ||
188 Array.isArray(this.body)) {
189 return JSON.stringify(this.body);
190 }
191 // Fall back on toString() for everything else.
192 return this.body.toString();
193 }
194 /**
195 * Examine the body and attempt to infer an appropriate MIME type
196 * for it.
197 *
198 * If no such type can be inferred, this method will return `null`.
199 */
200 detectContentTypeHeader() {
201 // An empty body has no content type.
202 if (this.body === null) {
203 return null;
204 }
205 // FormData bodies rely on the browser's content type assignment.
206 if (isFormData(this.body)) {
207 return null;
208 }
209 // Blobs usually have their own content type. If it doesn't, then
210 // no type can be inferred.
211 if (isBlob(this.body)) {
212 return this.body.type || null;
213 }
214 // Array buffers have unknown contents and thus no type can be inferred.
215 if (isArrayBuffer(this.body)) {
216 return null;
217 }
218 // Technically, strings could be a form of JSON data, but it's safe enough
219 // to assume they're plain strings.
220 if (typeof this.body === 'string') {
221 return 'text/plain';
222 }
223 // `HttpUrlEncodedParams` has its own content-type.
224 if (this.body instanceof HttpParams) {
225 return 'application/x-www-form-urlencoded;charset=UTF-8';
226 }
227 // Arrays, objects, boolean and numbers will be encoded as JSON.
228 if (typeof this.body === 'object' || typeof this.body === 'number' ||
229 typeof this.body === 'boolean') {
230 return 'application/json';
231 }
232 // No type could be inferred.
233 return null;
234 }
235 clone(update = {}) {
236 var _a;
237 // For method, url, and responseType, take the current value unless
238 // it is overridden in the update hash.
239 const method = update.method || this.method;
240 const url = update.url || this.url;
241 const responseType = update.responseType || this.responseType;
242 // The body is somewhat special - a `null` value in update.body means
243 // whatever current body is present is being overridden with an empty
244 // body, whereas an `undefined` value in update.body implies no
245 // override.
246 const body = (update.body !== undefined) ? update.body : this.body;
247 // Carefully handle the boolean options to differentiate between
248 // `false` and `undefined` in the update args.
249 const withCredentials = (update.withCredentials !== undefined) ? update.withCredentials : this.withCredentials;
250 const reportProgress = (update.reportProgress !== undefined) ? update.reportProgress : this.reportProgress;
251 // Headers and params may be appended to if `setHeaders` or
252 // `setParams` are used.
253 let headers = update.headers || this.headers;
254 let params = update.params || this.params;
255 // Pass on context if needed
256 const context = (_a = update.context) !== null && _a !== void 0 ? _a : this.context;
257 // Check whether the caller has asked to add headers.
258 if (update.setHeaders !== undefined) {
259 // Set every requested header.
260 headers =
261 Object.keys(update.setHeaders)
262 .reduce((headers, name) => headers.set(name, update.setHeaders[name]), headers);
263 }
264 // Check whether the caller has asked to set params.
265 if (update.setParams) {
266 // Set every requested param.
267 params = Object.keys(update.setParams)
268 .reduce((params, param) => params.set(param, update.setParams[param]), params);
269 }
270 // Finally, construct the new HttpRequest using the pieces from above.
271 return new HttpRequest(method, url, body, {
272 params,
273 headers,
274 context,
275 reportProgress,
276 responseType,
277 withCredentials,
278 });
279 }
280}
281//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVxdWVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL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ICAgICAgLy8gU2V0IGV2ZXJ5IHJlcXVlc3RlZCBwYXJhbS5cbiAgICAgIHBhcmFtcyA9IE9iamVjdC5rZXlzKHVwZGF0ZS5zZXRQYXJhbXMpXG4gICAgICAgICAgICAgICAgICAgLnJlZHVjZSgocGFyYW1zLCBwYXJhbSkgPT4gcGFyYW1zLnNldChwYXJhbSwgdXBkYXRlLnNldFBhcmFtcyFbcGFyYW1dKSwgcGFyYW1zKTtcbiAgICB9XG5cbiAgICAvLyBGaW5hbGx5LCBjb25zdHJ1Y3QgdGhlIG5ldyBIdHRwUmVxdWVzdCB1c2luZyB0aGUgcGllY2VzIGZyb20gYWJvdmUuXG4gICAgcmV0dXJuIG5ldyBIdHRwUmVxdWVzdChtZXRob2QsIHVybCwgYm9keSwge1xuICAgICAgcGFyYW1zLFxuICAgICAgaGVhZGVycyxcbiAgICAgIGNvbnRleHQsXG4gICAgICByZXBvcnRQcm9ncmVzcyxcbiAgICAgIHJlc3BvbnNlVHlwZSxcbiAgICAgIHdpdGhDcmVkZW50aWFscyxcbiAgICB9KTtcbiAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.