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