@d1g1tal/transportr 1.3.2 → 1.4.1
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.
- package/dist/transportr.js +1510 -1640
- package/dist/transportr.min.js +2 -2
- package/dist/transportr.min.js.map +4 -4
- package/package.json +3 -4
- package/src/abort-signal.js +17 -70
- package/src/constants.js +12 -1
- package/src/transportr.js +30 -71
package/dist/transportr.js
CHANGED
|
@@ -23,54 +23,8 @@ var Transportr = (() => {
|
|
|
23
23
|
default: () => Transportr
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
// node_modules/@d1g1tal/collections/src/set-multi-map.js
|
|
27
|
-
var SetMultiMap = class extends Map {
|
|
28
|
-
/**
|
|
29
|
-
* Adds a new element with a specified key and value to the SetMultiMap.
|
|
30
|
-
* If an element with the same key already exists, the value will be added to the underlying {@link Set}.
|
|
31
|
-
* If the value already exists in the {@link Set}, it will not be added again.
|
|
32
|
-
*
|
|
33
|
-
* @param {K} key The key to set.
|
|
34
|
-
* @param {V} value The value to add to the SetMultiMap
|
|
35
|
-
* @returns {SetMultiMap<K, V>} The SetMultiMap with the updated key and value.
|
|
36
|
-
*/
|
|
37
|
-
set(key, value) {
|
|
38
|
-
super.set(key, (super.get(key) ?? /* @__PURE__ */ new Set()).add(value));
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Checks if a specific key has a specific value.
|
|
43
|
-
*
|
|
44
|
-
* @param {K} key The key to check.
|
|
45
|
-
* @param {V} value The value to check.
|
|
46
|
-
* @returns {boolean} True if the key has the value, false otherwise.
|
|
47
|
-
*/
|
|
48
|
-
hasValue(key, value) {
|
|
49
|
-
const values = super.get(key);
|
|
50
|
-
return values ? values.has(value) : false;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Removes a specific value from a specific key.
|
|
54
|
-
*
|
|
55
|
-
* @param {K} key The key to remove the value from.
|
|
56
|
-
* @param {V} value The value to remove.
|
|
57
|
-
* @returns {boolean} True if the value was removed, false otherwise.
|
|
58
|
-
*/
|
|
59
|
-
deleteValue(key, value) {
|
|
60
|
-
const values = super.get(key);
|
|
61
|
-
if (values) {
|
|
62
|
-
return values.delete(value);
|
|
63
|
-
}
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
get [Symbol.toStringTag]() {
|
|
67
|
-
return "SetMultiMap";
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var set_multi_map_default = SetMultiMap;
|
|
71
|
-
|
|
72
26
|
// node_modules/@d1g1tal/subscribr/node_modules/@d1g1tal/collections/src/set-multi-map.js
|
|
73
|
-
var
|
|
27
|
+
var SetMultiMap = class extends Map {
|
|
74
28
|
/**
|
|
75
29
|
* Adds a new element with a specified key and value to the SetMultiMap. If an element with the same key already exists, the value will be added to the underlying {@link Set}.
|
|
76
30
|
*
|
|
@@ -151,7 +105,7 @@ var Transportr = (() => {
|
|
|
151
105
|
/** @type {SetMultiMap<string, ContextEventHandler>} */
|
|
152
106
|
#subscribers;
|
|
153
107
|
constructor() {
|
|
154
|
-
this.#subscribers = new
|
|
108
|
+
this.#subscribers = new SetMultiMap();
|
|
155
109
|
}
|
|
156
110
|
/**
|
|
157
111
|
* Subscribe to an event
|
|
@@ -211,1994 +165,1951 @@ var Transportr = (() => {
|
|
|
211
165
|
}
|
|
212
166
|
};
|
|
213
167
|
|
|
214
|
-
// src/http-
|
|
215
|
-
var
|
|
216
|
-
/** @type {ResponseBody} */
|
|
217
|
-
#entity;
|
|
218
|
-
/** @type {ResponseStatus} */
|
|
219
|
-
#responseStatus;
|
|
168
|
+
// src/http-request-methods.js
|
|
169
|
+
var HttpRequestMethod = {
|
|
220
170
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
171
|
+
* The OPTIONS method represents a request for information about the communication options available on the
|
|
172
|
+
* request/response chain identified by the Request-URI. This method allows the client to determine the options and/or
|
|
173
|
+
* requirements associated with a resource, or the capabilities of a server, without implying a resource action or
|
|
174
|
+
* initiating a resource retrieval.
|
|
175
|
+
*
|
|
176
|
+
* Responses to this method are not cacheable.
|
|
177
|
+
*
|
|
178
|
+
* If the OPTIONS request includes an entity-body (as indicated by the presence of Content-Length or
|
|
179
|
+
* Transfer-Encoding), then the media type MUST be indicated by a Content-Type field. Although this specification does
|
|
180
|
+
* not define any use for such a body, future extensions to HTTP might use the OPTIONS body to make more detailed
|
|
181
|
+
* queries on the server. A server that does not support such an extension MAY discard the request body.
|
|
182
|
+
*
|
|
183
|
+
* If the Request-URI is an asterisk ("*"), the OPTIONS request is intended to apply to the server in general rather
|
|
184
|
+
* than to a specific resource. Since a server's communication options typically depend on the resource, the "*"
|
|
185
|
+
* request is only useful as a "ping" or "no-op" type of method, it does nothing beyond allowing the client to test the
|
|
186
|
+
* capabilities of the server. For example, this can be used to test a proxy for HTTP/1.1 compliance (or lack thereof).
|
|
187
|
+
*
|
|
188
|
+
* If the Request-URI is not an asterisk, the OPTIONS request applies only to the options that are available when
|
|
189
|
+
* communicating with that resource.
|
|
190
|
+
*
|
|
191
|
+
* A 200 response SHOULD include any header fields that indicate optional features implemented by the server and
|
|
192
|
+
* applicable to that resource (e.g., Allow), possibly including extensions not defined by this specification. The
|
|
193
|
+
* response body, if any, SHOULD also include information about the communication options. The format for such a body
|
|
194
|
+
* is not defined by this specification, but might be defined by future extensions to HTTP. Content negotiation MAY be
|
|
195
|
+
* used to select the appropriate response format. If no response body is included, the response MUST include a
|
|
196
|
+
* Content-Length field with a field-value of "0".
|
|
197
|
+
*
|
|
198
|
+
* The Max-Forwards request-header field MAY be used to target a specific proxy in the request chain. When a proxy
|
|
199
|
+
* receives an OPTIONS request on an absoluteURI for which request forwarding is permitted, the proxy MUST check for a
|
|
200
|
+
* Max-Forwards field. If the Max-Forwards field-value is zero ("0"), the proxy MUST NOT forward the message, instead,
|
|
201
|
+
* the proxy SHOULD respond with its own communication options. If the Max-Forwards field-value is an integer greater
|
|
202
|
+
* than zero, the proxy MUST decrement the field-value when it forwards the request. If no Max-Forwards field is
|
|
203
|
+
* present in the request, then the forwarded request MUST NOT include a Max-Forwards field.
|
|
226
204
|
*/
|
|
227
|
-
|
|
228
|
-
super(message, { cause });
|
|
229
|
-
this.#entity = entity;
|
|
230
|
-
this.#responseStatus = status;
|
|
231
|
-
}
|
|
205
|
+
OPTIONS: "OPTIONS",
|
|
232
206
|
/**
|
|
233
|
-
*
|
|
207
|
+
* The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If
|
|
208
|
+
* the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in
|
|
209
|
+
* the response and not the source text of the process, unless that text happens to be the output of the process.
|
|
234
210
|
*
|
|
235
|
-
*
|
|
211
|
+
* The semantics of the GET method change to a "conditional GET" if the request message includes an If-Modified-Since;
|
|
212
|
+
* If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the
|
|
213
|
+
* entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET
|
|
214
|
+
* method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring
|
|
215
|
+
* multiple requests or transferring data already held by the client.
|
|
216
|
+
*
|
|
217
|
+
* The semantics of the GET method change to a "partial GET" if the request message includes a Range header field. A
|
|
218
|
+
* partial GET requests that only part of the entity be transferred, as described in section 14.35. The partial GET
|
|
219
|
+
* method is intended to reduce unnecessary network usage by allowing partially-retrieved entities to be completed
|
|
220
|
+
* without transferring data already held by the client.
|
|
221
|
+
*
|
|
222
|
+
* The response to a GET request is cacheable if and only if it meets the requirements for HTTP caching described in
|
|
223
|
+
* section 13.
|
|
224
|
+
*
|
|
225
|
+
* See section 15.1.3 for security considerations when used for forms.
|
|
236
226
|
*/
|
|
237
|
-
|
|
238
|
-
return this.#entity;
|
|
239
|
-
}
|
|
227
|
+
GET: "GET",
|
|
240
228
|
/**
|
|
241
|
-
*
|
|
229
|
+
* The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The
|
|
230
|
+
* meta information contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information
|
|
231
|
+
* sent in response to a GET request. This method can be used for obtaining meta information about the entity implied by
|
|
232
|
+
* the request without transferring the entity-body itself. This method is often used for testing hypertext links for
|
|
233
|
+
* validity, accessibility, and recent modification.
|
|
242
234
|
*
|
|
243
|
-
*
|
|
235
|
+
* The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be
|
|
236
|
+
* used to update a previously cached entity from that resource. If the new field values indicate that the cached
|
|
237
|
+
* entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or
|
|
238
|
+
* Last-Modified), then the cache MUST treat the cache entry as stale.
|
|
244
239
|
*/
|
|
245
|
-
|
|
246
|
-
return this.#responseStatus?.code;
|
|
247
|
-
}
|
|
240
|
+
HEAD: "HEAD",
|
|
248
241
|
/**
|
|
249
|
-
*
|
|
242
|
+
* The POST method is used to request that the origin server accept the entity enclosed in the request as a new
|
|
243
|
+
* subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform
|
|
244
|
+
* method to cover the following functions:
|
|
245
|
+
* <ul>
|
|
246
|
+
* <li>Annotation of existing resources,</li>
|
|
247
|
+
* <li>Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles,</li>
|
|
248
|
+
* <li>Providing a block of data, such as the result of submitting a form, to a data-handling process,</li>
|
|
249
|
+
* <li>Extending a database through an append operation.</li>
|
|
250
|
+
* </ul>
|
|
250
251
|
*
|
|
251
|
-
*
|
|
252
|
+
* The actual function performed by the POST method is determined by the server and is usually dependent on the
|
|
253
|
+
* Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory
|
|
254
|
+
* containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a
|
|
255
|
+
* database.
|
|
256
|
+
*
|
|
257
|
+
* The action performed by the POST method might not result in a resource that can be identified by a URI. In this
|
|
258
|
+
* case, either 200 (OK) or 204 (No Content) is the appropriate response status, depending on whether or not the
|
|
259
|
+
* response includes an entity that describes the result.
|
|
260
|
+
*
|
|
261
|
+
* If a resource has been created on the origin server, the response SHOULD be 201 (Created) and contain an entity
|
|
262
|
+
* which describes the status of the request and refers to the new resource, and a Location header (see section 14.30).
|
|
263
|
+
*
|
|
264
|
+
* Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header
|
|
265
|
+
* fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.
|
|
266
|
+
*
|
|
267
|
+
* POST requests MUST obey the message transmission requirements set out in section 8.2.
|
|
268
|
+
*
|
|
269
|
+
* See section 15.1.3 for security considerations.
|
|
252
270
|
*/
|
|
253
|
-
|
|
254
|
-
return this.#responseStatus?.text;
|
|
255
|
-
}
|
|
256
|
-
get name() {
|
|
257
|
-
return "HttpError";
|
|
258
|
-
}
|
|
271
|
+
POST: "POST",
|
|
259
272
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
273
|
+
* The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers
|
|
274
|
+
* to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing
|
|
275
|
+
* on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being
|
|
276
|
+
* defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If
|
|
277
|
+
* a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an
|
|
278
|
+
* existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate
|
|
279
|
+
* successful completion of the request. If the resource could not be created or modified with the Request-URI, an
|
|
280
|
+
* appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST
|
|
281
|
+
* \NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a
|
|
282
|
+
* 501 (Not Implemented) response in such cases.
|
|
262
283
|
*
|
|
263
|
-
*
|
|
284
|
+
* If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those
|
|
285
|
+
* entries SHOULD be treated as stale. Responses to this method are not cacheable.
|
|
286
|
+
*
|
|
287
|
+
* The fundamental difference between the POST and PUT requests is reflected in the different meaning of the
|
|
288
|
+
* Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource
|
|
289
|
+
* might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations.
|
|
290
|
+
* In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what
|
|
291
|
+
* URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires
|
|
292
|
+
* that the request be applied to a different URI, it MUST send a 301 (Moved Permanently) response, the user agent MAY
|
|
293
|
+
* then make its own decision regarding whether or not to redirect the request.
|
|
294
|
+
*
|
|
295
|
+
* A single resource MAY be identified by many different URIs. For example, an article might have a URI for identifying
|
|
296
|
+
* "the current version" which is separate from the URI identifying each particular version. In this case, a PUT
|
|
297
|
+
* request on a general URI might result in several other URIs being defined by the origin server.
|
|
298
|
+
*
|
|
299
|
+
* HTTP/1.1 does not define how a PUT method affects the state of an origin server.
|
|
300
|
+
*
|
|
301
|
+
* PUT requests MUST obey the message transmission requirements set out in section 8.2.
|
|
302
|
+
*
|
|
303
|
+
* Unless otherwise specified for a particular entity-header, the entity-headers in the PUT request SHOULD be applied
|
|
304
|
+
* to the resource created or modified by the PUT.
|
|
264
305
|
*/
|
|
265
|
-
|
|
266
|
-
return "HttpError";
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
// src/http-media-type.js
|
|
271
|
-
var HttpMediaType = {
|
|
272
|
-
/** Advanced Audio Coding (AAC) */
|
|
273
|
-
AAC: "audio/aac",
|
|
274
|
-
/** AbiWord */
|
|
275
|
-
ABW: "application/x-abiword",
|
|
276
|
-
/** Archive document (multiple files embedded) */
|
|
277
|
-
ARC: "application/x-freearc",
|
|
278
|
-
/** AVIF image */
|
|
279
|
-
AVIF: "image/avif",
|
|
280
|
-
/** Audio Video Interleave (AVI) */
|
|
281
|
-
AVI: "video/x-msvideo",
|
|
282
|
-
/** Amazon Kindle eBook format */
|
|
283
|
-
AZW: "application/vnd.amazon.ebook",
|
|
284
|
-
/** Binary Data */
|
|
285
|
-
BIN: "application/octet-stream",
|
|
286
|
-
/** Windows OS/2 Bitmap Graphics */
|
|
287
|
-
BMP: "image/bmp",
|
|
288
|
-
/** Bzip Archive */
|
|
289
|
-
BZIP: "application/x-bzip",
|
|
290
|
-
/** Bzip2 Archive */
|
|
291
|
-
BZIP2: "application/x-bzip2",
|
|
292
|
-
/** CD audio */
|
|
293
|
-
CDA: "application/x-cdf",
|
|
294
|
-
/** C Shell Script */
|
|
295
|
-
CSH: "application/x-csh",
|
|
296
|
-
/** Cascading Style Sheets (CSS) */
|
|
297
|
-
CSS: "text/css",
|
|
298
|
-
/** Comma-Separated Values */
|
|
299
|
-
CSV: "text/csv",
|
|
300
|
-
/** Microsoft Office Word Document */
|
|
301
|
-
DOC: "application/msword",
|
|
302
|
-
/** Microsoft Office Word Document (OpenXML) */
|
|
303
|
-
DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
304
|
-
/** Microsoft Embedded OpenType */
|
|
305
|
-
EOT: "application/vnd.ms-fontobject",
|
|
306
|
-
/** Electronic Publication (EPUB) */
|
|
307
|
-
EPUB: "application/epub+zip",
|
|
308
|
-
/** GZip Compressed Archive */
|
|
309
|
-
GZIP: "application/gzip",
|
|
310
|
-
/** Graphics Interchange Format */
|
|
311
|
-
GIF: "image/gif",
|
|
312
|
-
/** HyperText Markup Language (HTML) */
|
|
313
|
-
HTML: "text/html",
|
|
314
|
-
/** Icon Format */
|
|
315
|
-
ICO: "image/vnd.microsoft.icon",
|
|
316
|
-
/** iCalendar Format */
|
|
317
|
-
ICS: "text/calendar",
|
|
318
|
-
/** Java Archive (JAR) */
|
|
319
|
-
JAR: "application/java-archive",
|
|
320
|
-
/** JPEG Image */
|
|
321
|
-
JPEG: "image/jpeg",
|
|
322
|
-
/** JavaScript */
|
|
323
|
-
JAVA_SCRIPT: "text/javascript",
|
|
324
|
-
/** JavaScript Object Notation Format (JSON) */
|
|
325
|
-
JSON: "application/json",
|
|
326
|
-
/** JavaScript Object Notation LD Format */
|
|
327
|
-
JSON_LD: "application/ld+json",
|
|
328
|
-
/** JavaScript Object Notation (JSON) Merge Patch */
|
|
329
|
-
JSON_MERGE_PATCH: "application/merge-patch+json",
|
|
330
|
-
/** Musical Instrument Digital Interface (MIDI) */
|
|
331
|
-
MID: "audio/midi",
|
|
332
|
-
/** Musical Instrument Digital Interface (MIDI) */
|
|
333
|
-
X_MID: "audio/x-midi",
|
|
334
|
-
/** MP3 Audio */
|
|
335
|
-
MP3: "audio/mpeg",
|
|
336
|
-
/** MPEG-4 Audio */
|
|
337
|
-
MP4A: "audio/mp4",
|
|
338
|
-
/** MPEG-4 Video */
|
|
339
|
-
MP4: "video/mp4",
|
|
340
|
-
/** MPEG Video */
|
|
341
|
-
MPEG: "video/mpeg",
|
|
342
|
-
/** Apple Installer Package */
|
|
343
|
-
MPKG: "application/vnd.apple.installer+xml",
|
|
344
|
-
/** OpenDocument Presentation Document */
|
|
345
|
-
ODP: "application/vnd.oasis.opendocument.presentation",
|
|
346
|
-
/** OpenDocument Spreadsheet Document */
|
|
347
|
-
ODS: "application/vnd.oasis.opendocument.spreadsheet",
|
|
348
|
-
/** OpenDocument Text Document */
|
|
349
|
-
ODT: "application/vnd.oasis.opendocument.text",
|
|
350
|
-
/** Ogg Audio */
|
|
351
|
-
OGA: "audio/ogg",
|
|
352
|
-
/** Ogg Video */
|
|
353
|
-
OGV: "video/ogg",
|
|
354
|
-
/** Ogg */
|
|
355
|
-
OGX: "application/ogg",
|
|
356
|
-
/** Opus audio */
|
|
357
|
-
OPUS: "audio/opus",
|
|
358
|
-
/** OpenType Font File */
|
|
359
|
-
OTF: "font/otf",
|
|
360
|
-
/** Portable Network Graphics (PNG) */
|
|
361
|
-
PNG: "image/png",
|
|
362
|
-
/** Adobe Portable Document Format */
|
|
363
|
-
PDF: "application/pdf",
|
|
364
|
-
/** Hypertext Preprocessor (Personal Home Page) */
|
|
365
|
-
PHP: "application/x-httpd-php",
|
|
366
|
-
/** Microsoft PowerPoint */
|
|
367
|
-
PPT: "application/vnd.ms-powerpoint",
|
|
368
|
-
/** Microsoft Office Presentation (OpenXML) */
|
|
369
|
-
PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
370
|
-
/** RAR Archive */
|
|
371
|
-
RAR: "application/vnd.rar",
|
|
372
|
-
/** Rich Text Format */
|
|
373
|
-
RTF: "application/rtf",
|
|
374
|
-
/** Bourne Shell Script */
|
|
375
|
-
SH: "application/x-sh",
|
|
376
|
-
/** Scalable Vector Graphics (SVG) */
|
|
377
|
-
SVG: "image/svg+xml",
|
|
378
|
-
/** Tape Archive (TAR) */
|
|
379
|
-
TAR: "application/x-tar",
|
|
380
|
-
/** Tagged Image File Format (TIFF) */
|
|
381
|
-
TIFF: "image/tiff",
|
|
382
|
-
/** MPEG transport stream */
|
|
383
|
-
TRANSPORT_STREAM: "video/mp2t",
|
|
384
|
-
/** TrueType Font */
|
|
385
|
-
TTF: "font/ttf",
|
|
386
|
-
/** Text, (generally ASCII or ISO 8859-n) */
|
|
387
|
-
TEXT: "text/plain",
|
|
388
|
-
/** Microsoft Visio */
|
|
389
|
-
VSD: "application/vnd.visio",
|
|
390
|
-
/** Waveform Audio Format (WAV) */
|
|
391
|
-
WAV: "audio/wav",
|
|
392
|
-
/** Open Web Media Project - Audio */
|
|
393
|
-
WEBA: "audio/webm",
|
|
394
|
-
/** Open Web Media Project - Video */
|
|
395
|
-
WEBM: "video/webm",
|
|
396
|
-
/** WebP Image */
|
|
397
|
-
WEBP: "image/webp",
|
|
398
|
-
/** Web Open Font Format */
|
|
399
|
-
WOFF: "font/woff",
|
|
400
|
-
/** Web Open Font Format */
|
|
401
|
-
WOFF2: "font/woff2",
|
|
402
|
-
/** Form - Encoded */
|
|
403
|
-
FORM: "application/x-www-form-urlencoded",
|
|
404
|
-
/** Multipart FormData */
|
|
405
|
-
MULTIPART_FORM_DATA: "multipart/form-data",
|
|
406
|
-
/** XHTML - The Extensible HyperText Markup Language */
|
|
407
|
-
XHTML: "application/xhtml+xml",
|
|
408
|
-
/** Microsoft Excel Document */
|
|
409
|
-
XLS: "application/vnd.ms-excel",
|
|
410
|
-
/** Microsoft Office Spreadsheet Document (OpenXML) */
|
|
411
|
-
XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
412
|
-
/** Extensible Markup Language (XML) */
|
|
413
|
-
XML: "application/xml",
|
|
414
|
-
/** XML User Interface Language (XUL) */
|
|
415
|
-
XUL: "application/vnd.mozilla.xul+xml",
|
|
416
|
-
/** Zip Archive */
|
|
417
|
-
ZIP: "application/zip",
|
|
418
|
-
/** 3GPP audio/video container */
|
|
419
|
-
"3GP": "video/3gpp",
|
|
420
|
-
/** 3GPP2 audio/video container */
|
|
421
|
-
"3G2": "video/3gpp2",
|
|
422
|
-
/** 7-Zip Archive */
|
|
423
|
-
"7Z": "application/x-7z-compressed"
|
|
424
|
-
};
|
|
425
|
-
var http_media_type_default = HttpMediaType;
|
|
426
|
-
|
|
427
|
-
// src/http-request-headers.js
|
|
428
|
-
var HttpRequestHeader = {
|
|
429
|
-
/**
|
|
430
|
-
* Content-Types that are acceptable for the response. See Content negotiation. Permanent.
|
|
431
|
-
*
|
|
432
|
-
* @example
|
|
433
|
-
* <code>Accept: text/plain</code>
|
|
434
|
-
*/
|
|
435
|
-
ACCEPT: "accept",
|
|
306
|
+
PUT: "PUT",
|
|
436
307
|
/**
|
|
437
|
-
*
|
|
308
|
+
* The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY
|
|
309
|
+
* be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the
|
|
310
|
+
* operation has been carried out, even if the status code returned from the origin server indicates that the action
|
|
311
|
+
* has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response
|
|
312
|
+
* is given, it intends to delete the resource or move it to an inaccessible location.
|
|
438
313
|
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
|
|
442
|
-
ACCEPT_CHARSET: "accept-charset",
|
|
443
|
-
/**
|
|
444
|
-
* List of acceptable encodings. See HTTP compression. Permanent.
|
|
314
|
+
* A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if
|
|
315
|
+
* the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not
|
|
316
|
+
* include an entity.
|
|
445
317
|
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
318
|
+
* If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those
|
|
319
|
+
* entries SHOULD be treated as stale. Responses to this method are not cacheable.
|
|
448
320
|
*/
|
|
449
|
-
|
|
321
|
+
DELETE: "DELETE",
|
|
450
322
|
/**
|
|
451
|
-
*
|
|
323
|
+
* The TRACE method is used to invoke a remote, application-layer loop- back of the request message. The final
|
|
324
|
+
* recipient of the request SHOULD reflect the message received back to the client as the entity-body of a 200 (OK)
|
|
325
|
+
* response. The final recipient is either the origin server or the first proxy or gateway to receive a Max-Forwards
|
|
326
|
+
* value of zero (0) in the request (see section 14.31). A TRACE request MUST NOT include an entity.
|
|
452
327
|
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Authentication credentials for HTTP authentication. Permanent.
|
|
328
|
+
* TRACE allows the client to see what is being received at the other end of the request chain and use that data for
|
|
329
|
+
* testing or diagnostic information. The value of the Via header field (section 14.45) is of particular interest,
|
|
330
|
+
* since it acts as a trace of the request chain. Use of the Max-Forwards header field allows the client to limit the
|
|
331
|
+
* length of the request chain, which is useful for testing a chain of proxies forwarding messages in an infinite loop.
|
|
459
332
|
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
333
|
+
* If the request is valid, the response SHOULD contain the entire request message in the entity-body, with a
|
|
334
|
+
* Content-Type of "message/http". Responses to this method MUST NOT be cached.
|
|
462
335
|
*/
|
|
463
|
-
|
|
336
|
+
TRACE: "TRACE",
|
|
464
337
|
/**
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
* @example
|
|
469
|
-
* <code>Cache-Control: no-cache</code>
|
|
338
|
+
* This specification reserves the method name CONNECT for use with a proxy that can dynamically switch to being a
|
|
339
|
+
* tunnel (e.g. SSL tunneling [44]).
|
|
470
340
|
*/
|
|
471
|
-
|
|
341
|
+
CONNECT: "CONNECT",
|
|
472
342
|
/**
|
|
473
|
-
*
|
|
343
|
+
* The PATCH method requests that a set of changes described in the
|
|
344
|
+
* request entity be applied to the resource identified by the Request-
|
|
345
|
+
* URI. The set of changes is represented in a format called a "patch
|
|
346
|
+
* document" identified by a media type. If the Request-URI does not
|
|
347
|
+
* point to an existing resource, the server MAY create a new resource,
|
|
348
|
+
* depending on the patch document type (whether it can logically modify
|
|
349
|
+
* a null resource) and permissions, etc.
|
|
474
350
|
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
*
|
|
351
|
+
* The difference between the PUT and PATCH requests is reflected in the
|
|
352
|
+
* way the server processes the enclosed entity to modify the resource
|
|
353
|
+
* identified by the Request-URI. In a PUT request, the enclosed entity
|
|
354
|
+
* is considered to be a modified version of the resource stored on the
|
|
355
|
+
* origin server, and the client is requesting that the stored version
|
|
356
|
+
* be replaced. With PATCH, however, the enclosed entity contains a set
|
|
357
|
+
* of instructions describing how a resource currently residing on the
|
|
358
|
+
* origin server should be modified to produce a new version. The PATCH
|
|
359
|
+
* method affects the resource identified by the Request-URI, and it
|
|
360
|
+
* also MAY have side effects on other resources; i.e., new resources
|
|
361
|
+
* may be created, or existing ones modified, by the application of a
|
|
362
|
+
* PATCH.
|
|
482
363
|
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*/
|
|
486
|
-
COOKIE: "cookie",
|
|
487
|
-
/**
|
|
488
|
-
* The length of the request body in octets (8-bit bytes). Permanent.
|
|
364
|
+
* PATCH is neither safe nor idempotent as defined by [RFC2616], Section
|
|
365
|
+
* 9.1.
|
|
489
366
|
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
*
|
|
367
|
+
* A PATCH request can be issued in such a way as to be idempotent,
|
|
368
|
+
* which also helps prevent bad outcomes from collisions between two
|
|
369
|
+
* PATCH requests on the same resource in a similar time frame.
|
|
370
|
+
* Collisions from multiple PATCH requests may be more dangerous than
|
|
371
|
+
* PUT collisions because some patch formats need to operate from a
|
|
372
|
+
* known base-point or else they will corrupt the resource. Clients
|
|
373
|
+
* using this kind of patch application SHOULD use a conditional request
|
|
374
|
+
* such that the request will fail if the resource has been updated
|
|
375
|
+
* since the client last accessed the resource. For example, the client
|
|
376
|
+
* can use a strong ETag [RFC2616] in an If-Match header on the PATCH
|
|
377
|
+
* request.
|
|
496
378
|
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* The MIME type of the body of the request (used with POST and PUT requests). Permanent.
|
|
503
|
-
* <code>Content-Type: application/x-www-form-urlencoded</code>
|
|
504
|
-
*/
|
|
505
|
-
CONTENT_TYPE: "content-type",
|
|
506
|
-
/**
|
|
507
|
-
* The date and time that the message was sent (in "HTTP-date" format as defined by RFC 7231 Date/Time Formats).
|
|
508
|
-
* Permanent.
|
|
379
|
+
* There are also cases where patch formats do not need to operate from
|
|
380
|
+
* a known base-point (e.g., appending text lines to log files, or non-
|
|
381
|
+
* colliding rows to database tables), in which case the same care in
|
|
382
|
+
* client requests is not needed.
|
|
509
383
|
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
*
|
|
384
|
+
* The server MUST apply the entire set of changes atomically and never
|
|
385
|
+
* provide (e.g., in response to a GET during this operation) a
|
|
386
|
+
* partially modified representation. If the entire patch document
|
|
387
|
+
* cannot be successfully applied, then the server MUST NOT apply any of
|
|
388
|
+
* the changes. The determination of what constitutes a successful
|
|
389
|
+
* PATCH can vary depending on the patch document and the type of
|
|
390
|
+
* resource(s) being modified. For example, the common 'diff' utility
|
|
391
|
+
* can generate a patch document that applies to multiple files in a
|
|
392
|
+
* directory hierarchy. The atomicity requirement holds for all
|
|
393
|
+
* directly affected files. See "Error Handling", Section 2.2, for
|
|
394
|
+
* details on status codes and possible error conditions.
|
|
516
395
|
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
*
|
|
396
|
+
* If the request passes through a cache and the Request-URI identifies
|
|
397
|
+
* one or more currently cached entities, those entries SHOULD be
|
|
398
|
+
* treated as stale. A response to this method is only cacheable if it
|
|
399
|
+
* contains explicit freshness information (such as an Expires header or
|
|
400
|
+
* "Cache-Control: max-age" directive) as well as the Content-Location
|
|
401
|
+
* header matching the Request-URI, indicating that the PATCH response
|
|
402
|
+
* body is a resource representation. A cached PATCH response can only
|
|
403
|
+
* be used to respond to subsequent GET and HEAD requests; it MUST NOT
|
|
404
|
+
* be used to respond to other methods (in particular, PATCH).
|
|
523
405
|
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
406
|
+
* Note that entity-headers contained in the request apply only to the
|
|
407
|
+
* contained patch document and MUST NOT be applied to the resource
|
|
408
|
+
* being modified. Thus, a Content-Language header could be present on
|
|
409
|
+
* the request, but it would only mean (for whatever that's worth) that
|
|
410
|
+
* the patch document had a language. Servers SHOULD NOT store such
|
|
411
|
+
* headers except as trace information, and SHOULD NOT use such header
|
|
412
|
+
* values the same way they might be used on PUT requests. Therefore,
|
|
413
|
+
* this document does not specify a way to modify a document's Content-
|
|
414
|
+
* Type or Content-Language value through headers, though a mechanism
|
|
415
|
+
* could well be designed to achieve this goal through a patch document.
|
|
532
416
|
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
417
|
+
* There is no guarantee that a resource can be modified with PATCH.
|
|
418
|
+
* Further, it is expected that different patch document formats will be
|
|
419
|
+
* appropriate for different types of resources and that no single
|
|
420
|
+
* format will be appropriate for all types of resources. Therefore,
|
|
421
|
+
* there is no single default patch document format that implementations
|
|
422
|
+
* are required to support. Servers MUST ensure that a received patch
|
|
423
|
+
* document is appropriate for the type of resource identified by the
|
|
424
|
+
* Request-URI.
|
|
425
|
+
*
|
|
426
|
+
* Clients need to choose when to use PATCH rather than PUT. For
|
|
427
|
+
* example, if the patch document size is larger than the size of the
|
|
428
|
+
* new resource data that would be used in a PUT, then it might make
|
|
429
|
+
* sense to use PUT instead of PATCH. A comparison to POST is even more
|
|
430
|
+
* difficult, because POST is used in widely varying ways and can
|
|
431
|
+
* encompass PUT and PATCH-like operations if the server chooses. If
|
|
432
|
+
* the operation does not modify the resource identified by the Request-
|
|
433
|
+
* URI in a predictable way, POST should be considered instead of PATCH
|
|
434
|
+
* or PUT.
|
|
536
435
|
*/
|
|
537
|
-
|
|
436
|
+
PATCH: "PATCH"
|
|
437
|
+
};
|
|
438
|
+
var http_request_methods_default = HttpRequestMethod;
|
|
439
|
+
|
|
440
|
+
// src/response-status.js
|
|
441
|
+
var ResponseStatus = class {
|
|
442
|
+
/** @type {number} */
|
|
443
|
+
#code;
|
|
444
|
+
/** @type {string} */
|
|
445
|
+
#text;
|
|
538
446
|
/**
|
|
539
|
-
* Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for
|
|
540
|
-
* methods like PUT to only update a resource if it has not been modified since the user last updated it. Permanent.
|
|
541
447
|
*
|
|
542
|
-
* @
|
|
543
|
-
*
|
|
448
|
+
* @param {number} code The status code from the {@link Response}
|
|
449
|
+
* @param {string} text The status text from the {@link Response}
|
|
544
450
|
*/
|
|
545
|
-
|
|
451
|
+
constructor(code, text) {
|
|
452
|
+
this.#code = code;
|
|
453
|
+
this.#text = text;
|
|
454
|
+
}
|
|
546
455
|
/**
|
|
547
|
-
*
|
|
456
|
+
* Returns the status code from the {@link Response}
|
|
548
457
|
*
|
|
549
|
-
* @
|
|
550
|
-
* <code>If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT</code>
|
|
458
|
+
* @returns {number} The status code.
|
|
551
459
|
*/
|
|
552
|
-
|
|
460
|
+
get code() {
|
|
461
|
+
return this.#code;
|
|
462
|
+
}
|
|
553
463
|
/**
|
|
554
|
-
*
|
|
464
|
+
* Returns the status text from the {@link Response}.
|
|
555
465
|
*
|
|
556
|
-
* @
|
|
557
|
-
* <code>If-None-Match: "737060cd8c284d8af7ad3082f209582d"</code>
|
|
466
|
+
* @returns {string} The status text.
|
|
558
467
|
*/
|
|
559
|
-
|
|
468
|
+
get text() {
|
|
469
|
+
return this.#text;
|
|
470
|
+
}
|
|
560
471
|
/**
|
|
561
|
-
*
|
|
562
|
-
*
|
|
472
|
+
* A String value that is used in the creation of the default string
|
|
473
|
+
* description of an object. Called by the built-in method {@link Object.prototype.toString}.
|
|
563
474
|
*
|
|
564
|
-
* @
|
|
565
|
-
*
|
|
475
|
+
* @override
|
|
476
|
+
* @returns {string} The default string description of this object.
|
|
566
477
|
*/
|
|
567
|
-
|
|
478
|
+
get [Symbol.toStringTag]() {
|
|
479
|
+
return "ResponseStatus";
|
|
480
|
+
}
|
|
568
481
|
/**
|
|
569
|
-
*
|
|
482
|
+
* tostring method for the class.
|
|
570
483
|
*
|
|
571
|
-
* @
|
|
572
|
-
*
|
|
484
|
+
* @override
|
|
485
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString|Object.prototype.toString}
|
|
486
|
+
* @returns {string} The status code and status text.
|
|
573
487
|
*/
|
|
574
|
-
|
|
488
|
+
toString() {
|
|
489
|
+
return `${this.#code} ${this.#text}`;
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
// node_modules/@d1g1tal/media-type/src/utils.js
|
|
494
|
+
var whitespaceCharacters = [" ", " ", "\n", "\r"];
|
|
495
|
+
var leadingWhitespace = /^[ \t\n\r]+/u;
|
|
496
|
+
var trailingWhitespace = /[ \t\n\r]+$/u;
|
|
497
|
+
var httpTokenCodePoints = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;
|
|
498
|
+
var httpQuotedTokenCodePoints = /^[\t\u0020-\u007E\u0080-\u00FF]*$/u;
|
|
499
|
+
var removeLeadingAndTrailingHTTPWhitespace = (string) => string.replace(leadingWhitespace, "").replace(trailingWhitespace, "");
|
|
500
|
+
var removeTrailingHTTPWhitespace = (string) => string.replace(trailingWhitespace, "");
|
|
501
|
+
var isHTTPWhitespaceChar = (char) => whitespaceCharacters.includes(char);
|
|
502
|
+
var solelyContainsHTTPTokenCodePoints = (string) => httpTokenCodePoints.test(string);
|
|
503
|
+
var solelyContainsHTTPQuotedStringTokenCodePoints = (string) => httpQuotedTokenCodePoints.test(string);
|
|
504
|
+
var asciiLowercase = (string) => {
|
|
505
|
+
let result = "";
|
|
506
|
+
for (const [char, charCode = char.charCodeAt(0)] of string) {
|
|
507
|
+
result += charCode >= 65 && charCode <= 90 ? String.fromCharCode(charCode + 32) : char;
|
|
508
|
+
}
|
|
509
|
+
return result;
|
|
510
|
+
};
|
|
511
|
+
var collectAnHTTPQuotedString = (input, position) => {
|
|
512
|
+
let value = "";
|
|
513
|
+
for (let length = input.length, char; ++position < length; ) {
|
|
514
|
+
char = input[position];
|
|
515
|
+
if (char == "\\") {
|
|
516
|
+
value += ++position < length ? input[position] : char;
|
|
517
|
+
} else if (char == '"') {
|
|
518
|
+
break;
|
|
519
|
+
} else {
|
|
520
|
+
value += char;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return [value, position];
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
// node_modules/@d1g1tal/media-type/src/media-type-parameters.js
|
|
527
|
+
var MediaTypeParameters = class {
|
|
528
|
+
/** @type {Map<string, string>} */
|
|
529
|
+
#map;
|
|
575
530
|
/**
|
|
576
|
-
*
|
|
531
|
+
* Create a new MediaTypeParameters instance.
|
|
577
532
|
*
|
|
578
|
-
* @
|
|
579
|
-
* <code>Max-Forwards: 10</code>
|
|
533
|
+
* @param {Array<Array<string>>} entries An array of [name, value] tuples.
|
|
580
534
|
*/
|
|
581
|
-
|
|
535
|
+
constructor(entries) {
|
|
536
|
+
this.#map = new Map(entries);
|
|
537
|
+
}
|
|
582
538
|
/**
|
|
583
|
-
*
|
|
584
|
-
* field). Permanent: standard.
|
|
539
|
+
* Gets the number of media type parameters.
|
|
585
540
|
*
|
|
586
|
-
* @
|
|
587
|
-
* <code>Origin: http://www.example-social-network.com</code>
|
|
541
|
+
* @returns {number} The number of media type parameters
|
|
588
542
|
*/
|
|
589
|
-
|
|
543
|
+
get size() {
|
|
544
|
+
return this.#map.size;
|
|
545
|
+
}
|
|
590
546
|
/**
|
|
591
|
-
*
|
|
547
|
+
* Gets the media type parameter value for the supplied name.
|
|
592
548
|
*
|
|
593
|
-
* @
|
|
594
|
-
*
|
|
549
|
+
* @param {string} name The name of the media type parameter to retrieve.
|
|
550
|
+
* @returns {string} The media type parameter value.
|
|
595
551
|
*/
|
|
596
|
-
|
|
552
|
+
get(name) {
|
|
553
|
+
return this.#map.get(asciiLowercase(String(name)));
|
|
554
|
+
}
|
|
597
555
|
/**
|
|
598
|
-
*
|
|
556
|
+
* Indicates whether the media type parameter with the specified name exists or not.
|
|
599
557
|
*
|
|
600
|
-
* @
|
|
601
|
-
*
|
|
558
|
+
* @param {string} name The name of the media type parameter to check.
|
|
559
|
+
* @returns {boolean} true if the media type parameter exists, false otherwise.
|
|
602
560
|
*/
|
|
603
|
-
|
|
561
|
+
has(name) {
|
|
562
|
+
return this.#map.has(asciiLowercase(String(name)));
|
|
563
|
+
}
|
|
604
564
|
/**
|
|
605
|
-
*
|
|
565
|
+
* Adds a new media type parameter using the specified name and value to the MediaTypeParameters.
|
|
566
|
+
* If an parameter with the same name already exists, the parameter will be updated.
|
|
606
567
|
*
|
|
607
|
-
* @
|
|
608
|
-
*
|
|
568
|
+
* @param {string} name The name of the media type parameter to set.
|
|
569
|
+
* @param {string} value The media type parameter value.
|
|
570
|
+
* @returns {MediaTypeParameters} This instance.
|
|
609
571
|
*/
|
|
610
|
-
|
|
572
|
+
set(name, value) {
|
|
573
|
+
name = asciiLowercase(String(name));
|
|
574
|
+
value = String(value);
|
|
575
|
+
if (!solelyContainsHTTPTokenCodePoints(name)) {
|
|
576
|
+
throw new Error(`Invalid media type parameter name "${name}": only HTTP token code points are valid.`);
|
|
577
|
+
}
|
|
578
|
+
if (!solelyContainsHTTPQuotedStringTokenCodePoints(value)) {
|
|
579
|
+
throw new Error(`Invalid media type parameter value "${value}": only HTTP quoted-string token code points are valid.`);
|
|
580
|
+
}
|
|
581
|
+
this.#map.set(name, value);
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
611
584
|
/**
|
|
612
|
-
*
|
|
613
|
-
* word "referrer" has been misspelled in the RFC as well as in most implementations to the point that it has become
|
|
614
|
-
* standard usage and is considered correct terminology). Permanent.
|
|
615
|
-
*
|
|
616
|
-
* @example
|
|
617
|
-
* <code>Referer: http://en.wikipedia.org/wiki/Main_Page</code>
|
|
585
|
+
* Clears all the media type parameters.
|
|
618
586
|
*/
|
|
619
|
-
|
|
587
|
+
clear() {
|
|
588
|
+
this.#map.clear();
|
|
589
|
+
}
|
|
620
590
|
/**
|
|
621
|
-
*
|
|
622
|
-
* Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the
|
|
623
|
-
* server it expects to receive additional fields in the trailer after the last, zero-sized, chunk. Permanent.
|
|
591
|
+
* Removes the media type parameter using the specified name.
|
|
624
592
|
*
|
|
625
|
-
* @
|
|
626
|
-
*
|
|
593
|
+
* @param {string} name The name of the media type parameter to delete.
|
|
594
|
+
* @returns {boolean} true if the parameter existed and has been removed, or false if the parameter does not exist.
|
|
627
595
|
*/
|
|
628
|
-
|
|
596
|
+
delete(name) {
|
|
597
|
+
name = asciiLowercase(String(name));
|
|
598
|
+
return this.#map.delete(name);
|
|
599
|
+
}
|
|
629
600
|
/**
|
|
630
|
-
*
|
|
601
|
+
* Executes a provided function once per each name/value pair in the MediaTypeParameters, in insertion order.
|
|
631
602
|
*
|
|
632
|
-
* @
|
|
633
|
-
*
|
|
603
|
+
* @param {function(string, string): void} callback The function called on each iteration.
|
|
604
|
+
* @param {*} [thisArg] Optional object when binding 'this' to the callback.
|
|
634
605
|
*/
|
|
635
|
-
|
|
606
|
+
forEach(callback, thisArg) {
|
|
607
|
+
this.#map.forEach(callback, thisArg);
|
|
608
|
+
}
|
|
636
609
|
/**
|
|
637
|
-
*
|
|
610
|
+
* Returns an iterable of parameter names.
|
|
638
611
|
*
|
|
639
|
-
* @
|
|
640
|
-
* <code>Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11</code>
|
|
612
|
+
* @returns {IterableIterator<string>} The {@link IterableIterator} of media type parameter names.
|
|
641
613
|
*/
|
|
642
|
-
|
|
614
|
+
keys() {
|
|
615
|
+
return this.#map.keys();
|
|
616
|
+
}
|
|
643
617
|
/**
|
|
644
|
-
*
|
|
618
|
+
* Returns an iterable of parameter values.
|
|
645
619
|
*
|
|
646
|
-
* @
|
|
647
|
-
* <code>Via: 1.0 fred, 1.1 example.com (Apache/1.1)</code>
|
|
620
|
+
* @returns {IterableIterator<string>} The {@link IterableIterator} of media type parameter values.
|
|
648
621
|
*/
|
|
649
|
-
|
|
622
|
+
values() {
|
|
623
|
+
return this.#map.values();
|
|
624
|
+
}
|
|
650
625
|
/**
|
|
651
|
-
*
|
|
626
|
+
* Returns an iterable of name, value pairs for every parameter entry in the media type parameters.
|
|
652
627
|
*
|
|
653
|
-
* @
|
|
654
|
-
* <code>Warning: 199 Miscellaneous warning</code>
|
|
628
|
+
* @returns {IterableIterator<Array<Array<string>>>} The media type parameter entries.
|
|
655
629
|
*/
|
|
656
|
-
|
|
630
|
+
entries() {
|
|
631
|
+
return this.#map.entries();
|
|
632
|
+
}
|
|
657
633
|
/**
|
|
658
|
-
*
|
|
634
|
+
* A method that returns the default iterator for the {@link MediaTypeParameters}. Called by the semantics of the for-of statement.
|
|
659
635
|
*
|
|
660
|
-
* @
|
|
661
|
-
* <code>X-Requested-With: XMLHttpRequest</code>
|
|
636
|
+
* @returns {Iterator<string, string, undefined>} The {@link Symbol.iterator} for the media type parameters.
|
|
662
637
|
*/
|
|
663
|
-
|
|
638
|
+
[Symbol.iterator]() {
|
|
639
|
+
return this.#map[Symbol.iterator]();
|
|
640
|
+
}
|
|
664
641
|
/**
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
* draft proposal was submitted to IETF. The W3C Tracking Protection Working Group is producing a specification.
|
|
642
|
+
* Returns a string representation of the media type parameters.
|
|
643
|
+
* This method is called by the `String()` function.
|
|
668
644
|
*
|
|
669
645
|
* @example
|
|
670
|
-
*
|
|
671
|
-
*
|
|
646
|
+
* const parameters = new MediaTypeParameters(new Map([['charset', 'utf-8']]));
|
|
647
|
+
* String(parameters); // 'charset=utf-8'
|
|
648
|
+
* parameters.toString(); // 'charset=utf-8'
|
|
649
|
+
* parameters + ''; // 'charset=utf-8'
|
|
650
|
+
* `${parameters}`; // 'charset=utf-8'
|
|
651
|
+
* parameters[Symbol.toStringTag]; // 'MediaTypeParameters'
|
|
652
|
+
* parameters[Symbol.toStringTag](); // 'MediaTypeParameters'
|
|
653
|
+
* Object.prototype.toString.call(parameters); // '[object MediaTypeParameters]'
|
|
654
|
+
* parameters + ''; // 'charset=utf-8'
|
|
655
|
+
* @returns {string} The string representation of the media type parameters.
|
|
672
656
|
*/
|
|
673
|
-
|
|
657
|
+
[Symbol.toStringTag]() {
|
|
658
|
+
return "MediaTypeParameters";
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// node_modules/@d1g1tal/media-type/src/parser.js
|
|
663
|
+
var parse = (input) => {
|
|
664
|
+
input = removeLeadingAndTrailingHTTPWhitespace(input);
|
|
665
|
+
let position = 0;
|
|
666
|
+
let type = "";
|
|
667
|
+
while (position < input.length && input[position] != "/") {
|
|
668
|
+
type += input[position];
|
|
669
|
+
++position;
|
|
670
|
+
}
|
|
671
|
+
if (type.length === 0 || !solelyContainsHTTPTokenCodePoints(type)) {
|
|
672
|
+
return null;
|
|
673
|
+
}
|
|
674
|
+
if (position >= input.length) {
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
++position;
|
|
678
|
+
let subtype = "";
|
|
679
|
+
while (position < input.length && input[position] != ";") {
|
|
680
|
+
subtype += input[position];
|
|
681
|
+
++position;
|
|
682
|
+
}
|
|
683
|
+
subtype = removeTrailingHTTPWhitespace(subtype);
|
|
684
|
+
if (subtype.length === 0 || !solelyContainsHTTPTokenCodePoints(subtype)) {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
const mediaType = {
|
|
688
|
+
type: asciiLowercase(type),
|
|
689
|
+
subtype: asciiLowercase(subtype),
|
|
690
|
+
parameters: /* @__PURE__ */ new Map()
|
|
691
|
+
};
|
|
692
|
+
while (position < input.length) {
|
|
693
|
+
++position;
|
|
694
|
+
while (isHTTPWhitespaceChar(input[position])) {
|
|
695
|
+
++position;
|
|
696
|
+
}
|
|
697
|
+
let parameterName = "";
|
|
698
|
+
while (position < input.length && input[position] != ";" && input[position] != "=") {
|
|
699
|
+
parameterName += input[position];
|
|
700
|
+
++position;
|
|
701
|
+
}
|
|
702
|
+
parameterName = asciiLowercase(parameterName);
|
|
703
|
+
if (position < input.length) {
|
|
704
|
+
if (input[position] == ";") {
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
++position;
|
|
708
|
+
}
|
|
709
|
+
let parameterValue = null;
|
|
710
|
+
if (input[position] == '"') {
|
|
711
|
+
[parameterValue, position] = collectAnHTTPQuotedString(input, position);
|
|
712
|
+
while (position < input.length && input[position] != ";") {
|
|
713
|
+
++position;
|
|
714
|
+
}
|
|
715
|
+
} else {
|
|
716
|
+
parameterValue = "";
|
|
717
|
+
while (position < input.length && input[position] != ";") {
|
|
718
|
+
parameterValue += input[position];
|
|
719
|
+
++position;
|
|
720
|
+
}
|
|
721
|
+
parameterValue = removeTrailingHTTPWhitespace(parameterValue);
|
|
722
|
+
if (parameterValue === "") {
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (parameterName.length > 0 && solelyContainsHTTPTokenCodePoints(parameterName) && solelyContainsHTTPQuotedStringTokenCodePoints(parameterValue) && !mediaType.parameters.has(parameterName)) {
|
|
727
|
+
mediaType.parameters.set(parameterName, parameterValue);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return mediaType;
|
|
731
|
+
};
|
|
732
|
+
var parser_default = parse;
|
|
733
|
+
|
|
734
|
+
// node_modules/@d1g1tal/media-type/src/serializer.js
|
|
735
|
+
var serialize = (mediaType) => {
|
|
736
|
+
let serialization = `${mediaType.type}/${mediaType.subtype}`;
|
|
737
|
+
if (mediaType.parameters.size === 0) {
|
|
738
|
+
return serialization;
|
|
739
|
+
}
|
|
740
|
+
for (let [name, value] of mediaType.parameters) {
|
|
741
|
+
serialization += `;${name}=`;
|
|
742
|
+
if (!solelyContainsHTTPTokenCodePoints(value) || value.length === 0) {
|
|
743
|
+
value = `"${value.replace(/(["\\])/ug, "\\$1")}"`;
|
|
744
|
+
}
|
|
745
|
+
serialization += value;
|
|
746
|
+
}
|
|
747
|
+
return serialization;
|
|
748
|
+
};
|
|
749
|
+
var serializer_default = serialize;
|
|
750
|
+
|
|
751
|
+
// node_modules/@d1g1tal/media-type/src/media-type.js
|
|
752
|
+
var MediaType = class _MediaType {
|
|
753
|
+
/** @type {string} */
|
|
754
|
+
#type;
|
|
755
|
+
/** @type {string} */
|
|
756
|
+
#subtype;
|
|
757
|
+
/** @type {MediaTypeParameters} */
|
|
758
|
+
#parameters;
|
|
674
759
|
/**
|
|
675
|
-
*
|
|
676
|
-
* HTTP proxy or load balancer.
|
|
760
|
+
* Create a new MediaType instance from a string representation.
|
|
677
761
|
*
|
|
678
|
-
* @
|
|
679
|
-
*
|
|
680
|
-
* <code>X-Forwarded-For: 129.78.138.66, 129.78.64.103</code>
|
|
762
|
+
* @param {string} mediaType The media type to parse.
|
|
763
|
+
* @param {Object} [parameters] Optional parameters.
|
|
681
764
|
*/
|
|
682
|
-
|
|
765
|
+
constructor(mediaType, parameters = {}) {
|
|
766
|
+
const { type, subtype, parameters: parsedParameters } = parser_default(mediaType);
|
|
767
|
+
this.#type = type;
|
|
768
|
+
this.#subtype = subtype;
|
|
769
|
+
this.#parameters = new MediaTypeParameters([...parsedParameters, ...Object.entries(parameters).map(([name, value]) => [asciiLowercase(name), asciiLowercase(value)])]);
|
|
770
|
+
}
|
|
683
771
|
/**
|
|
684
|
-
*
|
|
685
|
-
* the host name and/or port of the reverse proxy (load balancer) may differ from the origin server handling the
|
|
686
|
-
* request.
|
|
772
|
+
* Static factory method for parsing a media type.
|
|
687
773
|
*
|
|
688
|
-
* @
|
|
689
|
-
*
|
|
690
|
-
* <code>X-Forwarded-Host: en.wikipedia.org</code>
|
|
774
|
+
* @param {string} string The media type to parse.
|
|
775
|
+
* @returns {MediaType} The parsed {@link MediaType} object or null if the string could not be parsed.
|
|
691
776
|
*/
|
|
692
|
-
|
|
777
|
+
static parse(string) {
|
|
778
|
+
try {
|
|
779
|
+
return new _MediaType(string);
|
|
780
|
+
} catch (e) {
|
|
781
|
+
throw new Error(`Could not parse media type string '${string}'`);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
693
784
|
/**
|
|
694
|
-
*
|
|
695
|
-
* balancer) may communicate with a web server using HTTP even if the request to the reverse proxy is HTTPS. An
|
|
696
|
-
* alternative form of the header (X-ProxyUser-Ip) is used by Google clients talking to Google servers.
|
|
785
|
+
* Gets the media type essence (type/subtype).
|
|
697
786
|
*
|
|
698
|
-
* @
|
|
699
|
-
* <code>X-Forwarded-Proto: https</code>
|
|
787
|
+
* @returns {string} The media type without any parameters
|
|
700
788
|
*/
|
|
701
|
-
|
|
789
|
+
get essence() {
|
|
790
|
+
return `${this.#type}/${this.#subtype}`;
|
|
791
|
+
}
|
|
702
792
|
/**
|
|
703
|
-
*
|
|
793
|
+
* Gets the type.
|
|
704
794
|
*
|
|
705
|
-
* @
|
|
706
|
-
* <code>Front-End-Https: on</code>
|
|
795
|
+
* @returns {string} The type.
|
|
707
796
|
*/
|
|
708
|
-
|
|
797
|
+
get type() {
|
|
798
|
+
return this.#type;
|
|
799
|
+
}
|
|
709
800
|
/**
|
|
710
|
-
*
|
|
711
|
-
* the header field (typically PUT or DELETE). Can be used when a user agent or firewall prevents PUT or DELETE methods
|
|
712
|
-
* from being sent directly (note that this either a bug in the software component, which ought to be fixed, or an
|
|
713
|
-
* intentional configuration, in which case bypassing it may be the wrong thing to do).
|
|
714
|
-
*
|
|
715
|
-
* @example
|
|
716
|
-
* <code>X-HTTP-Method-Override: DELETE</code>
|
|
801
|
+
* Sets the type.
|
|
717
802
|
*/
|
|
718
|
-
|
|
803
|
+
set type(value) {
|
|
804
|
+
value = asciiLowercase(String(value));
|
|
805
|
+
if (value.length === 0) {
|
|
806
|
+
throw new Error("Invalid type: must be a non-empty string");
|
|
807
|
+
}
|
|
808
|
+
if (!solelyContainsHTTPTokenCodePoints(value)) {
|
|
809
|
+
throw new Error(`Invalid type ${value}: must contain only HTTP token code points`);
|
|
810
|
+
}
|
|
811
|
+
this.#type = value;
|
|
812
|
+
}
|
|
719
813
|
/**
|
|
720
|
-
*
|
|
814
|
+
* Gets the subtype.
|
|
721
815
|
*
|
|
722
|
-
* @
|
|
723
|
-
* <code>X-Att-Deviceid: GT-P7320/P7320XXLPG</code>
|
|
816
|
+
* @returns {string} The subtype.
|
|
724
817
|
*/
|
|
725
|
-
|
|
818
|
+
get subtype() {
|
|
819
|
+
return this.#subtype;
|
|
820
|
+
}
|
|
726
821
|
/**
|
|
727
|
-
*
|
|
728
|
-
* x-wap-profile: http://wap.samsungmobile.com/uaprof/SGH-I777.xml
|
|
822
|
+
* Sets the subtype.
|
|
729
823
|
*/
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
824
|
+
set subtype(value) {
|
|
825
|
+
value = asciiLowercase(String(value));
|
|
826
|
+
if (value.length === 0) {
|
|
827
|
+
throw new Error("Invalid subtype: must be a non-empty string");
|
|
828
|
+
}
|
|
829
|
+
if (!solelyContainsHTTPTokenCodePoints(value)) {
|
|
830
|
+
throw new Error(`Invalid subtype ${value}: must contain only HTTP token code points`);
|
|
831
|
+
}
|
|
832
|
+
this.#subtype = value;
|
|
833
|
+
}
|
|
736
834
|
/**
|
|
737
|
-
*
|
|
738
|
-
* request/response chain identified by the Request-URI. This method allows the client to determine the options and/or
|
|
739
|
-
* requirements associated with a resource, or the capabilities of a server, without implying a resource action or
|
|
740
|
-
* initiating a resource retrieval.
|
|
741
|
-
*
|
|
742
|
-
* Responses to this method are not cacheable.
|
|
835
|
+
* Gets the parameters.
|
|
743
836
|
*
|
|
744
|
-
*
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
837
|
+
* @returns {MediaTypeParameters} The media type parameters.
|
|
838
|
+
*/
|
|
839
|
+
get parameters() {
|
|
840
|
+
return this.#parameters;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Gets the serialized version of the media type.
|
|
748
844
|
*
|
|
749
|
-
*
|
|
750
|
-
* than to a specific resource. Since a server's communication options typically depend on the resource, the "*"
|
|
751
|
-
* request is only useful as a "ping" or "no-op" type of method, it does nothing beyond allowing the client to test the
|
|
752
|
-
* capabilities of the server. For example, this can be used to test a proxy for HTTP/1.1 compliance (or lack thereof).
|
|
753
|
-
*
|
|
754
|
-
* If the Request-URI is not an asterisk, the OPTIONS request applies only to the options that are available when
|
|
755
|
-
* communicating with that resource.
|
|
756
|
-
*
|
|
757
|
-
* A 200 response SHOULD include any header fields that indicate optional features implemented by the server and
|
|
758
|
-
* applicable to that resource (e.g., Allow), possibly including extensions not defined by this specification. The
|
|
759
|
-
* response body, if any, SHOULD also include information about the communication options. The format for such a body
|
|
760
|
-
* is not defined by this specification, but might be defined by future extensions to HTTP. Content negotiation MAY be
|
|
761
|
-
* used to select the appropriate response format. If no response body is included, the response MUST include a
|
|
762
|
-
* Content-Length field with a field-value of "0".
|
|
763
|
-
*
|
|
764
|
-
* The Max-Forwards request-header field MAY be used to target a specific proxy in the request chain. When a proxy
|
|
765
|
-
* receives an OPTIONS request on an absoluteURI for which request forwarding is permitted, the proxy MUST check for a
|
|
766
|
-
* Max-Forwards field. If the Max-Forwards field-value is zero ("0"), the proxy MUST NOT forward the message, instead,
|
|
767
|
-
* the proxy SHOULD respond with its own communication options. If the Max-Forwards field-value is an integer greater
|
|
768
|
-
* than zero, the proxy MUST decrement the field-value when it forwards the request. If no Max-Forwards field is
|
|
769
|
-
* present in the request, then the forwarded request MUST NOT include a Max-Forwards field.
|
|
770
|
-
*/
|
|
771
|
-
OPTIONS: "OPTIONS",
|
|
772
|
-
/**
|
|
773
|
-
* The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If
|
|
774
|
-
* the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in
|
|
775
|
-
* the response and not the source text of the process, unless that text happens to be the output of the process.
|
|
776
|
-
*
|
|
777
|
-
* The semantics of the GET method change to a "conditional GET" if the request message includes an If-Modified-Since;
|
|
778
|
-
* If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the
|
|
779
|
-
* entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET
|
|
780
|
-
* method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring
|
|
781
|
-
* multiple requests or transferring data already held by the client.
|
|
782
|
-
*
|
|
783
|
-
* The semantics of the GET method change to a "partial GET" if the request message includes a Range header field. A
|
|
784
|
-
* partial GET requests that only part of the entity be transferred, as described in section 14.35. The partial GET
|
|
785
|
-
* method is intended to reduce unnecessary network usage by allowing partially-retrieved entities to be completed
|
|
786
|
-
* without transferring data already held by the client.
|
|
787
|
-
*
|
|
788
|
-
* The response to a GET request is cacheable if and only if it meets the requirements for HTTP caching described in
|
|
789
|
-
* section 13.
|
|
790
|
-
*
|
|
791
|
-
* See section 15.1.3 for security considerations when used for forms.
|
|
792
|
-
*/
|
|
793
|
-
GET: "GET",
|
|
794
|
-
/**
|
|
795
|
-
* The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The
|
|
796
|
-
* meta information contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information
|
|
797
|
-
* sent in response to a GET request. This method can be used for obtaining meta information about the entity implied by
|
|
798
|
-
* the request without transferring the entity-body itself. This method is often used for testing hypertext links for
|
|
799
|
-
* validity, accessibility, and recent modification.
|
|
800
|
-
*
|
|
801
|
-
* The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be
|
|
802
|
-
* used to update a previously cached entity from that resource. If the new field values indicate that the cached
|
|
803
|
-
* entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or
|
|
804
|
-
* Last-Modified), then the cache MUST treat the cache entry as stale.
|
|
805
|
-
*/
|
|
806
|
-
HEAD: "HEAD",
|
|
807
|
-
/**
|
|
808
|
-
* The POST method is used to request that the origin server accept the entity enclosed in the request as a new
|
|
809
|
-
* subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform
|
|
810
|
-
* method to cover the following functions:
|
|
811
|
-
* <ul>
|
|
812
|
-
* <li>Annotation of existing resources,</li>
|
|
813
|
-
* <li>Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles,</li>
|
|
814
|
-
* <li>Providing a block of data, such as the result of submitting a form, to a data-handling process,</li>
|
|
815
|
-
* <li>Extending a database through an append operation.</li>
|
|
816
|
-
* </ul>
|
|
817
|
-
*
|
|
818
|
-
* The actual function performed by the POST method is determined by the server and is usually dependent on the
|
|
819
|
-
* Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory
|
|
820
|
-
* containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a
|
|
821
|
-
* database.
|
|
822
|
-
*
|
|
823
|
-
* The action performed by the POST method might not result in a resource that can be identified by a URI. In this
|
|
824
|
-
* case, either 200 (OK) or 204 (No Content) is the appropriate response status, depending on whether or not the
|
|
825
|
-
* response includes an entity that describes the result.
|
|
826
|
-
*
|
|
827
|
-
* If a resource has been created on the origin server, the response SHOULD be 201 (Created) and contain an entity
|
|
828
|
-
* which describes the status of the request and refers to the new resource, and a Location header (see section 14.30).
|
|
829
|
-
*
|
|
830
|
-
* Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header
|
|
831
|
-
* fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.
|
|
832
|
-
*
|
|
833
|
-
* POST requests MUST obey the message transmission requirements set out in section 8.2.
|
|
834
|
-
*
|
|
835
|
-
* See section 15.1.3 for security considerations.
|
|
845
|
+
* @returns {string} The serialized media type.
|
|
836
846
|
*/
|
|
837
|
-
|
|
847
|
+
toString() {
|
|
848
|
+
return serializer_default(this);
|
|
849
|
+
}
|
|
838
850
|
/**
|
|
839
|
-
*
|
|
840
|
-
* to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing
|
|
841
|
-
* on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being
|
|
842
|
-
* defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If
|
|
843
|
-
* a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an
|
|
844
|
-
* existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate
|
|
845
|
-
* successful completion of the request. If the resource could not be created or modified with the Request-URI, an
|
|
846
|
-
* appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST
|
|
847
|
-
* \NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a
|
|
848
|
-
* 501 (Not Implemented) response in such cases.
|
|
849
|
-
*
|
|
850
|
-
* If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those
|
|
851
|
-
* entries SHOULD be treated as stale. Responses to this method are not cacheable.
|
|
852
|
-
*
|
|
853
|
-
* The fundamental difference between the POST and PUT requests is reflected in the different meaning of the
|
|
854
|
-
* Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource
|
|
855
|
-
* might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations.
|
|
856
|
-
* In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what
|
|
857
|
-
* URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires
|
|
858
|
-
* that the request be applied to a different URI, it MUST send a 301 (Moved Permanently) response, the user agent MAY
|
|
859
|
-
* then make its own decision regarding whether or not to redirect the request.
|
|
860
|
-
*
|
|
861
|
-
* A single resource MAY be identified by many different URIs. For example, an article might have a URI for identifying
|
|
862
|
-
* "the current version" which is separate from the URI identifying each particular version. In this case, a PUT
|
|
863
|
-
* request on a general URI might result in several other URIs being defined by the origin server.
|
|
864
|
-
*
|
|
865
|
-
* HTTP/1.1 does not define how a PUT method affects the state of an origin server.
|
|
866
|
-
*
|
|
867
|
-
* PUT requests MUST obey the message transmission requirements set out in section 8.2.
|
|
851
|
+
* Determines if this instance is a JavaScript media type.
|
|
868
852
|
*
|
|
869
|
-
*
|
|
870
|
-
* to
|
|
853
|
+
* @param {Object} [options] Optional options.
|
|
854
|
+
* @param {boolean} [options.prohibitParameters=false] The option to prohibit parameters when checking if the media type is JavaScript.
|
|
855
|
+
* @returns {boolean} true if this instance represents a JavaScript media type, false otherwise.
|
|
871
856
|
*/
|
|
872
|
-
|
|
857
|
+
isJavaScript({ prohibitParameters = false } = {}) {
|
|
858
|
+
switch (this.#type) {
|
|
859
|
+
case "text": {
|
|
860
|
+
switch (this.#subtype) {
|
|
861
|
+
case "ecmascript":
|
|
862
|
+
case "javascript":
|
|
863
|
+
case "javascript1.0":
|
|
864
|
+
case "javascript1.1":
|
|
865
|
+
case "javascript1.2":
|
|
866
|
+
case "javascript1.3":
|
|
867
|
+
case "javascript1.4":
|
|
868
|
+
case "javascript1.5":
|
|
869
|
+
case "jscript":
|
|
870
|
+
case "livescript":
|
|
871
|
+
case "x-ecmascript":
|
|
872
|
+
case "x-javascript":
|
|
873
|
+
return !prohibitParameters || this.#parameters.size === 0;
|
|
874
|
+
default:
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
case "application": {
|
|
879
|
+
switch (this.#subtype) {
|
|
880
|
+
case "ecmascript":
|
|
881
|
+
case "javascript":
|
|
882
|
+
case "x-ecmascript":
|
|
883
|
+
case "x-javascript":
|
|
884
|
+
return !prohibitParameters || this.#parameters.size === 0;
|
|
885
|
+
default:
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
default:
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
873
893
|
/**
|
|
874
|
-
*
|
|
875
|
-
* be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the
|
|
876
|
-
* operation has been carried out, even if the status code returned from the origin server indicates that the action
|
|
877
|
-
* has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response
|
|
878
|
-
* is given, it intends to delete the resource or move it to an inaccessible location.
|
|
879
|
-
*
|
|
880
|
-
* A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if
|
|
881
|
-
* the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not
|
|
882
|
-
* include an entity.
|
|
894
|
+
* Determines if this instance is an XML media type.
|
|
883
895
|
*
|
|
884
|
-
*
|
|
885
|
-
* entries SHOULD be treated as stale. Responses to this method are not cacheable.
|
|
896
|
+
* @returns {boolean} true if this instance represents an XML media type, false otherwise.
|
|
886
897
|
*/
|
|
887
|
-
|
|
898
|
+
isXML() {
|
|
899
|
+
return this.#subtype === "xml" && (this.#type === "text" || this.#type === "application") || this.#subtype.endsWith("+xml");
|
|
900
|
+
}
|
|
888
901
|
/**
|
|
889
|
-
*
|
|
890
|
-
* recipient of the request SHOULD reflect the message received back to the client as the entity-body of a 200 (OK)
|
|
891
|
-
* response. The final recipient is either the origin server or the first proxy or gateway to receive a Max-Forwards
|
|
892
|
-
* value of zero (0) in the request (see section 14.31). A TRACE request MUST NOT include an entity.
|
|
893
|
-
*
|
|
894
|
-
* TRACE allows the client to see what is being received at the other end of the request chain and use that data for
|
|
895
|
-
* testing or diagnostic information. The value of the Via header field (section 14.45) is of particular interest,
|
|
896
|
-
* since it acts as a trace of the request chain. Use of the Max-Forwards header field allows the client to limit the
|
|
897
|
-
* length of the request chain, which is useful for testing a chain of proxies forwarding messages in an infinite loop.
|
|
902
|
+
* Determines if this instance is an HTML media type.
|
|
898
903
|
*
|
|
899
|
-
*
|
|
900
|
-
* Content-Type of "message/http". Responses to this method MUST NOT be cached.
|
|
901
|
-
*/
|
|
902
|
-
TRACE: "TRACE",
|
|
903
|
-
/**
|
|
904
|
-
* This specification reserves the method name CONNECT for use with a proxy that can dynamically switch to being a
|
|
905
|
-
* tunnel (e.g. SSL tunneling [44]).
|
|
904
|
+
* @returns {boolean} true if this instance represents an HTML media type, false otherwise.
|
|
906
905
|
*/
|
|
907
|
-
|
|
906
|
+
isHTML() {
|
|
907
|
+
return this.#subtype === "html" && this.#type === "text";
|
|
908
|
+
}
|
|
908
909
|
/**
|
|
909
|
-
*
|
|
910
|
-
* request entity be applied to the resource identified by the Request-
|
|
911
|
-
* URI. The set of changes is represented in a format called a "patch
|
|
912
|
-
* document" identified by a media type. If the Request-URI does not
|
|
913
|
-
* point to an existing resource, the server MAY create a new resource,
|
|
914
|
-
* depending on the patch document type (whether it can logically modify
|
|
915
|
-
* a null resource) and permissions, etc.
|
|
916
|
-
*
|
|
917
|
-
* The difference between the PUT and PATCH requests is reflected in the
|
|
918
|
-
* way the server processes the enclosed entity to modify the resource
|
|
919
|
-
* identified by the Request-URI. In a PUT request, the enclosed entity
|
|
920
|
-
* is considered to be a modified version of the resource stored on the
|
|
921
|
-
* origin server, and the client is requesting that the stored version
|
|
922
|
-
* be replaced. With PATCH, however, the enclosed entity contains a set
|
|
923
|
-
* of instructions describing how a resource currently residing on the
|
|
924
|
-
* origin server should be modified to produce a new version. The PATCH
|
|
925
|
-
* method affects the resource identified by the Request-URI, and it
|
|
926
|
-
* also MAY have side effects on other resources; i.e., new resources
|
|
927
|
-
* may be created, or existing ones modified, by the application of a
|
|
928
|
-
* PATCH.
|
|
929
|
-
*
|
|
930
|
-
* PATCH is neither safe nor idempotent as defined by [RFC2616], Section
|
|
931
|
-
* 9.1.
|
|
932
|
-
*
|
|
933
|
-
* A PATCH request can be issued in such a way as to be idempotent,
|
|
934
|
-
* which also helps prevent bad outcomes from collisions between two
|
|
935
|
-
* PATCH requests on the same resource in a similar time frame.
|
|
936
|
-
* Collisions from multiple PATCH requests may be more dangerous than
|
|
937
|
-
* PUT collisions because some patch formats need to operate from a
|
|
938
|
-
* known base-point or else they will corrupt the resource. Clients
|
|
939
|
-
* using this kind of patch application SHOULD use a conditional request
|
|
940
|
-
* such that the request will fail if the resource has been updated
|
|
941
|
-
* since the client last accessed the resource. For example, the client
|
|
942
|
-
* can use a strong ETag [RFC2616] in an If-Match header on the PATCH
|
|
943
|
-
* request.
|
|
944
|
-
*
|
|
945
|
-
* There are also cases where patch formats do not need to operate from
|
|
946
|
-
* a known base-point (e.g., appending text lines to log files, or non-
|
|
947
|
-
* colliding rows to database tables), in which case the same care in
|
|
948
|
-
* client requests is not needed.
|
|
949
|
-
*
|
|
950
|
-
* The server MUST apply the entire set of changes atomically and never
|
|
951
|
-
* provide (e.g., in response to a GET during this operation) a
|
|
952
|
-
* partially modified representation. If the entire patch document
|
|
953
|
-
* cannot be successfully applied, then the server MUST NOT apply any of
|
|
954
|
-
* the changes. The determination of what constitutes a successful
|
|
955
|
-
* PATCH can vary depending on the patch document and the type of
|
|
956
|
-
* resource(s) being modified. For example, the common 'diff' utility
|
|
957
|
-
* can generate a patch document that applies to multiple files in a
|
|
958
|
-
* directory hierarchy. The atomicity requirement holds for all
|
|
959
|
-
* directly affected files. See "Error Handling", Section 2.2, for
|
|
960
|
-
* details on status codes and possible error conditions.
|
|
961
|
-
*
|
|
962
|
-
* If the request passes through a cache and the Request-URI identifies
|
|
963
|
-
* one or more currently cached entities, those entries SHOULD be
|
|
964
|
-
* treated as stale. A response to this method is only cacheable if it
|
|
965
|
-
* contains explicit freshness information (such as an Expires header or
|
|
966
|
-
* "Cache-Control: max-age" directive) as well as the Content-Location
|
|
967
|
-
* header matching the Request-URI, indicating that the PATCH response
|
|
968
|
-
* body is a resource representation. A cached PATCH response can only
|
|
969
|
-
* be used to respond to subsequent GET and HEAD requests; it MUST NOT
|
|
970
|
-
* be used to respond to other methods (in particular, PATCH).
|
|
971
|
-
*
|
|
972
|
-
* Note that entity-headers contained in the request apply only to the
|
|
973
|
-
* contained patch document and MUST NOT be applied to the resource
|
|
974
|
-
* being modified. Thus, a Content-Language header could be present on
|
|
975
|
-
* the request, but it would only mean (for whatever that's worth) that
|
|
976
|
-
* the patch document had a language. Servers SHOULD NOT store such
|
|
977
|
-
* headers except as trace information, and SHOULD NOT use such header
|
|
978
|
-
* values the same way they might be used on PUT requests. Therefore,
|
|
979
|
-
* this document does not specify a way to modify a document's Content-
|
|
980
|
-
* Type or Content-Language value through headers, though a mechanism
|
|
981
|
-
* could well be designed to achieve this goal through a patch document.
|
|
982
|
-
*
|
|
983
|
-
* There is no guarantee that a resource can be modified with PATCH.
|
|
984
|
-
* Further, it is expected that different patch document formats will be
|
|
985
|
-
* appropriate for different types of resources and that no single
|
|
986
|
-
* format will be appropriate for all types of resources. Therefore,
|
|
987
|
-
* there is no single default patch document format that implementations
|
|
988
|
-
* are required to support. Servers MUST ensure that a received patch
|
|
989
|
-
* document is appropriate for the type of resource identified by the
|
|
990
|
-
* Request-URI.
|
|
910
|
+
* Gets the name of the class.
|
|
991
911
|
*
|
|
992
|
-
*
|
|
993
|
-
* example, if the patch document size is larger than the size of the
|
|
994
|
-
* new resource data that would be used in a PUT, then it might make
|
|
995
|
-
* sense to use PUT instead of PATCH. A comparison to POST is even more
|
|
996
|
-
* difficult, because POST is used in widely varying ways and can
|
|
997
|
-
* encompass PUT and PATCH-like operations if the server chooses. If
|
|
998
|
-
* the operation does not modify the resource identified by the Request-
|
|
999
|
-
* URI in a predictable way, POST should be considered instead of PATCH
|
|
1000
|
-
* or PUT.
|
|
912
|
+
* @returns {string} The class name
|
|
1001
913
|
*/
|
|
1002
|
-
|
|
914
|
+
get [Symbol.toStringTag]() {
|
|
915
|
+
return "MediaType";
|
|
916
|
+
}
|
|
1003
917
|
};
|
|
1004
|
-
var http_request_methods_default = HttpRequestMethod;
|
|
1005
918
|
|
|
1006
|
-
// src/http-
|
|
1007
|
-
var
|
|
1008
|
-
/**
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
/**
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
919
|
+
// src/http-media-type.js
|
|
920
|
+
var HttpMediaType = {
|
|
921
|
+
/** Advanced Audio Coding (AAC) */
|
|
922
|
+
AAC: "audio/aac",
|
|
923
|
+
/** AbiWord */
|
|
924
|
+
ABW: "application/x-abiword",
|
|
925
|
+
/** Archive document (multiple files embedded) */
|
|
926
|
+
ARC: "application/x-freearc",
|
|
927
|
+
/** AVIF image */
|
|
928
|
+
AVIF: "image/avif",
|
|
929
|
+
/** Audio Video Interleave (AVI) */
|
|
930
|
+
AVI: "video/x-msvideo",
|
|
931
|
+
/** Amazon Kindle eBook format */
|
|
932
|
+
AZW: "application/vnd.amazon.ebook",
|
|
933
|
+
/** Binary Data */
|
|
934
|
+
BIN: "application/octet-stream",
|
|
935
|
+
/** Windows OS/2 Bitmap Graphics */
|
|
936
|
+
BMP: "image/bmp",
|
|
937
|
+
/** Bzip Archive */
|
|
938
|
+
BZIP: "application/x-bzip",
|
|
939
|
+
/** Bzip2 Archive */
|
|
940
|
+
BZIP2: "application/x-bzip2",
|
|
941
|
+
/** CD audio */
|
|
942
|
+
CDA: "application/x-cdf",
|
|
943
|
+
/** C Shell Script */
|
|
944
|
+
CSH: "application/x-csh",
|
|
945
|
+
/** Cascading Style Sheets (CSS) */
|
|
946
|
+
CSS: "text/css",
|
|
947
|
+
/** Comma-Separated Values */
|
|
948
|
+
CSV: "text/csv",
|
|
949
|
+
/** Microsoft Office Word Document */
|
|
950
|
+
DOC: "application/msword",
|
|
951
|
+
/** Microsoft Office Word Document (OpenXML) */
|
|
952
|
+
DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
953
|
+
/** Microsoft Embedded OpenType */
|
|
954
|
+
EOT: "application/vnd.ms-fontobject",
|
|
955
|
+
/** Electronic Publication (EPUB) */
|
|
956
|
+
EPUB: "application/epub+zip",
|
|
957
|
+
/** GZip Compressed Archive */
|
|
958
|
+
GZIP: "application/gzip",
|
|
959
|
+
/** Graphics Interchange Format */
|
|
960
|
+
GIF: "image/gif",
|
|
961
|
+
/** HyperText Markup Language (HTML) */
|
|
962
|
+
HTML: "text/html",
|
|
963
|
+
/** Icon Format */
|
|
964
|
+
ICO: "image/vnd.microsoft.icon",
|
|
965
|
+
/** iCalendar Format */
|
|
966
|
+
ICS: "text/calendar",
|
|
967
|
+
/** Java Archive (JAR) */
|
|
968
|
+
JAR: "application/java-archive",
|
|
969
|
+
/** JPEG Image */
|
|
970
|
+
JPEG: "image/jpeg",
|
|
971
|
+
/** JavaScript */
|
|
972
|
+
JAVA_SCRIPT: "text/javascript",
|
|
973
|
+
/** JavaScript Object Notation Format (JSON) */
|
|
974
|
+
JSON: "application/json",
|
|
975
|
+
/** JavaScript Object Notation LD Format */
|
|
976
|
+
JSON_LD: "application/ld+json",
|
|
977
|
+
/** JavaScript Object Notation (JSON) Merge Patch */
|
|
978
|
+
JSON_MERGE_PATCH: "application/merge-patch+json",
|
|
979
|
+
/** Musical Instrument Digital Interface (MIDI) */
|
|
980
|
+
MID: "audio/midi",
|
|
981
|
+
/** Musical Instrument Digital Interface (MIDI) */
|
|
982
|
+
X_MID: "audio/x-midi",
|
|
983
|
+
/** MP3 Audio */
|
|
984
|
+
MP3: "audio/mpeg",
|
|
985
|
+
/** MPEG-4 Audio */
|
|
986
|
+
MP4A: "audio/mp4",
|
|
987
|
+
/** MPEG-4 Video */
|
|
988
|
+
MP4: "video/mp4",
|
|
989
|
+
/** MPEG Video */
|
|
990
|
+
MPEG: "video/mpeg",
|
|
991
|
+
/** Apple Installer Package */
|
|
992
|
+
MPKG: "application/vnd.apple.installer+xml",
|
|
993
|
+
/** OpenDocument Presentation Document */
|
|
994
|
+
ODP: "application/vnd.oasis.opendocument.presentation",
|
|
995
|
+
/** OpenDocument Spreadsheet Document */
|
|
996
|
+
ODS: "application/vnd.oasis.opendocument.spreadsheet",
|
|
997
|
+
/** OpenDocument Text Document */
|
|
998
|
+
ODT: "application/vnd.oasis.opendocument.text",
|
|
999
|
+
/** Ogg Audio */
|
|
1000
|
+
OGA: "audio/ogg",
|
|
1001
|
+
/** Ogg Video */
|
|
1002
|
+
OGV: "video/ogg",
|
|
1003
|
+
/** Ogg */
|
|
1004
|
+
OGX: "application/ogg",
|
|
1005
|
+
/** Opus audio */
|
|
1006
|
+
OPUS: "audio/opus",
|
|
1007
|
+
/** OpenType Font File */
|
|
1008
|
+
OTF: "font/otf",
|
|
1009
|
+
/** Portable Network Graphics (PNG) */
|
|
1010
|
+
PNG: "image/png",
|
|
1011
|
+
/** Adobe Portable Document Format */
|
|
1012
|
+
PDF: "application/pdf",
|
|
1013
|
+
/** Hypertext Preprocessor (Personal Home Page) */
|
|
1014
|
+
PHP: "application/x-httpd-php",
|
|
1015
|
+
/** Microsoft PowerPoint */
|
|
1016
|
+
PPT: "application/vnd.ms-powerpoint",
|
|
1017
|
+
/** Microsoft Office Presentation (OpenXML) */
|
|
1018
|
+
PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
1019
|
+
/** RAR Archive */
|
|
1020
|
+
RAR: "application/vnd.rar",
|
|
1021
|
+
/** Rich Text Format */
|
|
1022
|
+
RTF: "application/rtf",
|
|
1023
|
+
/** Bourne Shell Script */
|
|
1024
|
+
SH: "application/x-sh",
|
|
1025
|
+
/** Scalable Vector Graphics (SVG) */
|
|
1026
|
+
SVG: "image/svg+xml",
|
|
1027
|
+
/** Tape Archive (TAR) */
|
|
1028
|
+
TAR: "application/x-tar",
|
|
1029
|
+
/** Tagged Image File Format (TIFF) */
|
|
1030
|
+
TIFF: "image/tiff",
|
|
1031
|
+
/** MPEG transport stream */
|
|
1032
|
+
TRANSPORT_STREAM: "video/mp2t",
|
|
1033
|
+
/** TrueType Font */
|
|
1034
|
+
TTF: "font/ttf",
|
|
1035
|
+
/** Text, (generally ASCII or ISO 8859-n) */
|
|
1036
|
+
TEXT: "text/plain",
|
|
1037
|
+
/** Microsoft Visio */
|
|
1038
|
+
VSD: "application/vnd.visio",
|
|
1039
|
+
/** Waveform Audio Format (WAV) */
|
|
1040
|
+
WAV: "audio/wav",
|
|
1041
|
+
/** Open Web Media Project - Audio */
|
|
1042
|
+
WEBA: "audio/webm",
|
|
1043
|
+
/** Open Web Media Project - Video */
|
|
1044
|
+
WEBM: "video/webm",
|
|
1045
|
+
/** WebP Image */
|
|
1046
|
+
WEBP: "image/webp",
|
|
1047
|
+
/** Web Open Font Format */
|
|
1048
|
+
WOFF: "font/woff",
|
|
1049
|
+
/** Web Open Font Format */
|
|
1050
|
+
WOFF2: "font/woff2",
|
|
1051
|
+
/** Form - Encoded */
|
|
1052
|
+
FORM: "application/x-www-form-urlencoded",
|
|
1053
|
+
/** Multipart FormData */
|
|
1054
|
+
MULTIPART_FORM_DATA: "multipart/form-data",
|
|
1055
|
+
/** XHTML - The Extensible HyperText Markup Language */
|
|
1056
|
+
XHTML: "application/xhtml+xml",
|
|
1057
|
+
/** Microsoft Excel Document */
|
|
1058
|
+
XLS: "application/vnd.ms-excel",
|
|
1059
|
+
/** Microsoft Office Spreadsheet Document (OpenXML) */
|
|
1060
|
+
XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
1061
|
+
/** Extensible Markup Language (XML) */
|
|
1062
|
+
XML: "application/xml",
|
|
1063
|
+
/** XML User Interface Language (XUL) */
|
|
1064
|
+
XUL: "application/vnd.mozilla.xul+xml",
|
|
1065
|
+
/** Zip Archive */
|
|
1066
|
+
ZIP: "application/zip",
|
|
1067
|
+
/** 3GPP audio/video container */
|
|
1068
|
+
"3GP": "video/3gpp",
|
|
1069
|
+
/** 3GPP2 audio/video container */
|
|
1070
|
+
"3G2": "video/3gpp2",
|
|
1071
|
+
/** 7-Zip Archive */
|
|
1072
|
+
"7Z": "application/x-7z-compressed"
|
|
1073
|
+
};
|
|
1074
|
+
var http_media_type_default = HttpMediaType;
|
|
1075
|
+
|
|
1076
|
+
// src/constants.js
|
|
1077
|
+
var defaultCharset = "utf-8";
|
|
1078
|
+
var endsWithSlashRegEx = /\/$/;
|
|
1079
|
+
var mediaTypes = /* @__PURE__ */ new Map([
|
|
1080
|
+
[http_media_type_default.PNG, new MediaType(http_media_type_default.PNG)],
|
|
1081
|
+
[http_media_type_default.TEXT, new MediaType(http_media_type_default.TEXT, { defaultCharset })],
|
|
1082
|
+
[http_media_type_default.JSON, new MediaType(http_media_type_default.JSON, { defaultCharset })],
|
|
1083
|
+
[http_media_type_default.HTML, new MediaType(http_media_type_default.HTML, { defaultCharset })],
|
|
1084
|
+
[http_media_type_default.JAVA_SCRIPT, new MediaType(http_media_type_default.JAVA_SCRIPT, { defaultCharset })],
|
|
1085
|
+
[http_media_type_default.CSS, new MediaType(http_media_type_default.CSS, { defaultCharset })],
|
|
1086
|
+
[http_media_type_default.XML, new MediaType(http_media_type_default.XML, { defaultCharset })],
|
|
1087
|
+
[http_media_type_default.BIN, new MediaType(http_media_type_default.BIN)]
|
|
1088
|
+
]);
|
|
1089
|
+
var RequestEvents = Object.freeze({
|
|
1090
|
+
CONFIGURED: "configured",
|
|
1091
|
+
SUCCESS: "success",
|
|
1092
|
+
ERROR: "error",
|
|
1093
|
+
ABORTED: "aborted",
|
|
1094
|
+
TIMEOUT: "timeout",
|
|
1095
|
+
COMPLETE: "complete",
|
|
1096
|
+
ALL_COMPLETE: "all-complete"
|
|
1097
|
+
});
|
|
1098
|
+
var SignalEvents = Object.freeze({
|
|
1099
|
+
ABORT: "abort",
|
|
1100
|
+
TIMEOUT: "timeout"
|
|
1101
|
+
});
|
|
1102
|
+
var _abortEvent = new CustomEvent(SignalEvents.ABORT, { detail: { cause: new DOMException("The request was aborted", "AbortError") } });
|
|
1103
|
+
var requestBodyMethods = [http_request_methods_default.POST, http_request_methods_default.PUT, http_request_methods_default.PATCH];
|
|
1104
|
+
var internalServerError = new ResponseStatus(500, "Internal Server Error");
|
|
1105
|
+
var eventResponseStatuses = Object.freeze({
|
|
1106
|
+
[RequestEvents.ABORTED]: new ResponseStatus(499, "Aborted"),
|
|
1107
|
+
[RequestEvents.TIMEOUT]: new ResponseStatus(504, "Request Timeout")
|
|
1108
|
+
});
|
|
1109
|
+
var abortSignalProxyHandler = { get: (target, property) => property == "signal" ? target.signal.timeout(target.timeout) : Reflect.get(target, property) };
|
|
1110
|
+
|
|
1111
|
+
// src/abort-signal.js
|
|
1112
|
+
var AbortSignal = class extends EventTarget {
|
|
1113
|
+
/** @type {AbortController} */
|
|
1114
|
+
#abortController;
|
|
1115
|
+
/** @type {number} */
|
|
1116
|
+
#timeoutId;
|
|
1045
1117
|
/**
|
|
1046
|
-
*
|
|
1047
|
-
*
|
|
1048
|
-
* @example
|
|
1049
|
-
* accept-ranges: bytes
|
|
1050
|
-
* Permanent
|
|
1118
|
+
* @param {AbortSignal} signal The signal to listen to
|
|
1051
1119
|
*/
|
|
1052
|
-
|
|
1120
|
+
constructor(signal) {
|
|
1121
|
+
super();
|
|
1122
|
+
this.#abortController = new AbortController();
|
|
1123
|
+
signal?.addEventListener(SignalEvents.ABORT, (event) => this.#abort(event));
|
|
1124
|
+
}
|
|
1053
1125
|
/**
|
|
1054
|
-
* The
|
|
1126
|
+
* The aborted property is a Boolean that indicates whether the request has been aborted (true) or not (false).
|
|
1055
1127
|
*
|
|
1056
|
-
* @
|
|
1057
|
-
* age: 12
|
|
1058
|
-
* Permanent
|
|
1128
|
+
* @returns {boolean} Whether the signal was aborted or not
|
|
1059
1129
|
*/
|
|
1060
|
-
|
|
1130
|
+
get aborted() {
|
|
1131
|
+
return this.#abortController.signal.aborted;
|
|
1132
|
+
}
|
|
1061
1133
|
/**
|
|
1062
|
-
*
|
|
1134
|
+
* The reason property returns a DOMException object indicating the reason the operation was aborted, or null if the operation is not aborted.
|
|
1063
1135
|
*
|
|
1064
|
-
* @
|
|
1065
|
-
* allow: GET, HEAD
|
|
1066
|
-
* Permanent
|
|
1136
|
+
* @returns {DOMException} The reason the signal was aborted
|
|
1067
1137
|
*/
|
|
1068
|
-
|
|
1138
|
+
get reason() {
|
|
1139
|
+
return this.#abortController.signal.reason;
|
|
1140
|
+
}
|
|
1069
1141
|
/**
|
|
1070
|
-
*
|
|
1142
|
+
* Returns an AbortSignal instance that will be aborted when the provided amount of milliseconds have passed.
|
|
1143
|
+
* A value of {@link Infinity} means there is no timeout.
|
|
1144
|
+
* Note: You can't set this property to a value less than 0.
|
|
1071
1145
|
*
|
|
1072
|
-
* @
|
|
1073
|
-
*
|
|
1074
|
-
* Permanent
|
|
1146
|
+
* @param {number} timeout The timeout in milliseconds
|
|
1147
|
+
* @returns {AbortSignal} The abort signal
|
|
1075
1148
|
*/
|
|
1076
|
-
|
|
1149
|
+
timeout(timeout) {
|
|
1150
|
+
if (timeout < 0) {
|
|
1151
|
+
throw new RangeError("The timeout cannot be negative");
|
|
1152
|
+
}
|
|
1153
|
+
if (timeout != Infinity) {
|
|
1154
|
+
this.#timeoutId ??= setTimeout(() => this.#abort(new CustomEvent(SignalEvents.TIMEOUT, { detail: { timeout, cause: new DOMException(`The request timed-out after ${timeout / 1e3} seconds`, "TimeoutError") } }), true), timeout);
|
|
1155
|
+
}
|
|
1156
|
+
return this.#abortController.signal;
|
|
1157
|
+
}
|
|
1077
1158
|
/**
|
|
1078
|
-
*
|
|
1159
|
+
* Clears the timeout.
|
|
1160
|
+
* Note: This does not abort the signal, dispatch the timeout event, or reset the timeout.
|
|
1079
1161
|
*
|
|
1080
|
-
* @
|
|
1081
|
-
* connection: close
|
|
1082
|
-
* Permanent
|
|
1162
|
+
* @returns {void}
|
|
1083
1163
|
*/
|
|
1084
|
-
|
|
1164
|
+
clearTimeout() {
|
|
1165
|
+
clearTimeout(this.#timeoutId);
|
|
1166
|
+
}
|
|
1085
1167
|
/**
|
|
1086
|
-
*
|
|
1168
|
+
* Adds an event listener for the 'abort' event.
|
|
1087
1169
|
*
|
|
1088
|
-
* @
|
|
1089
|
-
*
|
|
1090
|
-
* Permanent
|
|
1170
|
+
* @param {EventListener} listener The listener to add
|
|
1171
|
+
* @returns {AbortSignal} The AbortSignal
|
|
1091
1172
|
*/
|
|
1092
|
-
|
|
1173
|
+
onAbort(listener) {
|
|
1174
|
+
this.#abortController.signal.addEventListener(SignalEvents.ABORT, listener);
|
|
1175
|
+
return this;
|
|
1176
|
+
}
|
|
1093
1177
|
/**
|
|
1094
|
-
*
|
|
1178
|
+
* Adds an event listener for the 'timeout' event.
|
|
1095
1179
|
*
|
|
1096
|
-
* @
|
|
1097
|
-
*
|
|
1098
|
-
* Permanent
|
|
1180
|
+
* @param {EventListener} listener The listener to add
|
|
1181
|
+
* @returns {AbortSignal} The AbortSignal
|
|
1099
1182
|
*/
|
|
1100
|
-
|
|
1183
|
+
onTimeout(listener) {
|
|
1184
|
+
this.#abortController.signal.addEventListener(SignalEvents.TIMEOUT, listener);
|
|
1185
|
+
return this;
|
|
1186
|
+
}
|
|
1101
1187
|
/**
|
|
1102
|
-
*
|
|
1188
|
+
* Aborts the signal. This is so naughty. ¯\_(ツ)_/¯
|
|
1103
1189
|
*
|
|
1104
|
-
* @
|
|
1105
|
-
*
|
|
1106
|
-
* Permanent
|
|
1190
|
+
* @param {Event} event The event to abort with
|
|
1191
|
+
* @returns {void}
|
|
1107
1192
|
*/
|
|
1108
|
-
|
|
1193
|
+
abort(event) {
|
|
1194
|
+
this.#abort(event);
|
|
1195
|
+
}
|
|
1109
1196
|
/**
|
|
1110
|
-
*
|
|
1197
|
+
* Aborts the signal.
|
|
1111
1198
|
*
|
|
1112
|
-
* @
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1199
|
+
* @private
|
|
1200
|
+
* @param {Event} event The event to abort with
|
|
1201
|
+
* @param {boolean} [dispatchEvent = false] Whether to dispatch the event or not
|
|
1202
|
+
* @returns {void}
|
|
1203
|
+
* @fires SignalEvents.ABORT When the signal is aborted
|
|
1204
|
+
* @fires SignalEvents.TIMEOUT When the signal times out
|
|
1115
1205
|
*/
|
|
1116
|
-
|
|
1206
|
+
#abort(event = _abortEvent, dispatchEvent = false) {
|
|
1207
|
+
clearTimeout(this.#timeoutId);
|
|
1208
|
+
this.#abortController.abort(event.detail?.cause);
|
|
1209
|
+
if (dispatchEvent) {
|
|
1210
|
+
this.#abortController.signal.dispatchEvent(event);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
// src/http-error.js
|
|
1216
|
+
var HttpError = class extends Error {
|
|
1217
|
+
/** @type {ResponseBody} */
|
|
1218
|
+
#entity;
|
|
1219
|
+
/** @type {ResponseStatus} */
|
|
1220
|
+
#responseStatus;
|
|
1117
1221
|
/**
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1120
|
-
* @
|
|
1121
|
-
*
|
|
1122
|
-
*
|
|
1222
|
+
* @param {string} [message] The error message.
|
|
1223
|
+
* @param {HttpErrorOptions} [httpErrorOptions] The http error options.
|
|
1224
|
+
* @param {any} [httpErrorOptions.cause] The cause of the error.
|
|
1225
|
+
* @param {ResponseStatus} [httpErrorOptions.status] The response status.
|
|
1226
|
+
* @param {ResponseBody} [httpErrorOptions.entity] The error entity from the server, if any.
|
|
1123
1227
|
*/
|
|
1124
|
-
|
|
1228
|
+
constructor(message, { cause, status, entity }) {
|
|
1229
|
+
super(message, { cause });
|
|
1230
|
+
this.#entity = entity;
|
|
1231
|
+
this.#responseStatus = status;
|
|
1232
|
+
}
|
|
1125
1233
|
/**
|
|
1126
|
-
*
|
|
1234
|
+
* It returns the value of the private variable #entity.
|
|
1127
1235
|
*
|
|
1128
|
-
* @
|
|
1129
|
-
* content-range: bytes 21010-47021/47022
|
|
1130
|
-
* Permanent
|
|
1236
|
+
* @returns {ResponseBody} The entity property of the class.
|
|
1131
1237
|
*/
|
|
1132
|
-
|
|
1238
|
+
get entity() {
|
|
1239
|
+
return this.#entity;
|
|
1240
|
+
}
|
|
1133
1241
|
/**
|
|
1134
|
-
*
|
|
1242
|
+
* It returns the status code of the {@link Response}.
|
|
1135
1243
|
*
|
|
1136
|
-
* @
|
|
1137
|
-
* content-type: text/html, charset=utf-8
|
|
1138
|
-
* Permanent
|
|
1244
|
+
* @returns {number} The status code of the {@link Response}.
|
|
1139
1245
|
*/
|
|
1140
|
-
|
|
1246
|
+
get statusCode() {
|
|
1247
|
+
return this.#responseStatus?.code;
|
|
1248
|
+
}
|
|
1141
1249
|
/**
|
|
1142
|
-
*
|
|
1250
|
+
* It returns the status text of the {@link Response}.
|
|
1143
1251
|
*
|
|
1144
|
-
* @
|
|
1145
|
-
* date: Tue, 15 Nov 1994 08:12:31 GMT
|
|
1146
|
-
* Permanent
|
|
1252
|
+
* @returns {string} The status code and status text of the {@link Response}.
|
|
1147
1253
|
*/
|
|
1148
|
-
|
|
1254
|
+
get statusText() {
|
|
1255
|
+
return this.#responseStatus?.text;
|
|
1256
|
+
}
|
|
1257
|
+
get name() {
|
|
1258
|
+
return "HttpError";
|
|
1259
|
+
}
|
|
1149
1260
|
/**
|
|
1150
|
-
*
|
|
1261
|
+
* A String value that is used in the creation of the default string
|
|
1262
|
+
* description of an object. Called by the built-in method {@link Object.prototype.toString}.
|
|
1151
1263
|
*
|
|
1152
|
-
* @
|
|
1153
|
-
* etag: "737060cd8c284d8af7ad3082f209582d"
|
|
1154
|
-
* Permanent
|
|
1264
|
+
* @returns {string} The default string description of this object.
|
|
1155
1265
|
*/
|
|
1156
|
-
|
|
1266
|
+
get [Symbol.toStringTag]() {
|
|
1267
|
+
return "HttpError";
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1271
|
+
// src/http-request-headers.js
|
|
1272
|
+
var HttpRequestHeader = {
|
|
1157
1273
|
/**
|
|
1158
|
-
*
|
|
1274
|
+
* Content-Types that are acceptable for the response. See Content negotiation. Permanent.
|
|
1159
1275
|
*
|
|
1160
1276
|
* @example
|
|
1161
|
-
*
|
|
1162
|
-
* Permanent
|
|
1277
|
+
* <code>Accept: text/plain</code>
|
|
1163
1278
|
*/
|
|
1164
|
-
|
|
1279
|
+
ACCEPT: "accept",
|
|
1165
1280
|
/**
|
|
1166
|
-
*
|
|
1281
|
+
* Character sets that are acceptable. Permanent.
|
|
1167
1282
|
*
|
|
1168
1283
|
* @example
|
|
1169
|
-
*
|
|
1170
|
-
* Permanent
|
|
1284
|
+
* <code>Accept-Charset: utf-8</code>
|
|
1171
1285
|
*/
|
|
1172
|
-
|
|
1286
|
+
ACCEPT_CHARSET: "accept-charset",
|
|
1173
1287
|
/**
|
|
1174
|
-
*
|
|
1288
|
+
* List of acceptable encodings. See HTTP compression. Permanent.
|
|
1175
1289
|
*
|
|
1176
1290
|
* @example
|
|
1177
|
-
*
|
|
1178
|
-
* Permanent
|
|
1291
|
+
* <code>Accept-Encoding: gzip, deflate</code>
|
|
1179
1292
|
*/
|
|
1180
|
-
|
|
1293
|
+
ACCEPT_ENCODING: "accept-encoding",
|
|
1181
1294
|
/**
|
|
1182
|
-
*
|
|
1295
|
+
* List of acceptable human languages for response. See Content negotiation. Permanent.
|
|
1183
1296
|
*
|
|
1184
1297
|
* @example
|
|
1185
|
-
*
|
|
1186
|
-
* Permanent
|
|
1298
|
+
* <code>Accept-Language: en-US</code>
|
|
1187
1299
|
*/
|
|
1188
|
-
|
|
1300
|
+
ACCEPT_LANGUAGE: "accept-language",
|
|
1189
1301
|
/**
|
|
1190
|
-
*
|
|
1191
|
-
* implemented it, a lot of websites set this field with fake policy text, that was enough to fool browsers the existence of P3P policy and grant permissions for third party cookies.
|
|
1302
|
+
* Authentication credentials for HTTP authentication. Permanent.
|
|
1192
1303
|
*
|
|
1193
1304
|
* @example
|
|
1194
|
-
*
|
|
1195
|
-
* Permanent
|
|
1305
|
+
* <code>Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</code>
|
|
1196
1306
|
*/
|
|
1197
|
-
|
|
1307
|
+
AUTHORIZATION: "authorization",
|
|
1198
1308
|
/**
|
|
1199
|
-
*
|
|
1309
|
+
* Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain.
|
|
1310
|
+
* Permanent.
|
|
1200
1311
|
*
|
|
1201
1312
|
* @example
|
|
1202
|
-
*
|
|
1203
|
-
* Permanent
|
|
1313
|
+
* <code>Cache-Control: no-cache</code>
|
|
1204
1314
|
*/
|
|
1205
|
-
|
|
1315
|
+
CACHE_CONTROL: "cache-control",
|
|
1206
1316
|
/**
|
|
1207
|
-
*
|
|
1317
|
+
* Control options for the current connection and list of hop-by-hop request fields. Permanent.
|
|
1208
1318
|
*
|
|
1209
1319
|
* @example
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1320
|
+
* <code>Connection: keep-alive</code>
|
|
1321
|
+
* <code>Connection: Upgrade</code>
|
|
1212
1322
|
*/
|
|
1213
|
-
|
|
1323
|
+
CONNECTION: "connection",
|
|
1214
1324
|
/**
|
|
1215
|
-
* HTTP
|
|
1325
|
+
* An HTTP cookie previously sent by the server with Set-Cookie (below). Permanent: standard.
|
|
1216
1326
|
*
|
|
1217
1327
|
* @example
|
|
1218
|
-
*
|
|
1219
|
-
* Permanent
|
|
1328
|
+
* <code>Cookie: $Version=1, Skin=new,</code>
|
|
1220
1329
|
*/
|
|
1221
|
-
|
|
1330
|
+
COOKIE: "cookie",
|
|
1222
1331
|
/**
|
|
1223
|
-
*
|
|
1332
|
+
* The length of the request body in octets (8-bit bytes). Permanent.
|
|
1224
1333
|
*
|
|
1225
1334
|
* @example
|
|
1226
|
-
*
|
|
1227
|
-
* retry-after: Fri, 07 Nov 2014 23:59:59 GMT
|
|
1228
|
-
* Permanent
|
|
1335
|
+
* <code>Content-Length: 348</code>
|
|
1229
1336
|
*/
|
|
1230
|
-
|
|
1337
|
+
CONTENT_LENGTH: "content-length",
|
|
1231
1338
|
/**
|
|
1232
|
-
* A
|
|
1339
|
+
* A Base64-encoded binary MD5 sum of the content of the request body. Obsolete.
|
|
1233
1340
|
*
|
|
1234
1341
|
* @example
|
|
1235
|
-
*
|
|
1236
|
-
* Permanent
|
|
1342
|
+
* <code>Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==</code>
|
|
1237
1343
|
*/
|
|
1238
|
-
|
|
1344
|
+
CONTENT_MD5: "content-md5",
|
|
1239
1345
|
/**
|
|
1240
|
-
*
|
|
1346
|
+
* The MIME type of the body of the request (used with POST and PUT requests). Permanent.
|
|
1347
|
+
* <code>Content-Type: application/x-www-form-urlencoded</code>
|
|
1348
|
+
*/
|
|
1349
|
+
CONTENT_TYPE: "content-type",
|
|
1350
|
+
/**
|
|
1351
|
+
* The date and time that the message was sent (in "HTTP-date" format as defined by RFC 7231 Date/Time Formats).
|
|
1352
|
+
* Permanent.
|
|
1241
1353
|
*
|
|
1242
1354
|
* @example
|
|
1243
|
-
*
|
|
1244
|
-
* Permanent
|
|
1355
|
+
* <code>Date: Tue, 15 Nov 1994 08:12:31 GMT</code>
|
|
1245
1356
|
*/
|
|
1246
|
-
|
|
1357
|
+
DATE: "date",
|
|
1247
1358
|
/**
|
|
1248
|
-
*
|
|
1359
|
+
* Indicates that particular server behaviors are required by the client. Permanent.
|
|
1249
1360
|
*
|
|
1250
1361
|
* @example
|
|
1251
|
-
*
|
|
1362
|
+
* <code>Expect: 100-continue</code>
|
|
1252
1363
|
*/
|
|
1253
|
-
|
|
1364
|
+
EXPECT: "expect",
|
|
1254
1365
|
/**
|
|
1255
|
-
*
|
|
1366
|
+
* The email address of the user making the request. Permanent.
|
|
1256
1367
|
*
|
|
1257
1368
|
* @example
|
|
1258
|
-
*
|
|
1259
|
-
* Permanent
|
|
1369
|
+
* <code>From: user@example.com</code>
|
|
1260
1370
|
*/
|
|
1261
|
-
|
|
1371
|
+
FROM: "from",
|
|
1262
1372
|
/**
|
|
1263
|
-
* The
|
|
1373
|
+
* The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The
|
|
1374
|
+
* port number may be omitted if the port is the standard port for the service requested. Permanent. Mandatory since
|
|
1375
|
+
* HTTP/1.1.
|
|
1264
1376
|
*
|
|
1265
1377
|
* @example
|
|
1266
|
-
*
|
|
1267
|
-
*
|
|
1378
|
+
* <code>Host: en.wikipedia.org:80</code>
|
|
1379
|
+
* <code>Host: en.wikipedia.org</code>
|
|
1268
1380
|
*/
|
|
1269
|
-
|
|
1381
|
+
HOST: "host",
|
|
1270
1382
|
/**
|
|
1271
|
-
*
|
|
1383
|
+
* Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for
|
|
1384
|
+
* methods like PUT to only update a resource if it has not been modified since the user last updated it. Permanent.
|
|
1272
1385
|
*
|
|
1273
1386
|
* @example
|
|
1274
|
-
*
|
|
1275
|
-
* Permanent
|
|
1387
|
+
* <code>If-Match: "737060cd8c284d8af7ad3082f209582d"</code>
|
|
1276
1388
|
*/
|
|
1277
|
-
|
|
1389
|
+
IF_MATCH: "if-match",
|
|
1278
1390
|
/**
|
|
1279
|
-
*
|
|
1391
|
+
* Allows a 304 Not Modified to be returned if content is unchanged. Permanent.
|
|
1280
1392
|
*
|
|
1281
1393
|
* @example
|
|
1282
|
-
*
|
|
1283
|
-
* Permanent
|
|
1394
|
+
* <code>If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT</code>
|
|
1284
1395
|
*/
|
|
1285
|
-
|
|
1396
|
+
IF_MODIFIED_SINCE: "if-modified-since",
|
|
1286
1397
|
/**
|
|
1287
|
-
*
|
|
1398
|
+
* Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag. Permanent.
|
|
1288
1399
|
*
|
|
1289
1400
|
* @example
|
|
1290
|
-
*
|
|
1291
|
-
* Permanent
|
|
1401
|
+
* <code>If-None-Match: "737060cd8c284d8af7ad3082f209582d"</code>
|
|
1292
1402
|
*/
|
|
1293
|
-
|
|
1403
|
+
IF_NONE_MATCH: "if-none-match",
|
|
1294
1404
|
/**
|
|
1295
|
-
*
|
|
1405
|
+
* If the entity is unchanged, send me the part(s) that I am missing, otherwise, send me the entire new entity.
|
|
1406
|
+
* Permanent.
|
|
1296
1407
|
*
|
|
1297
1408
|
* @example
|
|
1298
|
-
*
|
|
1299
|
-
* Permanent
|
|
1409
|
+
* <code>If-Range: "737060cd8c284d8af7ad3082f209582d"</code>
|
|
1300
1410
|
*/
|
|
1301
|
-
|
|
1411
|
+
IF_RANGE: "if-range",
|
|
1302
1412
|
/**
|
|
1303
|
-
*
|
|
1413
|
+
* Only send the response if the entity has not been modified since a specific time. Permanent.
|
|
1304
1414
|
*
|
|
1305
1415
|
* @example
|
|
1306
|
-
*
|
|
1307
|
-
* Permanent
|
|
1416
|
+
* <code>If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT</code>
|
|
1308
1417
|
*/
|
|
1309
|
-
|
|
1418
|
+
IF_UNMODIFIED_SINCE: "if-unmodified-since",
|
|
1310
1419
|
/**
|
|
1311
|
-
*
|
|
1420
|
+
* Limit the number of times the message can be forwarded through proxies or gateways. Permanent.
|
|
1312
1421
|
*
|
|
1313
1422
|
* @example
|
|
1314
|
-
*
|
|
1315
|
-
* Permanent
|
|
1423
|
+
* <code>Max-Forwards: 10</code>
|
|
1316
1424
|
*/
|
|
1317
|
-
|
|
1425
|
+
MAX_FORWARDS: "max-forwards",
|
|
1318
1426
|
/**
|
|
1319
|
-
*
|
|
1427
|
+
* Initiates a request for cross-origin resource sharing (asks server for an 'Access-Control-Allow-Origin' response
|
|
1428
|
+
* field). Permanent: standard.
|
|
1320
1429
|
*
|
|
1321
1430
|
* @example
|
|
1322
|
-
*
|
|
1431
|
+
* <code>Origin: http://www.example-social-network.com</code>
|
|
1323
1432
|
*/
|
|
1324
|
-
|
|
1433
|
+
ORIGIN: "origin",
|
|
1325
1434
|
/**
|
|
1326
|
-
*
|
|
1327
|
-
* to load for a given page. With a few exceptions, policies mostly involve specifying server origins and script endpoints.
|
|
1328
|
-
* This helps guard against cross-site scripting attacks (Cross-site_scripting).
|
|
1435
|
+
* Implementation-specific fields that may have various effects anywhere along the request-response chain. Permanent.
|
|
1329
1436
|
*
|
|
1330
1437
|
* @example
|
|
1331
|
-
*
|
|
1438
|
+
* <code>Pragma: no-cache</code>
|
|
1332
1439
|
*/
|
|
1333
|
-
|
|
1440
|
+
PRAGMA: "pragma",
|
|
1334
1441
|
/**
|
|
1335
|
-
*
|
|
1442
|
+
* Authorization credentials for connecting to a proxy. Permanent.
|
|
1336
1443
|
*
|
|
1337
1444
|
* @example
|
|
1338
|
-
*
|
|
1445
|
+
* <code>Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</code>
|
|
1339
1446
|
*/
|
|
1340
|
-
|
|
1447
|
+
PROXY_AUTHORIZATION: "proxy-authorization",
|
|
1341
1448
|
/**
|
|
1342
|
-
*
|
|
1449
|
+
* Request only part of an entity. Bytes are numbered from 0. See Byte serving. Permanent.
|
|
1343
1450
|
*
|
|
1344
1451
|
* @example
|
|
1345
|
-
*
|
|
1452
|
+
* <code>Range: bytes=500-999</code>
|
|
1346
1453
|
*/
|
|
1347
|
-
|
|
1348
|
-
};
|
|
1349
|
-
var http_response_headers_default = HttpResponseHeader;
|
|
1350
|
-
|
|
1351
|
-
// src/response-status.js
|
|
1352
|
-
var ResponseStatus = class {
|
|
1353
|
-
/** @type {number} */
|
|
1354
|
-
#code;
|
|
1355
|
-
/** @type {string} */
|
|
1356
|
-
#text;
|
|
1454
|
+
RANGE: "range",
|
|
1357
1455
|
/**
|
|
1456
|
+
* This is the address of the previous web page from which a link to the currently requested page was followed. (The
|
|
1457
|
+
* word "referrer" has been misspelled in the RFC as well as in most implementations to the point that it has become
|
|
1458
|
+
* standard usage and is considered correct terminology). Permanent.
|
|
1358
1459
|
*
|
|
1359
|
-
* @
|
|
1360
|
-
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* <code>Referer: http://en.wikipedia.org/wiki/Main_Page</code>
|
|
1361
1462
|
*/
|
|
1362
|
-
|
|
1363
|
-
this.#code = code;
|
|
1364
|
-
this.#text = text;
|
|
1365
|
-
}
|
|
1463
|
+
REFERER: "referer",
|
|
1366
1464
|
/**
|
|
1367
|
-
*
|
|
1465
|
+
* The transfer encodings the user agent is willing to accept: the same values as for the response header field
|
|
1466
|
+
* Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the
|
|
1467
|
+
* server it expects to receive additional fields in the trailer after the last, zero-sized, chunk. Permanent.
|
|
1368
1468
|
*
|
|
1369
|
-
* @
|
|
1469
|
+
* @example
|
|
1470
|
+
* <code>TE: trailers, deflate</code>
|
|
1370
1471
|
*/
|
|
1371
|
-
|
|
1372
|
-
return this.#code;
|
|
1373
|
-
}
|
|
1472
|
+
TE: "te",
|
|
1374
1473
|
/**
|
|
1375
|
-
*
|
|
1474
|
+
* The user agent string of the user agent. Permanent.
|
|
1376
1475
|
*
|
|
1377
|
-
* @
|
|
1476
|
+
* @example
|
|
1477
|
+
* <code>User-Agent: Mozilla/5.0 (X11, Linux x86_64, rv:12.0) Gecko/20100101 Firefox/21.0</code>
|
|
1378
1478
|
*/
|
|
1379
|
-
|
|
1380
|
-
return this.#text;
|
|
1381
|
-
}
|
|
1479
|
+
USER_AGENT: "user-agent",
|
|
1382
1480
|
/**
|
|
1383
|
-
*
|
|
1384
|
-
* description of an object. Called by the built-in method {@link Object.prototype.toString}.
|
|
1481
|
+
* Ask the server to upgrade to another protocol. Permanent.
|
|
1385
1482
|
*
|
|
1386
|
-
* @
|
|
1387
|
-
*
|
|
1483
|
+
* @example
|
|
1484
|
+
* <code>Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11</code>
|
|
1388
1485
|
*/
|
|
1389
|
-
|
|
1390
|
-
return "ResponseStatus";
|
|
1391
|
-
}
|
|
1486
|
+
UPGRADE: "upgrade",
|
|
1392
1487
|
/**
|
|
1393
|
-
*
|
|
1488
|
+
* Informs the server of proxies through which the request was sent. Permanent.
|
|
1394
1489
|
*
|
|
1395
|
-
* @
|
|
1396
|
-
*
|
|
1397
|
-
* @returns {string} The status code and status text.
|
|
1490
|
+
* @example
|
|
1491
|
+
* <code>Via: 1.0 fred, 1.1 example.com (Apache/1.1)</code>
|
|
1398
1492
|
*/
|
|
1399
|
-
|
|
1400
|
-
return `${this.#code} ${this.#text}`;
|
|
1401
|
-
}
|
|
1402
|
-
};
|
|
1403
|
-
|
|
1404
|
-
// src/parameter-map.js
|
|
1405
|
-
var ParameterMap = class _ParameterMap extends Map {
|
|
1493
|
+
VIA: "via",
|
|
1406
1494
|
/**
|
|
1407
|
-
*
|
|
1408
|
-
*
|
|
1495
|
+
* A general warning about possible problems with the entity body. Permanent.
|
|
1496
|
+
*
|
|
1497
|
+
* @example
|
|
1498
|
+
* <code>Warning: 199 Miscellaneous warning</code>
|
|
1409
1499
|
*/
|
|
1410
|
-
|
|
1411
|
-
super();
|
|
1412
|
-
for (const [key, value] of _ParameterMap.#entries(parameters)) {
|
|
1413
|
-
this.append(key, value);
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1500
|
+
WARNING: "warning",
|
|
1416
1501
|
/**
|
|
1417
|
-
*
|
|
1418
|
-
* If an element with the same key already exists, the value will be replaced in the underlying {@link Set}.
|
|
1502
|
+
* mainly used to identify Ajax requests. Most JavaScript frameworks send this field with value of XMLHttpRequest.
|
|
1419
1503
|
*
|
|
1420
|
-
* @
|
|
1421
|
-
*
|
|
1422
|
-
* @param {*} value The value to add to the ParameterMap
|
|
1423
|
-
* @returns {ParameterMap<string, *>} The ParameterMap with the updated key and value.
|
|
1504
|
+
* @example
|
|
1505
|
+
* <code>X-Requested-With: XMLHttpRequest</code>
|
|
1424
1506
|
*/
|
|
1425
|
-
|
|
1426
|
-
const array = super.get(key);
|
|
1427
|
-
if (array?.length > 0) {
|
|
1428
|
-
array.length = 0;
|
|
1429
|
-
array[0] = value;
|
|
1430
|
-
} else {
|
|
1431
|
-
super.set(key, [value]);
|
|
1432
|
-
}
|
|
1433
|
-
return this;
|
|
1434
|
-
}
|
|
1507
|
+
X_REQUESTED_WITH: "x-requested-with",
|
|
1435
1508
|
/**
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1509
|
+
* Requests a web application to disable their tracking of a user. This is Mozilla's version of the X-Do-Not-Track
|
|
1510
|
+
* header field (since Firefox 4.0 Beta 11). Safari and IE9 also have support for this field. On March 7, 2011, a
|
|
1511
|
+
* draft proposal was submitted to IETF. The W3C Tracking Protection Working Group is producing a specification.
|
|
1438
1512
|
*
|
|
1439
|
-
* @
|
|
1440
|
-
*
|
|
1513
|
+
* @example
|
|
1514
|
+
* <code>DNT: 1 (Do Not Track Enabled)</code>
|
|
1515
|
+
* <code>DNT: 0 (Do Not Track Disabled)</code>
|
|
1441
1516
|
*/
|
|
1442
|
-
|
|
1443
|
-
for (const [key, value] of _ParameterMap.#entries(parameters)) {
|
|
1444
|
-
this.set(key, value);
|
|
1445
|
-
}
|
|
1446
|
-
return this;
|
|
1447
|
-
}
|
|
1517
|
+
DNT: "dnt",
|
|
1448
1518
|
/**
|
|
1449
|
-
*
|
|
1450
|
-
*
|
|
1451
|
-
* If the key has no values, undefined will be returned.
|
|
1519
|
+
* A de facto standard for identifying the originating IP address of a client connecting to a web server through an
|
|
1520
|
+
* HTTP proxy or load balancer.
|
|
1452
1521
|
*
|
|
1453
|
-
* @
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1522
|
+
* @example
|
|
1523
|
+
* <code>X-Forwarded-For: client1, proxy1, proxy2</code>
|
|
1524
|
+
* <code>X-Forwarded-For: 129.78.138.66, 129.78.64.103</code>
|
|
1456
1525
|
*/
|
|
1457
|
-
|
|
1458
|
-
return super.get(key)?.[0];
|
|
1459
|
-
}
|
|
1526
|
+
X_FORWARDED_FOR: "x-forwarded-for",
|
|
1460
1527
|
/**
|
|
1461
|
-
*
|
|
1528
|
+
* A de facto standard for identifying the original host requested by the client in the Host HTTP request header, since
|
|
1529
|
+
* the host name and/or port of the reverse proxy (load balancer) may differ from the origin server handling the
|
|
1530
|
+
* request.
|
|
1462
1531
|
*
|
|
1463
|
-
* @
|
|
1464
|
-
*
|
|
1532
|
+
* @example
|
|
1533
|
+
* <code>X-Forwarded-Host: en.wikipedia.org:80</code>
|
|
1534
|
+
* <code>X-Forwarded-Host: en.wikipedia.org</code>
|
|
1465
1535
|
*/
|
|
1466
|
-
|
|
1467
|
-
return super.get(key);
|
|
1468
|
-
}
|
|
1536
|
+
X_FORWARDED_HOST: "x-forwarded-host",
|
|
1469
1537
|
/**
|
|
1470
|
-
*
|
|
1538
|
+
* A de facto standard for identifying the originating protocol of an HTTP request, since a reverse proxy (load
|
|
1539
|
+
* balancer) may communicate with a web server using HTTP even if the request to the reverse proxy is HTTPS. An
|
|
1540
|
+
* alternative form of the header (X-ProxyUser-Ip) is used by Google clients talking to Google servers.
|
|
1471
1541
|
*
|
|
1472
|
-
* @
|
|
1473
|
-
*
|
|
1474
|
-
* @returns {ParameterMap<string, *>} The ParameterMap with the updated key and value to allow chaining.
|
|
1542
|
+
* @example
|
|
1543
|
+
* <code>X-Forwarded-Proto: https</code>
|
|
1475
1544
|
*/
|
|
1476
|
-
|
|
1477
|
-
const array = super.get(key);
|
|
1478
|
-
if (array?.length > 0) {
|
|
1479
|
-
array.push(value);
|
|
1480
|
-
} else {
|
|
1481
|
-
super.set(key, [value]);
|
|
1482
|
-
}
|
|
1483
|
-
return this;
|
|
1484
|
-
}
|
|
1545
|
+
X_FORWARDED_PROTO: "x-forwarded-proto",
|
|
1485
1546
|
/**
|
|
1486
|
-
*
|
|
1487
|
-
* If a key already exists, the value will be appended to the underlying {@link Array}.
|
|
1488
|
-
* If a key does not exist, the key and value will be added to the ParameterMap.
|
|
1547
|
+
* Non-standard header field used by Microsoft applications and load-balancers.
|
|
1489
1548
|
*
|
|
1490
|
-
* @
|
|
1491
|
-
*
|
|
1549
|
+
* @example
|
|
1550
|
+
* <code>Front-End-Https: on</code>
|
|
1492
1551
|
*/
|
|
1493
|
-
|
|
1494
|
-
for (const [key, value] of _ParameterMap.#entries(parameters)) {
|
|
1495
|
-
this.append(key, value);
|
|
1496
|
-
}
|
|
1497
|
-
return this;
|
|
1498
|
-
}
|
|
1552
|
+
FRONT_END_HTTPS: "front-end-https",
|
|
1499
1553
|
/**
|
|
1500
|
-
*
|
|
1554
|
+
* Requests a web application override the method specified in the request (typically POST) with the method given in
|
|
1555
|
+
* the header field (typically PUT or DELETE). Can be used when a user agent or firewall prevents PUT or DELETE methods
|
|
1556
|
+
* from being sent directly (note that this either a bug in the software component, which ought to be fixed, or an
|
|
1557
|
+
* intentional configuration, in which case bypassing it may be the wrong thing to do).
|
|
1501
1558
|
*
|
|
1502
|
-
* @
|
|
1503
|
-
*
|
|
1559
|
+
* @example
|
|
1560
|
+
* <code>X-HTTP-Method-Override: DELETE</code>
|
|
1504
1561
|
*/
|
|
1505
|
-
|
|
1506
|
-
for (const array of super.values()) {
|
|
1507
|
-
if (array.includes(value)) {
|
|
1508
|
-
return true;
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
return false;
|
|
1512
|
-
}
|
|
1562
|
+
X_HTTP_METHOD_OVERRIDE: "x-http-method-override",
|
|
1513
1563
|
/**
|
|
1514
|
-
*
|
|
1564
|
+
* Allows easier parsing of the MakeModel/Firmware that is usually found in the User-Agent String of AT&T Devices.
|
|
1515
1565
|
*
|
|
1516
|
-
* @
|
|
1517
|
-
*
|
|
1566
|
+
* @example
|
|
1567
|
+
* <code>X-Att-Deviceid: GT-P7320/P7320XXLPG</code>
|
|
1518
1568
|
*/
|
|
1519
|
-
|
|
1520
|
-
for (const array of this.values()) {
|
|
1521
|
-
if (array.includes(value)) {
|
|
1522
|
-
return array.splice(array.indexOf(value), 1).length > 0;
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
return false;
|
|
1526
|
-
}
|
|
1569
|
+
X_ATT_DEVICE_ID: "x-att-deviceid",
|
|
1527
1570
|
/**
|
|
1528
|
-
*
|
|
1571
|
+
* Links to an XML file on the Internet with a full description and details about the device currently connecting. In the example to the right is an XML file for an AT&T Samsung Galaxy S2.
|
|
1572
|
+
* x-wap-profile: http://wap.samsungmobile.com/uaprof/SGH-I777.xml
|
|
1573
|
+
*/
|
|
1574
|
+
X_WAP_PROFILE: "x-wap-profile"
|
|
1575
|
+
};
|
|
1576
|
+
var http_request_headers_default = HttpRequestHeader;
|
|
1577
|
+
|
|
1578
|
+
// src/http-response-headers.js
|
|
1579
|
+
var HttpResponseHeader = {
|
|
1580
|
+
/**
|
|
1581
|
+
* Implemented as a misunderstanding of the HTTP specifications. Common because of mistakes in implementations of early HTTP versions. Has exactly the same functionality as standard Connection field.
|
|
1529
1582
|
*
|
|
1530
|
-
* @
|
|
1583
|
+
* @example
|
|
1584
|
+
* proxy-connection: keep-alive
|
|
1531
1585
|
*/
|
|
1532
|
-
|
|
1533
|
-
return this.size === 0;
|
|
1534
|
-
}
|
|
1586
|
+
PROXY_CONNECTION: "proxy-connection",
|
|
1535
1587
|
/**
|
|
1536
|
-
*
|
|
1537
|
-
* If a key has only one value, the value will be a single value.
|
|
1538
|
-
* If a key has multiple values, the value will be an array of values.
|
|
1539
|
-
* If a key has no values, the value will be undefined.
|
|
1588
|
+
* Server-side deep packet insertion of a unique ID identifying customers of Verizon Wireless, also known as "perma-cookie" or "supercookie"
|
|
1540
1589
|
*
|
|
1541
|
-
* @
|
|
1542
|
-
*
|
|
1543
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON_behavior}
|
|
1590
|
+
* @example
|
|
1591
|
+
* x-uidh: ...
|
|
1544
1592
|
*/
|
|
1545
|
-
|
|
1546
|
-
const obj = /* @__PURE__ */ Object.create(null);
|
|
1547
|
-
for (const [key, values] of super.entries()) {
|
|
1548
|
-
obj[key] = values.length === 1 ? values[0] : values;
|
|
1549
|
-
}
|
|
1550
|
-
return obj;
|
|
1551
|
-
}
|
|
1593
|
+
X_UIDH: "x-uidh",
|
|
1552
1594
|
/**
|
|
1553
|
-
*
|
|
1595
|
+
* Used to prevent cross-site request forgery. Alternative header names are: X-CSRFToken and X-XSRF-TOKEN
|
|
1554
1596
|
*
|
|
1555
|
-
* @
|
|
1556
|
-
*
|
|
1597
|
+
* @example
|
|
1598
|
+
* x-csrf-token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
|
|
1557
1599
|
*/
|
|
1558
|
-
|
|
1559
|
-
for (const [key, array] of super.entries()) {
|
|
1560
|
-
for (const value of array) {
|
|
1561
|
-
yield [key, value];
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1600
|
+
X_CSRF_TOKEN: "x-csrf-token",
|
|
1565
1601
|
/**
|
|
1566
|
-
*
|
|
1602
|
+
* Specifying which web sites can participate in cross-origin resource sharing
|
|
1567
1603
|
*
|
|
1568
|
-
* @
|
|
1569
|
-
*
|
|
1604
|
+
* @example
|
|
1605
|
+
* access-control-allow-origin: *
|
|
1606
|
+
* Provisional
|
|
1570
1607
|
*/
|
|
1571
|
-
|
|
1572
|
-
yield* this.entries();
|
|
1573
|
-
}
|
|
1608
|
+
ACCESS_CONTROL_ALLOW_ORIGIN: "access-control-allow-origin",
|
|
1574
1609
|
/**
|
|
1575
|
-
*
|
|
1610
|
+
* Specifies which patch document formats this server supports
|
|
1576
1611
|
*
|
|
1577
|
-
* @
|
|
1578
|
-
*
|
|
1579
|
-
*
|
|
1580
|
-
* @returns {Iterable<[string, *]>} An iterable of key, value pairs for every entry in the parameters object.
|
|
1612
|
+
* @example
|
|
1613
|
+
* accept-patch: text/example,charset=utf-8
|
|
1614
|
+
* Permanent
|
|
1581
1615
|
*/
|
|
1582
|
-
|
|
1583
|
-
return parameters[Symbol.iterator] ? parameters : Object.entries(parameters);
|
|
1584
|
-
}
|
|
1616
|
+
ACCEPT_PATCH: "accept-patch",
|
|
1585
1617
|
/**
|
|
1586
|
-
*
|
|
1587
|
-
* Called by the built-in method {@link Object.prototype.toString}.
|
|
1618
|
+
* What partial content range types this server supports via byte serving
|
|
1588
1619
|
*
|
|
1589
|
-
* @
|
|
1590
|
-
*
|
|
1620
|
+
* @example
|
|
1621
|
+
* accept-ranges: bytes
|
|
1622
|
+
* Permanent
|
|
1591
1623
|
*/
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
var httpTokenCodePoints = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;
|
|
1602
|
-
var httpQuotedTokenCodePoints = /^[\t\u0020-\u007E\u0080-\u00FF]*$/u;
|
|
1603
|
-
var removeLeadingAndTrailingHTTPWhitespace = (string) => string.replace(leadingWhitespace, "").replace(trailingWhitespace, "");
|
|
1604
|
-
var removeTrailingHTTPWhitespace = (string) => string.replace(trailingWhitespace, "");
|
|
1605
|
-
var isHTTPWhitespaceChar = (char) => whitespaceCharacters.includes(char);
|
|
1606
|
-
var solelyContainsHTTPTokenCodePoints = (string) => httpTokenCodePoints.test(string);
|
|
1607
|
-
var solelyContainsHTTPQuotedStringTokenCodePoints = (string) => httpQuotedTokenCodePoints.test(string);
|
|
1608
|
-
var asciiLowercase = (string) => {
|
|
1609
|
-
let result = "";
|
|
1610
|
-
for (const [char, charCode = char.charCodeAt(0)] of string) {
|
|
1611
|
-
result += charCode >= 65 && charCode <= 90 ? String.fromCharCode(charCode + 32) : char;
|
|
1612
|
-
}
|
|
1613
|
-
return result;
|
|
1614
|
-
};
|
|
1615
|
-
var collectAnHTTPQuotedString = (input, position) => {
|
|
1616
|
-
let value = "";
|
|
1617
|
-
for (let length = input.length, char; ++position < length; ) {
|
|
1618
|
-
char = input[position];
|
|
1619
|
-
if (char == "\\") {
|
|
1620
|
-
value += ++position < length ? input[position] : char;
|
|
1621
|
-
} else if (char == '"') {
|
|
1622
|
-
break;
|
|
1623
|
-
} else {
|
|
1624
|
-
value += char;
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
return [value, position];
|
|
1628
|
-
};
|
|
1629
|
-
|
|
1630
|
-
// node_modules/@d1g1tal/media-type/src/media-type-parameters.js
|
|
1631
|
-
var MediaTypeParameters = class {
|
|
1632
|
-
/** @type {Map<string, string>} */
|
|
1633
|
-
#map;
|
|
1624
|
+
ACCEPT_RANGES: "accept-ranges",
|
|
1625
|
+
/**
|
|
1626
|
+
* The age the object has been in a proxy cache in seconds
|
|
1627
|
+
*
|
|
1628
|
+
* @example
|
|
1629
|
+
* age: 12
|
|
1630
|
+
* Permanent
|
|
1631
|
+
*/
|
|
1632
|
+
AGE: "age",
|
|
1634
1633
|
/**
|
|
1635
|
-
*
|
|
1634
|
+
* Valid actions for a specified resource. To be used for a 405 Method not allowed
|
|
1636
1635
|
*
|
|
1637
|
-
* @
|
|
1636
|
+
* @example
|
|
1637
|
+
* allow: GET, HEAD
|
|
1638
|
+
* Permanent
|
|
1638
1639
|
*/
|
|
1639
|
-
|
|
1640
|
-
this.#map = new Map(entries);
|
|
1641
|
-
}
|
|
1640
|
+
ALLOW: "allow",
|
|
1642
1641
|
/**
|
|
1643
|
-
*
|
|
1642
|
+
* Tells all caching mechanisms from server to client whether they may cache this object. It is measured in seconds
|
|
1644
1643
|
*
|
|
1645
|
-
* @
|
|
1644
|
+
* @example
|
|
1645
|
+
* cache-control: max-age=3600
|
|
1646
|
+
* Permanent
|
|
1646
1647
|
*/
|
|
1647
|
-
|
|
1648
|
-
return this.#map.size;
|
|
1649
|
-
}
|
|
1648
|
+
CACHE_CONTROL: "cache-control",
|
|
1650
1649
|
/**
|
|
1651
|
-
*
|
|
1650
|
+
* Control options for the current connection and list of hop-by-hop response fields
|
|
1652
1651
|
*
|
|
1653
|
-
* @
|
|
1654
|
-
*
|
|
1652
|
+
* @example
|
|
1653
|
+
* connection: close
|
|
1654
|
+
* Permanent
|
|
1655
1655
|
*/
|
|
1656
|
-
|
|
1657
|
-
return this.#map.get(asciiLowercase(String(name)));
|
|
1658
|
-
}
|
|
1656
|
+
CONNECTION: "connection",
|
|
1659
1657
|
/**
|
|
1660
|
-
*
|
|
1658
|
+
* An opportunity to raise a "File Download" dialogue box for a known MIME type with binary format or suggest a filename for dynamic content. Quotes are necessary with special characters.
|
|
1661
1659
|
*
|
|
1662
|
-
* @
|
|
1663
|
-
*
|
|
1660
|
+
* @example
|
|
1661
|
+
* content-disposition: attachment, filename="fname.ext"
|
|
1662
|
+
* Permanent
|
|
1664
1663
|
*/
|
|
1665
|
-
|
|
1666
|
-
return this.#map.has(asciiLowercase(String(name)));
|
|
1667
|
-
}
|
|
1664
|
+
CONTENT_DISPOSITION: "content-disposition",
|
|
1668
1665
|
/**
|
|
1669
|
-
*
|
|
1670
|
-
* If an parameter with the same name already exists, the parameter will be updated.
|
|
1666
|
+
* The type of encoding used on the data. See HTTP compression.
|
|
1671
1667
|
*
|
|
1672
|
-
* @
|
|
1673
|
-
*
|
|
1674
|
-
*
|
|
1668
|
+
* @example
|
|
1669
|
+
* content-encoding: gzip
|
|
1670
|
+
* Permanent
|
|
1675
1671
|
*/
|
|
1676
|
-
|
|
1677
|
-
name = asciiLowercase(String(name));
|
|
1678
|
-
value = String(value);
|
|
1679
|
-
if (!solelyContainsHTTPTokenCodePoints(name)) {
|
|
1680
|
-
throw new Error(`Invalid media type parameter name "${name}": only HTTP token code points are valid.`);
|
|
1681
|
-
}
|
|
1682
|
-
if (!solelyContainsHTTPQuotedStringTokenCodePoints(value)) {
|
|
1683
|
-
throw new Error(`Invalid media type parameter value "${value}": only HTTP quoted-string token code points are valid.`);
|
|
1684
|
-
}
|
|
1685
|
-
this.#map.set(name, value);
|
|
1686
|
-
return this;
|
|
1687
|
-
}
|
|
1672
|
+
CONTENT_ENCODING: "content-encoding",
|
|
1688
1673
|
/**
|
|
1689
|
-
*
|
|
1674
|
+
* The natural language or languages of the intended audience for the enclosed content
|
|
1675
|
+
*
|
|
1676
|
+
* @example
|
|
1677
|
+
* content-language: da
|
|
1678
|
+
* Permanent
|
|
1690
1679
|
*/
|
|
1691
|
-
|
|
1692
|
-
this.#map.clear();
|
|
1693
|
-
}
|
|
1680
|
+
CONTENT_LANGUAGE: "content-language",
|
|
1694
1681
|
/**
|
|
1695
|
-
*
|
|
1682
|
+
* The length of the response body in octets (8-bit bytes)
|
|
1696
1683
|
*
|
|
1697
|
-
* @
|
|
1698
|
-
*
|
|
1684
|
+
* @example
|
|
1685
|
+
* content-length: 348
|
|
1686
|
+
* Permanent
|
|
1699
1687
|
*/
|
|
1700
|
-
|
|
1701
|
-
name = asciiLowercase(String(name));
|
|
1702
|
-
return this.#map.delete(name);
|
|
1703
|
-
}
|
|
1688
|
+
CONTENT_LENGTH: "content-length",
|
|
1704
1689
|
/**
|
|
1705
|
-
*
|
|
1690
|
+
* An alternate location for the returned data
|
|
1706
1691
|
*
|
|
1707
|
-
* @
|
|
1708
|
-
*
|
|
1692
|
+
* @example
|
|
1693
|
+
* content-location: /index.htm
|
|
1694
|
+
* Permanent
|
|
1709
1695
|
*/
|
|
1710
|
-
|
|
1711
|
-
this.#map.forEach(callback, thisArg);
|
|
1712
|
-
}
|
|
1696
|
+
CONTENT_LOCATION: "content-location",
|
|
1713
1697
|
/**
|
|
1714
|
-
*
|
|
1698
|
+
* Where in a full body message this partial message belongs
|
|
1715
1699
|
*
|
|
1716
|
-
* @
|
|
1700
|
+
* @example
|
|
1701
|
+
* content-range: bytes 21010-47021/47022
|
|
1702
|
+
* Permanent
|
|
1717
1703
|
*/
|
|
1718
|
-
|
|
1719
|
-
return this.#map.keys();
|
|
1720
|
-
}
|
|
1704
|
+
CONTENT_RANGE: "content-range",
|
|
1721
1705
|
/**
|
|
1722
|
-
*
|
|
1706
|
+
* The MIME type of this content
|
|
1723
1707
|
*
|
|
1724
|
-
* @
|
|
1708
|
+
* @example
|
|
1709
|
+
* content-type: text/html, charset=utf-8
|
|
1710
|
+
* Permanent
|
|
1725
1711
|
*/
|
|
1726
|
-
|
|
1727
|
-
return this.#map.values();
|
|
1728
|
-
}
|
|
1712
|
+
CONTENT_TYPE: "content-type",
|
|
1729
1713
|
/**
|
|
1730
|
-
*
|
|
1714
|
+
* The date and time that the message was sent (in "HTTP-date" format as defined by RFC 7231)
|
|
1731
1715
|
*
|
|
1732
|
-
* @
|
|
1716
|
+
* @example
|
|
1717
|
+
* date: Tue, 15 Nov 1994 08:12:31 GMT
|
|
1718
|
+
* Permanent
|
|
1733
1719
|
*/
|
|
1734
|
-
|
|
1735
|
-
return this.#map.entries();
|
|
1736
|
-
}
|
|
1720
|
+
DATE: "date",
|
|
1737
1721
|
/**
|
|
1738
|
-
*
|
|
1722
|
+
* An identifier for a specific version of a resource, often a message digest
|
|
1739
1723
|
*
|
|
1740
|
-
* @
|
|
1724
|
+
* @example
|
|
1725
|
+
* etag: "737060cd8c284d8af7ad3082f209582d"
|
|
1726
|
+
* Permanent
|
|
1741
1727
|
*/
|
|
1742
|
-
|
|
1743
|
-
return this.#map[Symbol.iterator]();
|
|
1744
|
-
}
|
|
1728
|
+
ETAG: "etag",
|
|
1745
1729
|
/**
|
|
1746
|
-
*
|
|
1747
|
-
* This method is called by the `String()` function.
|
|
1730
|
+
* Gives the date/time after which the response is considered stale (in "HTTP-date" format as defined by RFC 7231)
|
|
1748
1731
|
*
|
|
1749
1732
|
* @example
|
|
1750
|
-
*
|
|
1751
|
-
*
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
* `${parameters}`; // 'charset=utf-8'
|
|
1755
|
-
* parameters[Symbol.toStringTag]; // 'MediaTypeParameters'
|
|
1756
|
-
* parameters[Symbol.toStringTag](); // 'MediaTypeParameters'
|
|
1757
|
-
* Object.prototype.toString.call(parameters); // '[object MediaTypeParameters]'
|
|
1758
|
-
* parameters + ''; // 'charset=utf-8'
|
|
1759
|
-
* @returns {string} The string representation of the media type parameters.
|
|
1760
|
-
*/
|
|
1761
|
-
[Symbol.toStringTag]() {
|
|
1762
|
-
return "MediaTypeParameters";
|
|
1763
|
-
}
|
|
1764
|
-
};
|
|
1765
|
-
|
|
1766
|
-
// node_modules/@d1g1tal/media-type/src/parser.js
|
|
1767
|
-
var parse = (input) => {
|
|
1768
|
-
input = removeLeadingAndTrailingHTTPWhitespace(input);
|
|
1769
|
-
let position = 0;
|
|
1770
|
-
let type = "";
|
|
1771
|
-
while (position < input.length && input[position] != "/") {
|
|
1772
|
-
type += input[position];
|
|
1773
|
-
++position;
|
|
1774
|
-
}
|
|
1775
|
-
if (type.length === 0 || !solelyContainsHTTPTokenCodePoints(type)) {
|
|
1776
|
-
return null;
|
|
1777
|
-
}
|
|
1778
|
-
if (position >= input.length) {
|
|
1779
|
-
return null;
|
|
1780
|
-
}
|
|
1781
|
-
++position;
|
|
1782
|
-
let subtype = "";
|
|
1783
|
-
while (position < input.length && input[position] != ";") {
|
|
1784
|
-
subtype += input[position];
|
|
1785
|
-
++position;
|
|
1786
|
-
}
|
|
1787
|
-
subtype = removeTrailingHTTPWhitespace(subtype);
|
|
1788
|
-
if (subtype.length === 0 || !solelyContainsHTTPTokenCodePoints(subtype)) {
|
|
1789
|
-
return null;
|
|
1790
|
-
}
|
|
1791
|
-
const mediaType = {
|
|
1792
|
-
type: asciiLowercase(type),
|
|
1793
|
-
subtype: asciiLowercase(subtype),
|
|
1794
|
-
parameters: /* @__PURE__ */ new Map()
|
|
1795
|
-
};
|
|
1796
|
-
while (position < input.length) {
|
|
1797
|
-
++position;
|
|
1798
|
-
while (isHTTPWhitespaceChar(input[position])) {
|
|
1799
|
-
++position;
|
|
1800
|
-
}
|
|
1801
|
-
let parameterName = "";
|
|
1802
|
-
while (position < input.length && input[position] != ";" && input[position] != "=") {
|
|
1803
|
-
parameterName += input[position];
|
|
1804
|
-
++position;
|
|
1805
|
-
}
|
|
1806
|
-
parameterName = asciiLowercase(parameterName);
|
|
1807
|
-
if (position < input.length) {
|
|
1808
|
-
if (input[position] == ";") {
|
|
1809
|
-
continue;
|
|
1810
|
-
}
|
|
1811
|
-
++position;
|
|
1812
|
-
}
|
|
1813
|
-
let parameterValue = null;
|
|
1814
|
-
if (input[position] == '"') {
|
|
1815
|
-
[parameterValue, position] = collectAnHTTPQuotedString(input, position);
|
|
1816
|
-
while (position < input.length && input[position] != ";") {
|
|
1817
|
-
++position;
|
|
1818
|
-
}
|
|
1819
|
-
} else {
|
|
1820
|
-
parameterValue = "";
|
|
1821
|
-
while (position < input.length && input[position] != ";") {
|
|
1822
|
-
parameterValue += input[position];
|
|
1823
|
-
++position;
|
|
1824
|
-
}
|
|
1825
|
-
parameterValue = removeTrailingHTTPWhitespace(parameterValue);
|
|
1826
|
-
if (parameterValue === "") {
|
|
1827
|
-
continue;
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
if (parameterName.length > 0 && solelyContainsHTTPTokenCodePoints(parameterName) && solelyContainsHTTPQuotedStringTokenCodePoints(parameterValue) && !mediaType.parameters.has(parameterName)) {
|
|
1831
|
-
mediaType.parameters.set(parameterName, parameterValue);
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
return mediaType;
|
|
1835
|
-
};
|
|
1836
|
-
var parser_default = parse;
|
|
1837
|
-
|
|
1838
|
-
// node_modules/@d1g1tal/media-type/src/serializer.js
|
|
1839
|
-
var serialize = (mediaType) => {
|
|
1840
|
-
let serialization = `${mediaType.type}/${mediaType.subtype}`;
|
|
1841
|
-
if (mediaType.parameters.size === 0) {
|
|
1842
|
-
return serialization;
|
|
1843
|
-
}
|
|
1844
|
-
for (let [name, value] of mediaType.parameters) {
|
|
1845
|
-
serialization += `;${name}=`;
|
|
1846
|
-
if (!solelyContainsHTTPTokenCodePoints(value) || value.length === 0) {
|
|
1847
|
-
value = `"${value.replace(/(["\\])/ug, "\\$1")}"`;
|
|
1848
|
-
}
|
|
1849
|
-
serialization += value;
|
|
1850
|
-
}
|
|
1851
|
-
return serialization;
|
|
1852
|
-
};
|
|
1853
|
-
var serializer_default = serialize;
|
|
1854
|
-
|
|
1855
|
-
// node_modules/@d1g1tal/media-type/src/media-type.js
|
|
1856
|
-
var MediaType = class _MediaType {
|
|
1857
|
-
/** @type {string} */
|
|
1858
|
-
#type;
|
|
1859
|
-
/** @type {string} */
|
|
1860
|
-
#subtype;
|
|
1861
|
-
/** @type {MediaTypeParameters} */
|
|
1862
|
-
#parameters;
|
|
1733
|
+
* expires: Thu, 01 Dec 1994 16:00:00 GMT
|
|
1734
|
+
* Permanent
|
|
1735
|
+
*/
|
|
1736
|
+
EXPIRES: "expires",
|
|
1863
1737
|
/**
|
|
1864
|
-
*
|
|
1738
|
+
* The last modified date for the requested object (in "HTTP-date" format as defined by RFC 7231)
|
|
1865
1739
|
*
|
|
1866
|
-
* @
|
|
1867
|
-
*
|
|
1740
|
+
* @example
|
|
1741
|
+
* last-modified: Tue, 15 Nov 1994 12:45:26 GMT
|
|
1742
|
+
* Permanent
|
|
1868
1743
|
*/
|
|
1869
|
-
|
|
1870
|
-
const { type, subtype, parameters: parsedParameters } = parser_default(mediaType);
|
|
1871
|
-
this.#type = type;
|
|
1872
|
-
this.#subtype = subtype;
|
|
1873
|
-
this.#parameters = new MediaTypeParameters([...parsedParameters, ...Object.entries(parameters).map(([name, value]) => [asciiLowercase(name), asciiLowercase(value)])]);
|
|
1874
|
-
}
|
|
1744
|
+
LAST_MODIFIED: "last-modified",
|
|
1875
1745
|
/**
|
|
1876
|
-
*
|
|
1746
|
+
* Used to express a typed relationship with another resource, where the relation type is defined by RFC 5988
|
|
1877
1747
|
*
|
|
1878
|
-
* @
|
|
1879
|
-
*
|
|
1748
|
+
* @example
|
|
1749
|
+
* link: </feed>, rel="alternate"
|
|
1750
|
+
* Permanent
|
|
1880
1751
|
*/
|
|
1881
|
-
|
|
1882
|
-
try {
|
|
1883
|
-
return new _MediaType(string);
|
|
1884
|
-
} catch (e) {
|
|
1885
|
-
throw new Error(`Could not parse media type string '${string}'`);
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1752
|
+
LINK: "link",
|
|
1888
1753
|
/**
|
|
1889
|
-
*
|
|
1754
|
+
* Used in redirection, or when a new resource has been created.
|
|
1890
1755
|
*
|
|
1891
|
-
* @
|
|
1756
|
+
* @example
|
|
1757
|
+
* location: http://www.w3.org/pub/WWW/People.html
|
|
1758
|
+
* Permanent
|
|
1892
1759
|
*/
|
|
1893
|
-
|
|
1894
|
-
return `${this.#type}/${this.#subtype}`;
|
|
1895
|
-
}
|
|
1760
|
+
LOCATION: "location",
|
|
1896
1761
|
/**
|
|
1897
|
-
*
|
|
1762
|
+
* This field is supposed to set P3P policy, in the form of P3P:CP="your_compact_policy". However, P3P did not take off, most browsers have never fully
|
|
1763
|
+
* implemented it, a lot of websites set this field with fake policy text, that was enough to fool browsers the existence of P3P policy and grant permissions for third party cookies.
|
|
1898
1764
|
*
|
|
1899
|
-
* @
|
|
1765
|
+
* @example
|
|
1766
|
+
* p3p: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
|
|
1767
|
+
* Permanent
|
|
1900
1768
|
*/
|
|
1901
|
-
|
|
1902
|
-
return this.#type;
|
|
1903
|
-
}
|
|
1769
|
+
P3P: "p3p",
|
|
1904
1770
|
/**
|
|
1905
|
-
*
|
|
1771
|
+
* Implementation-specific fields that may have various effects anywhere along the request-response chain.
|
|
1772
|
+
*
|
|
1773
|
+
* @example
|
|
1774
|
+
* pragma: no-cache
|
|
1775
|
+
* Permanent
|
|
1906
1776
|
*/
|
|
1907
|
-
|
|
1908
|
-
value = asciiLowercase(String(value));
|
|
1909
|
-
if (value.length === 0) {
|
|
1910
|
-
throw new Error("Invalid type: must be a non-empty string");
|
|
1911
|
-
}
|
|
1912
|
-
if (!solelyContainsHTTPTokenCodePoints(value)) {
|
|
1913
|
-
throw new Error(`Invalid type ${value}: must contain only HTTP token code points`);
|
|
1914
|
-
}
|
|
1915
|
-
this.#type = value;
|
|
1916
|
-
}
|
|
1777
|
+
PRAGMA: "pragma",
|
|
1917
1778
|
/**
|
|
1918
|
-
*
|
|
1779
|
+
* Request authentication to access the proxy.
|
|
1919
1780
|
*
|
|
1920
|
-
* @
|
|
1781
|
+
* @example
|
|
1782
|
+
* proxy-authenticate: Basic
|
|
1783
|
+
* Permanent
|
|
1921
1784
|
*/
|
|
1922
|
-
|
|
1923
|
-
return this.#subtype;
|
|
1924
|
-
}
|
|
1785
|
+
PROXY_AUTHENTICATION: "proxy-authenticate",
|
|
1925
1786
|
/**
|
|
1926
|
-
*
|
|
1787
|
+
* HTTP Public Key Pinning, announces hash of website's authentic TLS certificate
|
|
1788
|
+
*
|
|
1789
|
+
* @example
|
|
1790
|
+
* public-key-pins: max-age=2592000, pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=",
|
|
1791
|
+
* Permanent
|
|
1927
1792
|
*/
|
|
1928
|
-
|
|
1929
|
-
value = asciiLowercase(String(value));
|
|
1930
|
-
if (value.length === 0) {
|
|
1931
|
-
throw new Error("Invalid subtype: must be a non-empty string");
|
|
1932
|
-
}
|
|
1933
|
-
if (!solelyContainsHTTPTokenCodePoints(value)) {
|
|
1934
|
-
throw new Error(`Invalid subtype ${value}: must contain only HTTP token code points`);
|
|
1935
|
-
}
|
|
1936
|
-
this.#subtype = value;
|
|
1937
|
-
}
|
|
1793
|
+
PUBLIC_KEY_PINS: "public-key-pins",
|
|
1938
1794
|
/**
|
|
1939
|
-
*
|
|
1795
|
+
* If an entity is temporarily unavailable, this instructs the client to try again later. Value could be a specified period of time (in seconds) or a HTTP-date.
|
|
1940
1796
|
*
|
|
1941
|
-
* @
|
|
1797
|
+
* @example
|
|
1798
|
+
* retry-after: 120
|
|
1799
|
+
* retry-after: Fri, 07 Nov 2014 23:59:59 GMT
|
|
1800
|
+
* Permanent
|
|
1942
1801
|
*/
|
|
1943
|
-
|
|
1944
|
-
return this.#parameters;
|
|
1945
|
-
}
|
|
1802
|
+
RETRY_AFTER: "retry-after",
|
|
1946
1803
|
/**
|
|
1947
|
-
*
|
|
1804
|
+
* A name for the server
|
|
1948
1805
|
*
|
|
1949
|
-
* @
|
|
1806
|
+
* @example
|
|
1807
|
+
* server: Apache/2.4.1 (Unix)
|
|
1808
|
+
* Permanent
|
|
1950
1809
|
*/
|
|
1951
|
-
|
|
1952
|
-
return serializer_default(this);
|
|
1953
|
-
}
|
|
1810
|
+
SERVER: "server",
|
|
1954
1811
|
/**
|
|
1955
|
-
*
|
|
1812
|
+
* An HTTP cookie
|
|
1956
1813
|
*
|
|
1957
|
-
* @
|
|
1958
|
-
*
|
|
1959
|
-
*
|
|
1814
|
+
* @example
|
|
1815
|
+
* set-cookie: UserID=JohnDoe, Max-Age=3600, Version=1
|
|
1816
|
+
* Permanent
|
|
1960
1817
|
*/
|
|
1961
|
-
|
|
1962
|
-
switch (this.#type) {
|
|
1963
|
-
case "text": {
|
|
1964
|
-
switch (this.#subtype) {
|
|
1965
|
-
case "ecmascript":
|
|
1966
|
-
case "javascript":
|
|
1967
|
-
case "javascript1.0":
|
|
1968
|
-
case "javascript1.1":
|
|
1969
|
-
case "javascript1.2":
|
|
1970
|
-
case "javascript1.3":
|
|
1971
|
-
case "javascript1.4":
|
|
1972
|
-
case "javascript1.5":
|
|
1973
|
-
case "jscript":
|
|
1974
|
-
case "livescript":
|
|
1975
|
-
case "x-ecmascript":
|
|
1976
|
-
case "x-javascript":
|
|
1977
|
-
return !prohibitParameters || this.#parameters.size === 0;
|
|
1978
|
-
default:
|
|
1979
|
-
return false;
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
case "application": {
|
|
1983
|
-
switch (this.#subtype) {
|
|
1984
|
-
case "ecmascript":
|
|
1985
|
-
case "javascript":
|
|
1986
|
-
case "x-ecmascript":
|
|
1987
|
-
case "x-javascript":
|
|
1988
|
-
return !prohibitParameters || this.#parameters.size === 0;
|
|
1989
|
-
default:
|
|
1990
|
-
return false;
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
default:
|
|
1994
|
-
return false;
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1818
|
+
SET_COOKIE: "set-cookie",
|
|
1997
1819
|
/**
|
|
1998
|
-
*
|
|
1820
|
+
* CGI header field specifying the status of the HTTP response. Normal HTTP responses use a separate "Status-Line" instead, defined by RFC 7230.
|
|
1999
1821
|
*
|
|
2000
|
-
* @
|
|
1822
|
+
* @example
|
|
1823
|
+
* status: 200 OK
|
|
2001
1824
|
*/
|
|
2002
|
-
|
|
2003
|
-
return this.#subtype === "xml" && (this.#type === "text" || this.#type === "application") || this.#subtype.endsWith("+xml");
|
|
2004
|
-
}
|
|
1825
|
+
STATUS: "status",
|
|
2005
1826
|
/**
|
|
2006
|
-
*
|
|
1827
|
+
* A HSTS Policy informing the HTTP client how long to cache the HTTPS only policy and whether this applies to subdomains.
|
|
2007
1828
|
*
|
|
2008
|
-
* @
|
|
1829
|
+
* @example
|
|
1830
|
+
* strict-transport-security: max-age=16070400, includeSubDomains
|
|
1831
|
+
* Permanent
|
|
1832
|
+
*/
|
|
1833
|
+
STRICT_TRANSPORT_SECURITY: "strict-transport-security",
|
|
1834
|
+
/**
|
|
1835
|
+
* The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding.
|
|
1836
|
+
*
|
|
1837
|
+
* @example
|
|
1838
|
+
* trailer: Max-Forwards
|
|
1839
|
+
* Permanent
|
|
1840
|
+
*/
|
|
1841
|
+
TRAILER: "trailer",
|
|
1842
|
+
/**
|
|
1843
|
+
* The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.
|
|
1844
|
+
*
|
|
1845
|
+
* @example
|
|
1846
|
+
* transfer-encoding: chunked
|
|
1847
|
+
* Permanent
|
|
1848
|
+
*/
|
|
1849
|
+
TRANSFER_ENCODING: "transfer-encoding",
|
|
1850
|
+
/**
|
|
1851
|
+
* Ask the client to upgrade to another protocol.
|
|
1852
|
+
*
|
|
1853
|
+
* @example
|
|
1854
|
+
* upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11
|
|
1855
|
+
* Permanent
|
|
1856
|
+
*/
|
|
1857
|
+
UPGRADE: "upgrade",
|
|
1858
|
+
/**
|
|
1859
|
+
* Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server.
|
|
1860
|
+
*
|
|
1861
|
+
* @example
|
|
1862
|
+
* vary: *
|
|
1863
|
+
* Permanent
|
|
1864
|
+
*/
|
|
1865
|
+
VARY: "vary",
|
|
1866
|
+
/**
|
|
1867
|
+
* Informs the client of proxies through which the response was sent.
|
|
1868
|
+
*
|
|
1869
|
+
* @example
|
|
1870
|
+
* via: 1.0 fred, 1.1 example.com (Apache/1.1)
|
|
1871
|
+
* Permanent
|
|
1872
|
+
*/
|
|
1873
|
+
VIA: "via",
|
|
1874
|
+
/**
|
|
1875
|
+
* A general warning about possible problems with the entity body.
|
|
1876
|
+
*
|
|
1877
|
+
* @example
|
|
1878
|
+
* warning: 199 Miscellaneous warning
|
|
1879
|
+
* Permanent
|
|
1880
|
+
*/
|
|
1881
|
+
WARNING: "warning",
|
|
1882
|
+
/**
|
|
1883
|
+
* Indicates the authentication scheme that should be used to access the requested entity.
|
|
1884
|
+
*
|
|
1885
|
+
* @example
|
|
1886
|
+
* www-authenticate: Basic
|
|
1887
|
+
* Permanent
|
|
1888
|
+
*/
|
|
1889
|
+
WWW_AUTHENTICATE: "www-authenticate",
|
|
1890
|
+
/**
|
|
1891
|
+
* Cross-site scripting (XSS) filter
|
|
1892
|
+
*
|
|
1893
|
+
* @example
|
|
1894
|
+
* x-xss-protection: 1, mode=block
|
|
1895
|
+
*/
|
|
1896
|
+
X_XSS_PROTECTION: "x-xss-protection",
|
|
1897
|
+
/**
|
|
1898
|
+
* The HTTP Content-Security-Policy response header allows web site administrators to control resources the user agent is allowed
|
|
1899
|
+
* to load for a given page. With a few exceptions, policies mostly involve specifying server origins and script endpoints.
|
|
1900
|
+
* This helps guard against cross-site scripting attacks (Cross-site_scripting).
|
|
1901
|
+
*
|
|
1902
|
+
* @example
|
|
1903
|
+
* content-security-policy: default-src
|
|
1904
|
+
*/
|
|
1905
|
+
CONTENT_SECURITY_POLICY: "content-security-policy",
|
|
1906
|
+
/**
|
|
1907
|
+
* The only defined value, "nosniff", prevents Internet Explorer from MIME-sniffing a response away from the declared content-type. This also applies to Google Chrome, when downloading extensions.
|
|
1908
|
+
*
|
|
1909
|
+
* @example
|
|
1910
|
+
* x-content-type-options: nosniff
|
|
2009
1911
|
*/
|
|
2010
|
-
|
|
2011
|
-
return this.#subtype === "html" && this.#type === "text";
|
|
2012
|
-
}
|
|
1912
|
+
X_CONTENT_TYPE_OPTIONS: "x-content-type-options",
|
|
2013
1913
|
/**
|
|
2014
|
-
*
|
|
1914
|
+
* specifies the technology (e.g. ASP.NET, PHP, JBoss) supporting the web application (version details are often in X-Runtime, X-Version, or X-AspNet-Version)
|
|
2015
1915
|
*
|
|
2016
|
-
* @
|
|
1916
|
+
* @example
|
|
1917
|
+
* x-powered-by: PHP/5.4.0
|
|
2017
1918
|
*/
|
|
2018
|
-
|
|
2019
|
-
return "MediaType";
|
|
2020
|
-
}
|
|
1919
|
+
X_POWERED_BY: "x-powered-by"
|
|
2021
1920
|
};
|
|
1921
|
+
var http_response_headers_default = HttpResponseHeader;
|
|
2022
1922
|
|
|
2023
|
-
// src/
|
|
2024
|
-
var
|
|
2025
|
-
var endsWithSlashRegEx = /\/$/;
|
|
2026
|
-
var mediaTypes = /* @__PURE__ */ new Map([
|
|
2027
|
-
[http_media_type_default.PNG, new MediaType(http_media_type_default.PNG)],
|
|
2028
|
-
[http_media_type_default.TEXT, new MediaType(http_media_type_default.TEXT, { defaultCharset })],
|
|
2029
|
-
[http_media_type_default.JSON, new MediaType(http_media_type_default.JSON, { defaultCharset })],
|
|
2030
|
-
[http_media_type_default.HTML, new MediaType(http_media_type_default.HTML, { defaultCharset })],
|
|
2031
|
-
[http_media_type_default.JAVA_SCRIPT, new MediaType(http_media_type_default.JAVA_SCRIPT, { defaultCharset })],
|
|
2032
|
-
[http_media_type_default.CSS, new MediaType(http_media_type_default.CSS, { defaultCharset })],
|
|
2033
|
-
[http_media_type_default.XML, new MediaType(http_media_type_default.XML, { defaultCharset })],
|
|
2034
|
-
[http_media_type_default.BIN, new MediaType(http_media_type_default.BIN)]
|
|
2035
|
-
]);
|
|
2036
|
-
var RequestEvents = Object.freeze({
|
|
2037
|
-
CONFIGURED: "configured",
|
|
2038
|
-
SUCCESS: "success",
|
|
2039
|
-
ERROR: "error",
|
|
2040
|
-
ABORTED: "aborted",
|
|
2041
|
-
TIMEOUT: "timeout",
|
|
2042
|
-
COMPLETE: "complete",
|
|
2043
|
-
ALL_COMPLETE: "all-complete"
|
|
2044
|
-
});
|
|
2045
|
-
var SignalEvents = Object.freeze({
|
|
2046
|
-
ABORT: "abort",
|
|
2047
|
-
TIMEOUT: "timeout"
|
|
2048
|
-
});
|
|
2049
|
-
var _abortEvent = new CustomEvent(SignalEvents.ABORT, { detail: { cause: new DOMException("The request was aborted", "AbortError") } });
|
|
2050
|
-
var requestBodyMethods = [http_request_methods_default.POST, http_request_methods_default.PUT, http_request_methods_default.PATCH];
|
|
2051
|
-
|
|
2052
|
-
// src/abort-signal.js
|
|
2053
|
-
var NativeAbortSignal = globalThis.AbortSignal;
|
|
2054
|
-
var AbortSignal = class _AbortSignal extends EventTarget {
|
|
2055
|
-
/** @type {AbortController} */
|
|
2056
|
-
#abortController;
|
|
2057
|
-
/** @type {number} */
|
|
2058
|
-
#timeoutId;
|
|
1923
|
+
// src/parameter-map.js
|
|
1924
|
+
var ParameterMap = class _ParameterMap extends Map {
|
|
2059
1925
|
/**
|
|
2060
|
-
* @param {
|
|
1926
|
+
* @param {Iterable<[string, *]>|Object} parameters The initial parameters to set.
|
|
1927
|
+
* @returns {ParameterMap<string, *>} The ParameterMap with the updated key and value.
|
|
2061
1928
|
*/
|
|
2062
|
-
constructor(
|
|
1929
|
+
constructor(parameters = {}) {
|
|
2063
1930
|
super();
|
|
2064
|
-
|
|
2065
|
-
|
|
1931
|
+
for (const [key, value] of _ParameterMap.#entries(parameters)) {
|
|
1932
|
+
this.append(key, value);
|
|
1933
|
+
}
|
|
2066
1934
|
}
|
|
2067
1935
|
/**
|
|
2068
|
-
*
|
|
1936
|
+
* Adds a new element with a specified key and value to the ParameterMap.
|
|
1937
|
+
* If an element with the same key already exists, the value will be replaced in the underlying {@link Set}.
|
|
2069
1938
|
*
|
|
2070
|
-
* @
|
|
2071
|
-
* @
|
|
1939
|
+
* @override
|
|
1940
|
+
* @param {string} key The key to set.
|
|
1941
|
+
* @param {*} value The value to add to the ParameterMap
|
|
1942
|
+
* @returns {ParameterMap<string, *>} The ParameterMap with the updated key and value.
|
|
2072
1943
|
*/
|
|
2073
|
-
|
|
2074
|
-
|
|
1944
|
+
set(key, value) {
|
|
1945
|
+
const array = super.get(key);
|
|
1946
|
+
if (array?.length > 0) {
|
|
1947
|
+
array.length = 0;
|
|
1948
|
+
array[0] = value;
|
|
1949
|
+
} else {
|
|
1950
|
+
super.set(key, [value]);
|
|
1951
|
+
}
|
|
1952
|
+
return this;
|
|
2075
1953
|
}
|
|
2076
1954
|
/**
|
|
2077
|
-
*
|
|
1955
|
+
* Adds all key-value pairs from an iterable or object to the ParameterMap.
|
|
1956
|
+
* If a key already exists, the value will be replaced in the underlying {@link Array}.
|
|
2078
1957
|
*
|
|
2079
|
-
* @
|
|
2080
|
-
* @
|
|
2081
|
-
* @returns {AbortSignal} The abort signal
|
|
1958
|
+
* @param {Iterable<[string, *]>|Object} parameters The parameters to set.
|
|
1959
|
+
* @returns {ParameterMap<string, *>} The ParameterMap with the updated key and value.
|
|
2082
1960
|
*/
|
|
2083
|
-
|
|
2084
|
-
|
|
1961
|
+
setAll(parameters) {
|
|
1962
|
+
for (const [key, value] of _ParameterMap.#entries(parameters)) {
|
|
1963
|
+
this.set(key, value);
|
|
1964
|
+
}
|
|
1965
|
+
return this;
|
|
2085
1966
|
}
|
|
2086
1967
|
/**
|
|
2087
|
-
*
|
|
1968
|
+
* Returns the value associated to the key, or undefined if there is none.
|
|
1969
|
+
* If the key has multiple values, the first value will be returned.
|
|
1970
|
+
* If the key has no values, undefined will be returned.
|
|
2088
1971
|
*
|
|
2089
|
-
* @
|
|
1972
|
+
* @override
|
|
1973
|
+
* @param {string} key The key to get.
|
|
1974
|
+
* @returns {*} The value associated to the key, or undefined if there is none.
|
|
2090
1975
|
*/
|
|
2091
|
-
get
|
|
2092
|
-
return
|
|
1976
|
+
get(key) {
|
|
1977
|
+
return super.get(key)?.[0];
|
|
2093
1978
|
}
|
|
2094
1979
|
/**
|
|
2095
|
-
*
|
|
1980
|
+
* Returns an array of all values associated to the key, or undefined if there are none.
|
|
2096
1981
|
*
|
|
2097
|
-
* @
|
|
1982
|
+
* @param {string} key The key to get.
|
|
1983
|
+
* @returns {Array<*>} An array of all values associated to the key, or undefined if there are none.
|
|
2098
1984
|
*/
|
|
2099
|
-
|
|
2100
|
-
return
|
|
1985
|
+
getAll(key) {
|
|
1986
|
+
return super.get(key);
|
|
2101
1987
|
}
|
|
2102
1988
|
/**
|
|
2103
|
-
*
|
|
1989
|
+
* Appends a new value to an existing key inside a ParameterMap, or adds the new key if it does not exist.
|
|
2104
1990
|
*
|
|
2105
|
-
* @
|
|
1991
|
+
* @param {string} key The key to append.
|
|
1992
|
+
* @param {*} value The value to append.
|
|
1993
|
+
* @returns {ParameterMap<string, *>} The ParameterMap with the updated key and value to allow chaining.
|
|
2106
1994
|
*/
|
|
2107
|
-
|
|
2108
|
-
|
|
1995
|
+
append(key, value) {
|
|
1996
|
+
const array = super.get(key);
|
|
1997
|
+
if (array?.length > 0) {
|
|
1998
|
+
array.push(value);
|
|
1999
|
+
} else {
|
|
2000
|
+
super.set(key, [value]);
|
|
2001
|
+
}
|
|
2002
|
+
return this;
|
|
2109
2003
|
}
|
|
2110
2004
|
/**
|
|
2111
|
-
*
|
|
2112
|
-
*
|
|
2113
|
-
*
|
|
2005
|
+
* Appends all key-value pairs from an iterable or object to the ParameterMap.
|
|
2006
|
+
* If a key already exists, the value will be appended to the underlying {@link Array}.
|
|
2007
|
+
* If a key does not exist, the key and value will be added to the ParameterMap.
|
|
2114
2008
|
*
|
|
2115
|
-
* @param {
|
|
2116
|
-
* @returns {
|
|
2009
|
+
* @param {Iterable<[string, *]>|Object} parameters The parameters to append.
|
|
2010
|
+
* @returns {ParameterMap<string, *>} The ParameterMap with the updated key and value.
|
|
2117
2011
|
*/
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2012
|
+
appendAll(parameters) {
|
|
2013
|
+
for (const [key, value] of _ParameterMap.#entries(parameters)) {
|
|
2014
|
+
this.append(key, value);
|
|
2121
2015
|
}
|
|
2122
|
-
|
|
2123
|
-
return this.#abortController.signal;
|
|
2016
|
+
return this;
|
|
2124
2017
|
}
|
|
2125
2018
|
/**
|
|
2126
|
-
*
|
|
2127
|
-
* Note: This does not abort the signal, dispatch the timeout event, or reset the timeout.
|
|
2019
|
+
* Checks if a specific key has a specific value.
|
|
2128
2020
|
*
|
|
2129
|
-
* @
|
|
2021
|
+
* @param {*} value The value to check.
|
|
2022
|
+
* @returns {boolean} True if the key has the value, false otherwise.
|
|
2130
2023
|
*/
|
|
2131
|
-
|
|
2132
|
-
|
|
2024
|
+
hasValue(value) {
|
|
2025
|
+
for (const array of super.values()) {
|
|
2026
|
+
if (array.includes(value)) {
|
|
2027
|
+
return true;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
return false;
|
|
2133
2031
|
}
|
|
2134
2032
|
/**
|
|
2135
|
-
*
|
|
2033
|
+
* Removes a specific value from a specific key.
|
|
2136
2034
|
*
|
|
2137
|
-
* @
|
|
2138
|
-
* @
|
|
2139
|
-
* @param {EventListener} listener The listener to add
|
|
2140
|
-
* @returns {void}
|
|
2035
|
+
* @param {*} value The value to remove.
|
|
2036
|
+
* @returns {boolean} True if the value was removed, false otherwise.
|
|
2141
2037
|
*/
|
|
2142
|
-
|
|
2143
|
-
this
|
|
2038
|
+
deleteValue(value) {
|
|
2039
|
+
for (const array of this.values()) {
|
|
2040
|
+
if (array.includes(value)) {
|
|
2041
|
+
return array.splice(array.indexOf(value), 1).length > 0;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
return false;
|
|
2144
2045
|
}
|
|
2145
2046
|
/**
|
|
2146
|
-
*
|
|
2047
|
+
* Determines whether the ParameterMap contains anything.
|
|
2147
2048
|
*
|
|
2148
|
-
* @
|
|
2149
|
-
* @param {Event} event The event to dispatch
|
|
2150
|
-
* @returns {boolean} Whether the event was dispatched or not
|
|
2049
|
+
* @returns {boolean} True if the ParameterMap size is greater than 0, false otherwise.
|
|
2151
2050
|
*/
|
|
2152
|
-
|
|
2153
|
-
return this
|
|
2051
|
+
isEmpty() {
|
|
2052
|
+
return this.size === 0;
|
|
2154
2053
|
}
|
|
2155
2054
|
/**
|
|
2156
|
-
*
|
|
2055
|
+
* Returns an Object that can be serialized to JSON.
|
|
2056
|
+
* If a key has only one value, the value will be a single value.
|
|
2057
|
+
* If a key has multiple values, the value will be an array of values.
|
|
2058
|
+
* If a key has no values, the value will be undefined.
|
|
2157
2059
|
*
|
|
2158
2060
|
* @override
|
|
2159
|
-
* @
|
|
2160
|
-
* @
|
|
2161
|
-
* @returns {void}
|
|
2061
|
+
* @returns {Object} The Object to be serialized to JSON.
|
|
2062
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON_behavior}
|
|
2162
2063
|
*/
|
|
2163
|
-
|
|
2164
|
-
|
|
2064
|
+
toJSON() {
|
|
2065
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
2066
|
+
for (const [key, values] of super.entries()) {
|
|
2067
|
+
obj[key] = values.length === 1 ? values[0] : values;
|
|
2068
|
+
}
|
|
2069
|
+
return obj;
|
|
2165
2070
|
}
|
|
2166
2071
|
/**
|
|
2167
|
-
*
|
|
2072
|
+
* Returns an iterator that yields all key-value pairs in the map as arrays in their insertion order.
|
|
2168
2073
|
*
|
|
2169
|
-
* @
|
|
2170
|
-
* @
|
|
2074
|
+
* @override
|
|
2075
|
+
* @yields {[string, *]} An iterator for the key-value pairs in the map.
|
|
2171
2076
|
*/
|
|
2172
|
-
|
|
2173
|
-
|
|
2077
|
+
*entries() {
|
|
2078
|
+
for (const [key, array] of super.entries()) {
|
|
2079
|
+
for (const value of array) {
|
|
2080
|
+
yield [key, value];
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2174
2083
|
}
|
|
2175
2084
|
/**
|
|
2176
|
-
*
|
|
2085
|
+
* Returns an iterator that yields all key-value pairs in the map as arrays in their insertion order.
|
|
2177
2086
|
*
|
|
2178
|
-
* @
|
|
2179
|
-
* @
|
|
2180
|
-
* @param {boolean} [dispatchEvent = false] Whether to dispatch the event or not
|
|
2181
|
-
* @returns {void}
|
|
2182
|
-
* @fires SignalEvents.ABORT When the signal is aborted
|
|
2183
|
-
* @fires SignalEvents.TIMEOUT When the signal times out
|
|
2087
|
+
* @override
|
|
2088
|
+
* @yields {[string, *]} An iterator for the key-value pairs in the map.
|
|
2184
2089
|
*/
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
this.#abortController.abort(event.detail?.cause);
|
|
2188
|
-
if (dispatchEvent) {
|
|
2189
|
-
this.#abortController.signal.dispatchEvent(event);
|
|
2190
|
-
}
|
|
2090
|
+
*[Symbol.iterator]() {
|
|
2091
|
+
yield* this.entries();
|
|
2191
2092
|
}
|
|
2192
2093
|
/**
|
|
2193
|
-
*
|
|
2094
|
+
* Returns an iterable of key, value pairs for every entry in the parameters object.
|
|
2194
2095
|
*
|
|
2195
2096
|
* @private
|
|
2196
2097
|
* @static
|
|
2197
|
-
* @param {
|
|
2198
|
-
* @returns {
|
|
2098
|
+
* @param {Iterable<[string, *]>|Object} parameters The parameters to set.
|
|
2099
|
+
* @returns {Iterable<[string, *]>} An iterable of key, value pairs for every entry in the parameters object.
|
|
2100
|
+
*/
|
|
2101
|
+
static #entries(parameters) {
|
|
2102
|
+
return parameters[Symbol.iterator] ? parameters : Object.entries(parameters);
|
|
2103
|
+
}
|
|
2104
|
+
/**
|
|
2105
|
+
* A String value that is used in the creation of the default string description of an object.
|
|
2106
|
+
* Called by the built-in method {@link Object.prototype.toString}.
|
|
2107
|
+
*
|
|
2108
|
+
* @override
|
|
2109
|
+
* @returns {string} The default string description of this object.
|
|
2199
2110
|
*/
|
|
2200
|
-
|
|
2201
|
-
return
|
|
2111
|
+
get [Symbol.toStringTag]() {
|
|
2112
|
+
return "ParameterMap";
|
|
2202
2113
|
}
|
|
2203
2114
|
};
|
|
2204
2115
|
|
|
@@ -2263,8 +2174,8 @@ var Transportr = (() => {
|
|
|
2263
2174
|
static #globalSubscribr = new Subscribr();
|
|
2264
2175
|
/** @type {Set<AbortSignal>} */
|
|
2265
2176
|
static #activeRequests = /* @__PURE__ */ new Set();
|
|
2266
|
-
/** @type {
|
|
2267
|
-
static #contentTypeHandlers = new
|
|
2177
|
+
/** @type {Map<ResponseHandler<ResponseBody>, string>} */
|
|
2178
|
+
static #contentTypeHandlers = /* @__PURE__ */ new Map([
|
|
2268
2179
|
[_handleImage, mediaTypes.get(http_media_type_default.PNG).type],
|
|
2269
2180
|
[_handleText, mediaTypes.get(http_media_type_default.TEXT).type],
|
|
2270
2181
|
[_handleJson, mediaTypes.get(http_media_type_default.JSON).subtype],
|
|
@@ -2391,24 +2302,6 @@ var Transportr = (() => {
|
|
|
2391
2302
|
global: true,
|
|
2392
2303
|
window: null
|
|
2393
2304
|
});
|
|
2394
|
-
/**
|
|
2395
|
-
* @private
|
|
2396
|
-
* @static
|
|
2397
|
-
* @type {Map<TransportrEvent, ResponseStatus>}
|
|
2398
|
-
*/
|
|
2399
|
-
static #eventResponseStatuses = /* @__PURE__ */ new Map([
|
|
2400
|
-
[RequestEvents.ABORTED, new ResponseStatus(499, "Aborted")],
|
|
2401
|
-
[RequestEvents.TIMEOUT, new ResponseStatus(504, "Gateway Timeout")]
|
|
2402
|
-
]);
|
|
2403
|
-
/**
|
|
2404
|
-
* Returns a {@link AbortSignal} used for aborting requests.
|
|
2405
|
-
*
|
|
2406
|
-
* @static
|
|
2407
|
-
* @returns {AbortSignal} A new {@link AbortSignal} instance.
|
|
2408
|
-
*/
|
|
2409
|
-
static abortSignal() {
|
|
2410
|
-
return new AbortSignal();
|
|
2411
|
-
}
|
|
2412
2305
|
/**
|
|
2413
2306
|
* Returns a {@link EventRegistration} used for subscribing to global events.
|
|
2414
2307
|
*
|
|
@@ -2687,12 +2580,12 @@ var Transportr = (() => {
|
|
|
2687
2580
|
* @async
|
|
2688
2581
|
* @param {string} [path] The path to the endpoint you want to call.
|
|
2689
2582
|
* @param {RequestOptions} [userOptions] The options passed to the public function to use for the request.
|
|
2690
|
-
* @param {RequestOptions} [options] The options for the request.
|
|
2583
|
+
* @param {RequestOptions} [options={}] The options for the request.
|
|
2691
2584
|
* @param {ResponseHandler<ResponseBody>} [responseHandler] A function that will be called with the response object.
|
|
2692
2585
|
* @returns {Promise<ResponseBody>} The result of the #request method.
|
|
2693
2586
|
*/
|
|
2694
|
-
async #get(path, userOptions, options, responseHandler) {
|
|
2695
|
-
return this.#request(path, userOptions,
|
|
2587
|
+
async #get(path, userOptions, options = {}, responseHandler) {
|
|
2588
|
+
return this.#request(path, userOptions, Object.assign(options, { method: http_request_methods_default.GET }), responseHandler);
|
|
2696
2589
|
}
|
|
2697
2590
|
/**
|
|
2698
2591
|
* It takes a path, options, and a response handler, and returns a promise that resolves to the
|
|
@@ -2711,32 +2604,23 @@ var Transportr = (() => {
|
|
|
2711
2604
|
if (object_type_default(path) == Object) {
|
|
2712
2605
|
[path, userOptions] = [void 0, path];
|
|
2713
2606
|
}
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
} catch (cause) {
|
|
2717
|
-
return Promise.reject(new HttpError("Unable to process request options", { cause }));
|
|
2718
|
-
}
|
|
2719
|
-
this.#publish({ name: RequestEvents.CONFIGURED, data: options, global: options.global });
|
|
2607
|
+
options = this.#processRequestOptions(userOptions, options);
|
|
2608
|
+
let response;
|
|
2720
2609
|
const url = _Transportr.#createUrl(this.#baseUrl, path, options.searchParams);
|
|
2721
|
-
if (object_type_default(options.signal) != AbortSignal) {
|
|
2722
|
-
options.signal = new AbortSignal(options.signal);
|
|
2723
|
-
}
|
|
2724
|
-
options.signal.addEventListener(SignalEvents.ABORT, (event) => this.#publish({ name: RequestEvents.ABORTED, event, global: options.global }));
|
|
2725
|
-
options.signal.addEventListener(SignalEvents.TIMEOUT, (event) => this.#publish({ name: RequestEvents.TIMEOUT, event, global: options.global }));
|
|
2726
|
-
_Transportr.#activeRequests.add(options.signal);
|
|
2727
|
-
let response, result;
|
|
2728
2610
|
try {
|
|
2729
|
-
|
|
2730
|
-
|
|
2611
|
+
_Transportr.#activeRequests.add(options.signal);
|
|
2612
|
+
response = await fetch(url, new Proxy(options, abortSignalProxyHandler));
|
|
2613
|
+
if (!responseHandler && response.status != 204) {
|
|
2731
2614
|
responseHandler = this.#getResponseHandler(response.headers.get(http_response_headers_default.CONTENT_TYPE));
|
|
2732
2615
|
}
|
|
2733
|
-
result = await responseHandler?.(response) ?? response;
|
|
2616
|
+
const result = await responseHandler?.(response) ?? response;
|
|
2734
2617
|
if (!response.ok) {
|
|
2735
2618
|
return Promise.reject(this.#handleError(url, { status: _Transportr.#generateResponseStatusFromError("ResponseError", response), entity: result }));
|
|
2736
2619
|
}
|
|
2737
2620
|
this.#publish({ name: RequestEvents.SUCCESS, data: result, global: options.global });
|
|
2738
|
-
|
|
2739
|
-
|
|
2621
|
+
return result;
|
|
2622
|
+
} catch (cause) {
|
|
2623
|
+
return Promise.reject(this.#handleError(url, { cause, status: _Transportr.#generateResponseStatusFromError(cause.name, response) }));
|
|
2740
2624
|
} finally {
|
|
2741
2625
|
options.signal.clearTimeout();
|
|
2742
2626
|
if (!options.signal.aborted) {
|
|
@@ -2747,7 +2631,6 @@ var Transportr = (() => {
|
|
|
2747
2631
|
}
|
|
2748
2632
|
}
|
|
2749
2633
|
}
|
|
2750
|
-
return result;
|
|
2751
2634
|
}
|
|
2752
2635
|
/**
|
|
2753
2636
|
* Creates the options for a {@link Transportr} instance.
|
|
@@ -2819,23 +2702,10 @@ var Transportr = (() => {
|
|
|
2819
2702
|
}
|
|
2820
2703
|
requestOptions.body = void 0;
|
|
2821
2704
|
}
|
|
2705
|
+
requestOptions.signal = new AbortSignal(requestOptions.signal).onAbort((event) => this.#publish({ name: RequestEvents.ABORTED, event, global: requestOptions.global })).onTimeout((event) => this.#publish({ name: RequestEvents.TIMEOUT, event, global: requestOptions.global }));
|
|
2706
|
+
this.#publish({ name: RequestEvents.CONFIGURED, data: requestOptions, global: requestOptions.global });
|
|
2822
2707
|
return requestOptions;
|
|
2823
2708
|
}
|
|
2824
|
-
/**
|
|
2825
|
-
* Returns a Proxy of the options object that traps for 'signal' access.
|
|
2826
|
-
* If the signal has not been aborted, then it will return a new signal with a timeout.
|
|
2827
|
-
*
|
|
2828
|
-
* @private
|
|
2829
|
-
* @static
|
|
2830
|
-
* @param {number} timeout The timeout in milliseconds before the signal is aborted.
|
|
2831
|
-
* @returns {Proxy<RequestOptions>} A proxy for the options object.
|
|
2832
|
-
*/
|
|
2833
|
-
static #requestOptionsProxyHandler(timeout) {
|
|
2834
|
-
return (target, property) => {
|
|
2835
|
-
const value = Reflect.get(target, property);
|
|
2836
|
-
return property == "signal" && !value.aborted ? value.withTimeout(timeout) : value;
|
|
2837
|
-
};
|
|
2838
|
-
}
|
|
2839
2709
|
/**
|
|
2840
2710
|
* It takes a url or a string, and returns a {@link URL} instance.
|
|
2841
2711
|
* If the url is a string and starts with a slash, then the origin of the current page is used as the base url.
|
|
@@ -2884,11 +2754,11 @@ var Transportr = (() => {
|
|
|
2884
2754
|
static #generateResponseStatusFromError(errorName, response) {
|
|
2885
2755
|
switch (errorName) {
|
|
2886
2756
|
case "AbortError":
|
|
2887
|
-
return
|
|
2757
|
+
return eventResponseStatuses[RequestEvents.ABORTED];
|
|
2888
2758
|
case "TimeoutError":
|
|
2889
|
-
return
|
|
2759
|
+
return eventResponseStatuses[RequestEvents.TIMEOUT];
|
|
2890
2760
|
default:
|
|
2891
|
-
return response ? new ResponseStatus(response.status, response.statusText) :
|
|
2761
|
+
return response ? new ResponseStatus(response.status, response.statusText) : internalServerError;
|
|
2892
2762
|
}
|
|
2893
2763
|
}
|
|
2894
2764
|
/**
|