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

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

initial commit

  • Property mode set to 100644
File size: 25.2 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 */
8/**
9 * Represents the header configuration options for an HTTP request.
10 * Instances are immutable. Modifying methods return a cloned
11 * instance with the change. The original object is never changed.
12 *
13 * @publicApi
14 */
15export class HttpHeaders {
16 /** Constructs a new HTTP header object with the given values.*/
17 constructor(headers) {
18 /**
19 * Internal map of lowercased header names to the normalized
20 * form of the name (the form seen first).
21 */
22 this.normalizedNames = new Map();
23 /**
24 * Queued updates to be materialized the next initialization.
25 */
26 this.lazyUpdate = null;
27 if (!headers) {
28 this.headers = new Map();
29 }
30 else if (typeof headers === 'string') {
31 this.lazyInit = () => {
32 this.headers = new Map();
33 headers.split('\n').forEach(line => {
34 const index = line.indexOf(':');
35 if (index > 0) {
36 const name = line.slice(0, index);
37 const key = name.toLowerCase();
38 const value = line.slice(index + 1).trim();
39 this.maybeSetNormalizedName(name, key);
40 if (this.headers.has(key)) {
41 this.headers.get(key).push(value);
42 }
43 else {
44 this.headers.set(key, [value]);
45 }
46 }
47 });
48 };
49 }
50 else {
51 this.lazyInit = () => {
52 this.headers = new Map();
53 Object.keys(headers).forEach(name => {
54 let values = headers[name];
55 const key = name.toLowerCase();
56 if (typeof values === 'string') {
57 values = [values];
58 }
59 if (values.length > 0) {
60 this.headers.set(key, values);
61 this.maybeSetNormalizedName(name, key);
62 }
63 });
64 };
65 }
66 }
67 /**
68 * Checks for existence of a given header.
69 *
70 * @param name The header name to check for existence.
71 *
72 * @returns True if the header exists, false otherwise.
73 */
74 has(name) {
75 this.init();
76 return this.headers.has(name.toLowerCase());
77 }
78 /**
79 * Retrieves the first value of a given header.
80 *
81 * @param name The header name.
82 *
83 * @returns The value string if the header exists, null otherwise
84 */
85 get(name) {
86 this.init();
87 const values = this.headers.get(name.toLowerCase());
88 return values && values.length > 0 ? values[0] : null;
89 }
90 /**
91 * Retrieves the names of the headers.
92 *
93 * @returns A list of header names.
94 */
95 keys() {
96 this.init();
97 return Array.from(this.normalizedNames.values());
98 }
99 /**
100 * Retrieves a list of values for a given header.
101 *
102 * @param name The header name from which to retrieve values.
103 *
104 * @returns A string of values if the header exists, null otherwise.
105 */
106 getAll(name) {
107 this.init();
108 return this.headers.get(name.toLowerCase()) || null;
109 }
110 /**
111 * Appends a new value to the existing set of values for a header
112 * and returns them in a clone of the original instance.
113 *
114 * @param name The header name for which to append the values.
115 * @param value The value to append.
116 *
117 * @returns A clone of the HTTP headers object with the value appended to the given header.
118 */
119 append(name, value) {
120 return this.clone({ name, value, op: 'a' });
121 }
122 /**
123 * Sets or modifies a value for a given header in a clone of the original instance.
124 * If the header already exists, its value is replaced with the given value
125 * in the returned object.
126 *
127 * @param name The header name.
128 * @param value The value or values to set or overide for the given header.
129 *
130 * @returns A clone of the HTTP headers object with the newly set header value.
131 */
132 set(name, value) {
133 return this.clone({ name, value, op: 's' });
134 }
135 /**
136 * Deletes values for a given header in a clone of the original instance.
137 *
138 * @param name The header name.
139 * @param value The value or values to delete for the given header.
140 *
141 * @returns A clone of the HTTP headers object with the given value deleted.
142 */
143 delete(name, value) {
144 return this.clone({ name, value, op: 'd' });
145 }
146 maybeSetNormalizedName(name, lcName) {
147 if (!this.normalizedNames.has(lcName)) {
148 this.normalizedNames.set(lcName, name);
149 }
150 }
151 init() {
152 if (!!this.lazyInit) {
153 if (this.lazyInit instanceof HttpHeaders) {
154 this.copyFrom(this.lazyInit);
155 }
156 else {
157 this.lazyInit();
158 }
159 this.lazyInit = null;
160 if (!!this.lazyUpdate) {
161 this.lazyUpdate.forEach(update => this.applyUpdate(update));
162 this.lazyUpdate = null;
163 }
164 }
165 }
166 copyFrom(other) {
167 other.init();
168 Array.from(other.headers.keys()).forEach(key => {
169 this.headers.set(key, other.headers.get(key));
170 this.normalizedNames.set(key, other.normalizedNames.get(key));
171 });
172 }
173 clone(update) {
174 const clone = new HttpHeaders();
175 clone.lazyInit =
176 (!!this.lazyInit && this.lazyInit instanceof HttpHeaders) ? this.lazyInit : this;
177 clone.lazyUpdate = (this.lazyUpdate || []).concat([update]);
178 return clone;
179 }
180 applyUpdate(update) {
181 const key = update.name.toLowerCase();
182 switch (update.op) {
183 case 'a':
184 case 's':
185 let value = update.value;
186 if (typeof value === 'string') {
187 value = [value];
188 }
189 if (value.length === 0) {
190 return;
191 }
192 this.maybeSetNormalizedName(update.name, key);
193 const base = (update.op === 'a' ? this.headers.get(key) : undefined) || [];
194 base.push(...value);
195 this.headers.set(key, base);
196 break;
197 case 'd':
198 const toDelete = update.value;
199 if (!toDelete) {
200 this.headers.delete(key);
201 this.normalizedNames.delete(key);
202 }
203 else {
204 let existing = this.headers.get(key);
205 if (!existing) {
206 return;
207 }
208 existing = existing.filter(value => toDelete.indexOf(value) === -1);
209 if (existing.length === 0) {
210 this.headers.delete(key);
211 this.normalizedNames.delete(key);
212 }
213 else {
214 this.headers.set(key, existing);
215 }
216 }
217 break;
218 }
219 }
220 /**
221 * @internal
222 */
223 forEach(fn) {
224 this.init();
225 Array.from(this.normalizedNames.keys())
226 .forEach(key => fn(this.normalizedNames.get(key), this.headers.get(key)));
227 }
228}
229//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVhZGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbW1vbi9odHRwL3NyYy9oZWFkZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQVFIOzs7Ozs7R0FNRztBQUNILE1BQU0sT0FBTyxXQUFXO0lBd0J0QixpRUFBaUU7SUFFakUsWUFBWSxPQUFvR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RyaW5nW10+KCk7XG4gICAgICAgIGhlYWRlcnMuc3BsaXQoJ1xcbicpLmZvckVhY2gobGluZSA9PiB7XG4gICAgICAgICAgY29uc3QgaW5kZXggPSBsaW5lLmluZGV4T2YoJzonKTtcbiAgICAgICAgICBpZiAoaW5kZXggPiAwKSB7XG4gICAgICAgICAgICBjb25zdCBuYW1lID0gbGluZS5zbGljZSgwLCBpbmRleCk7XG4gICAgICAgICAgICBjb25zdCBrZXkgPSBuYW1lLnRvTG93ZXJDYXNlKCk7XG4gICAgICAgICAgICBjb25zdCB2YWx1ZSA9IGxpbmUuc2xpY2UoaW5kZXggKyAxKS50cmltKCk7XG4gICAgICAgICAgICB0aGlzLm1heWJlU2V0Tm9ybWFsaXplZE5hbWUobmFtZSwga2V5KTtcbiAgICAgICAgICAgIGlmICh0aGlzLmhlYWRlcnMuaGFzKGtleSkpIHtcbiAgICAgICAgICAgICAgdGhpcy5oZWFkZXJzLmdldChrZXkpIS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHRoaXMuaGVhZGVycy5zZXQoa2V5LCBbdmFsdWVdKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfTtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhpcy5sYXp5SW5pdCA9ICgpID0+IHtcbiAgICAgICAgdGhpcy5oZWFkZXJzID0gbmV3IE1hcDxzdHJpbmcsIHN0cmluZ1tdPigpO1xuICAgICAgICBPYmplY3Qua2V5cyhoZWFkZXJzKS5mb3JFYWNoKG5hbWUgPT4ge1xuICAgICAgICAgIGxldCB2YWx1ZXM6IHN0cmluZ3xzdHJpbmdbXSA9IGhlYWRlcnNbbmFtZV07XG4gICAgICAgICAgY29uc3Qga2V5ID0gbmFtZS50b0xvd2VyQ2FzZSgpO1xuICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWVzID09PSAnc3RyaW5nJykge1xuICAgICAgICA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XRjaCAodXBkYXRlLm9wKSB7XG4gICAgICBjYXNlICdhJzpcbiAgICAgIGNhc2UgJ3MnOlxuICAgICAgICBsZXQgdmFsdWUgPSB1cGRhdGUudmFsdWUhO1xuICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAnc3RyaW5nJykge1xuICAgICAgICAgIHZhbHVlID0gW3ZhbHVlXTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodmFsdWUubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMubWF5YmVTZXROb3JtYWxpemVkTmFtZSh1cGRhdGUubmFtZSwga2V5KTtcbiAgICAgICAgY29uc3QgYmFzZSA9ICh1cGRhdGUub3AgPT09ICdhJyA/IHRoaXMuaGVhZGVycy5nZXQoa2V5KSA6IHVuZGVmaW5lZCkgfHwgW107XG4gICAgICAgIGJhc2UucHVzaCguLi52YWx1ZSk7XG4gICAgICAgIHRoaXMuaGVhZGVycy5zZXQoa2V5LCBiYXNlKTtcbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlICdkJzpcbiAgICAgICAgY29uc3QgdG9EZWxldGUgPSB1cGRhdGUudmFsdWUgYXMgc3RyaW5nIHwgdW5kZWZpbmVkO1xuICAgICAgICBpZiAoIXRvRGVsZXRlKSB7XG4gICAgICAgICAgdGhpcy5oZWFkZXJzLmRlbGV0ZShrZXkpO1xuICAgICAgICAgIHRoaXMubm9ybWFsaXplZE5hbWVzLmRlbGV0ZShrZXkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGxldCBleGlzdGluZyA9IHRoaXMuaGVhZGVycy5nZXQoa2V5KTtcbiAgICAgICAgICBpZiAoIWV4aXN0aW5nKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgfVxuICAgICAgICAgIGV4aXN0aW5nID0gZXhpc3RpbmcuZmlsdGVyKHZhbHVlID0+IHRvRGVsZXRlLmluZGV4T2YodmFsdWUpID09PSAtMSk7XG4gICAgICAgICAgaWYgKGV4aXN0aW5nLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5oZWFkZXJzLmRlbGV0ZShrZXkpO1xuICAgICAgICAgICAgdGhpcy5ub3JtYWxpemVkTmFtZXMuZGVsZXRlKGtleSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuaGVhZGVycy5zZXQoa2V5LCBleGlzdGluZyk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGJyZWFrO1xuICAgIH1cbiAgfVxuXG4gIC8qKlxuICAgKiBAaW50ZXJuYWxcbiAgICovXG4gIGZvckVhY2goZm46IChuYW1lOiBzdHJpbmcsIHZhbHVlczogc3RyaW5nW10pID0+IHZvaWQpIHtcbiAgICB0aGlzLmluaXQoKTtcbiAgICBBcnJheS5mcm9tKHRoaXMubm9ybWFsaXplZE5hbWVzLmtleXMoKSlcbiAgICAgICAgLmZvckVhY2goa2V5ID0+IGZuKHRoaXMubm9ybWFsaXplZE5hbWVzLmdldChrZXkpISwgdGhpcy5oZWFkZXJzLmdldChrZXkpISkpO1xuICB9XG59XG4iXX0=
Note: See TracBrowser for help on using the repository browser.