@d1g1tal/transportr 1.4.2 → 2.0.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.
@@ -0,0 +1,1799 @@
1
+ import { Subscription } from "@d1g1tal/subscribr";
2
+ import { MediaType } from "@d1g1tal/media-type";
3
+
4
+ /**
5
+ * A collection of some of the available HTTP media types.
6
+ * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | IANA Media Types}
7
+ */
8
+ declare const HttpMediaType: {
9
+ /** Advanced Audio Coding (AAC) */
10
+ readonly AAC: "audio/aac";
11
+ /** AbiWord */
12
+ readonly ABW: "application/x-abiword";
13
+ /** Archive document (multiple files embedded) */
14
+ readonly ARC: "application/x-freearc";
15
+ /** AVIF image */
16
+ readonly AVIF: "image/avif";
17
+ /** Audio Video Interleave (AVI) */
18
+ readonly AVI: "video/x-msvideo";
19
+ /** Amazon Kindle eBook format */
20
+ readonly AZW: "application/vnd.amazon.ebook";
21
+ /** Binary Data */
22
+ readonly BIN: "application/octet-stream";
23
+ /** Windows OS/2 Bitmap Graphics */
24
+ readonly BMP: "image/bmp";
25
+ /** Bzip Archive */
26
+ readonly BZIP: "application/x-bzip";
27
+ /** Bzip2 Archive */
28
+ readonly BZIP2: "application/x-bzip2";
29
+ /** CD audio */
30
+ readonly CDA: "application/x-cdf";
31
+ /** C Shell Script */
32
+ readonly CSH: "application/x-csh";
33
+ /** Cascading Style Sheets (CSS) */
34
+ readonly CSS: "text/css";
35
+ /** Comma-Separated Values */
36
+ readonly CSV: "text/csv";
37
+ /** Microsoft Office Word Document */
38
+ readonly DOC: "application/msword";
39
+ /** Microsoft Office Word Document (OpenXML) */
40
+ readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
41
+ /** Microsoft Embedded OpenType */
42
+ readonly EOT: "application/vnd.ms-fontobject";
43
+ /** Electronic Publication (EPUB) */
44
+ readonly EPUB: "application/epub+zip";
45
+ /** GZip Compressed Archive */
46
+ readonly GZIP: "application/gzip";
47
+ /** Graphics Interchange Format */
48
+ readonly GIF: "image/gif";
49
+ /** HyperText Markup Language (HTML) */
50
+ readonly HTML: "text/html";
51
+ /** Icon Format */
52
+ readonly ICO: "image/vnd.microsoft.icon";
53
+ /** iCalendar Format */
54
+ readonly ICS: "text/calendar";
55
+ /** Java Archive (JAR) */
56
+ readonly JAR: "application/java-archive";
57
+ /** JPEG Image */
58
+ readonly JPEG: "image/jpeg";
59
+ /** JavaScript */
60
+ readonly JAVA_SCRIPT: "text/javascript";
61
+ /** JavaScript Object Notation Format (JSON) */
62
+ readonly JSON: "application/json";
63
+ /** JavaScript Object Notation LD Format */
64
+ readonly JSON_LD: "application/ld+json";
65
+ /** JavaScript Object Notation (JSON) Merge Patch */
66
+ readonly JSON_MERGE_PATCH: "application/merge-patch+json";
67
+ /** Musical Instrument Digital Interface (MIDI) */
68
+ readonly MID: "audio/midi";
69
+ /** Musical Instrument Digital Interface (MIDI) */
70
+ readonly X_MID: "audio/x-midi";
71
+ /** MP3 Audio */
72
+ readonly MP3: "audio/mpeg";
73
+ /** MPEG-4 Audio */
74
+ readonly MP4A: "audio/mp4";
75
+ /** MPEG-4 Video */
76
+ readonly MP4: "video/mp4";
77
+ /** MPEG Video */
78
+ readonly MPEG: "video/mpeg";
79
+ /** Apple Installer Package */
80
+ readonly MPKG: "application/vnd.apple.installer+xml";
81
+ /** OpenDocument Presentation Document */
82
+ readonly ODP: "application/vnd.oasis.opendocument.presentation";
83
+ /** OpenDocument Spreadsheet Document */
84
+ readonly ODS: "application/vnd.oasis.opendocument.spreadsheet";
85
+ /** OpenDocument Text Document */
86
+ readonly ODT: "application/vnd.oasis.opendocument.text";
87
+ /** Ogg Audio */
88
+ readonly OGA: "audio/ogg";
89
+ /** Ogg Video */
90
+ readonly OGV: "video/ogg";
91
+ /** Ogg */
92
+ readonly OGX: "application/ogg";
93
+ /** Opus audio */
94
+ readonly OPUS: "audio/opus";
95
+ /** OpenType Font File */
96
+ readonly OTF: "font/otf";
97
+ /** Portable Network Graphics (PNG) */
98
+ readonly PNG: "image/png";
99
+ /** Adobe Portable Document Format */
100
+ readonly PDF: "application/pdf";
101
+ /** Hypertext Preprocessor (Personal Home Page) */
102
+ readonly PHP: "application/x-httpd-php";
103
+ /** Microsoft PowerPoint */
104
+ readonly PPT: "application/vnd.ms-powerpoint";
105
+ /** Microsoft Office Presentation (OpenXML) */
106
+ readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
107
+ /** RAR Archive */
108
+ readonly RAR: "application/vnd.rar";
109
+ /** Rich Text Format */
110
+ readonly RTF: "application/rtf";
111
+ /** Bourne Shell Script */
112
+ readonly SH: "application/x-sh";
113
+ /** Scalable Vector Graphics (SVG) */
114
+ readonly SVG: "image/svg+xml";
115
+ /** Tape Archive (TAR) */
116
+ readonly TAR: "application/x-tar";
117
+ /** Tagged Image File Format (TIFF) */
118
+ readonly TIFF: "image/tiff";
119
+ /** MPEG transport stream */
120
+ readonly TRANSPORT_STREAM: "video/mp2t";
121
+ /** TrueType Font */
122
+ readonly TTF: "font/ttf";
123
+ /** Text, (generally ASCII or ISO 8859-n) */
124
+ readonly TEXT: "text/plain";
125
+ /** Microsoft Visio */
126
+ readonly VSD: "application/vnd.visio";
127
+ /** Waveform Audio Format (WAV) */
128
+ readonly WAV: "audio/wav";
129
+ /** Open Web Media Project - Audio */
130
+ readonly WEBA: "audio/webm";
131
+ /** Open Web Media Project - Video */
132
+ readonly WEBM: "video/webm";
133
+ /** WebP Image */
134
+ readonly WEBP: "image/webp";
135
+ /** Web Open Font Format */
136
+ readonly WOFF: "font/woff";
137
+ /** Web Open Font Format */
138
+ readonly WOFF2: "font/woff2";
139
+ /** Form - Encoded */
140
+ readonly FORM: "application/x-www-form-urlencoded";
141
+ /** Multipart FormData */
142
+ readonly MULTIPART_FORM_DATA: "multipart/form-data";
143
+ /** XHTML - The Extensible HyperText Markup Language */
144
+ readonly XHTML: "application/xhtml+xml";
145
+ /** Microsoft Excel Document */
146
+ readonly XLS: "application/vnd.ms-excel";
147
+ /** Microsoft Office Spreadsheet Document (OpenXML) */
148
+ readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
149
+ /** Extensible Markup Language (XML) */
150
+ readonly XML: "application/xml";
151
+ /** XML User Interface Language (XUL) */
152
+ readonly XUL: "application/vnd.mozilla.xul+xml";
153
+ /** Zip Archive */
154
+ readonly ZIP: "application/zip";
155
+ /** 3GPP audio/video container */
156
+ readonly '3GP': "video/3gpp";
157
+ /** 3GPP2 audio/video container */
158
+ readonly '3G2': "video/3gpp2";
159
+ /** 7-Zip Archive */
160
+ readonly '7Z': "application/x-7z-compressed";
161
+ };
162
+
163
+ /**
164
+ * Defining a constant object with all the HTTP request headers.
165
+ */
166
+ declare const HttpRequestHeader: {
167
+ /**
168
+ * Content-Types that are acceptable for the response. See Content negotiation. Permanent.
169
+ *
170
+ * @example
171
+ * <code>Accept: text/plain</code>
172
+ */
173
+ readonly ACCEPT: "accept";
174
+ /**
175
+ * Character sets that are acceptable. Permanent.
176
+ *
177
+ * @example
178
+ * <code>Accept-Charset: utf-8</code>
179
+ */
180
+ readonly ACCEPT_CHARSET: "accept-charset";
181
+ /**
182
+ * List of acceptable encodings. See HTTP compression. Permanent.
183
+ *
184
+ * @example
185
+ * <code>Accept-Encoding: gzip, deflate</code>
186
+ */
187
+ readonly ACCEPT_ENCODING: "accept-encoding";
188
+ /**
189
+ * List of acceptable human languages for response. See Content negotiation. Permanent.
190
+ *
191
+ * @example
192
+ * <code>Accept-Language: en-US</code>
193
+ */
194
+ readonly ACCEPT_LANGUAGE: "accept-language";
195
+ /**
196
+ * Authentication credentials for HTTP authentication. Permanent.
197
+ *
198
+ * @example
199
+ * <code>Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</code>
200
+ */
201
+ readonly AUTHORIZATION: "authorization";
202
+ /**
203
+ * Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain.
204
+ * Permanent.
205
+ *
206
+ * @example
207
+ * <code>Cache-Control: no-cache</code>
208
+ */
209
+ readonly CACHE_CONTROL: "cache-control";
210
+ /**
211
+ * Control options for the current connection and list of hop-by-hop request fields. Permanent.
212
+ *
213
+ * @example
214
+ * <code>Connection: keep-alive</code>
215
+ * <code>Connection: Upgrade</code>
216
+ */
217
+ readonly CONNECTION: "connection";
218
+ /**
219
+ * An HTTP cookie previously sent by the server with Set-Cookie (below). Permanent: standard.
220
+ *
221
+ * @example
222
+ * <code>Cookie: $Version=1, Skin=new,</code>
223
+ */
224
+ readonly COOKIE: "cookie";
225
+ /**
226
+ * The length of the request body in octets (8-bit bytes). Permanent.
227
+ *
228
+ * @example
229
+ * <code>Content-Length: 348</code>
230
+ */
231
+ readonly CONTENT_LENGTH: "content-length";
232
+ /**
233
+ * A Base64-encoded binary MD5 sum of the content of the request body. Obsolete.
234
+ *
235
+ * @example
236
+ * <code>Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==</code>
237
+ */
238
+ readonly CONTENT_MD5: "content-md5";
239
+ /**
240
+ * The MIME type of the body of the request (used with POST and PUT requests). Permanent.
241
+ * <code>Content-Type: application/x-www-form-urlencoded</code>
242
+ */
243
+ readonly CONTENT_TYPE: "content-type";
244
+ /**
245
+ * The date and time that the message was sent (in "HTTP-date" format as defined by RFC 7231 Date/Time Formats).
246
+ * Permanent.
247
+ *
248
+ * @example
249
+ * <code>Date: Tue, 15 Nov 1994 08:12:31 GMT</code>
250
+ */
251
+ readonly DATE: "date";
252
+ /**
253
+ * The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The
254
+ * port number may be omitted if the port is the standard port for the service requested. Permanent. Mandatory since
255
+ * HTTP/1.1.
256
+ *
257
+ * @example
258
+ * <code>Host: en.wikipedia.org:80</code>
259
+ * <code>Host: en.wikipedia.org</code>
260
+ */
261
+ readonly HOST: "host";
262
+ /**
263
+ * Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for
264
+ * methods like PUT to only update a resource if it has not been modified since the user last updated it. Permanent.
265
+ *
266
+ * @example
267
+ * <code>If-Match: "737060cd8c284d8af7ad3082f209582d"</code>
268
+ */
269
+ readonly IF_MATCH: "if-match";
270
+ /**
271
+ * Allows a 304 Not Modified to be returned if content is unchanged. Permanent.
272
+ *
273
+ * @example
274
+ * <code>If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT</code>
275
+ */
276
+ readonly IF_MODIFIED_SINCE: "if-modified-since";
277
+ /**
278
+ * Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag. Permanent.
279
+ *
280
+ * @example
281
+ * <code>If-None-Match: "737060cd8c284d8af7ad3082f209582d"</code>
282
+ */
283
+ readonly IF_NONE_MATCH: "if-none-match";
284
+ /**
285
+ * If the entity is unchanged, send me the part(s) that I am missing, otherwise, send me the entire new entity.
286
+ * Permanent.
287
+ *
288
+ * @example
289
+ * <code>If-Range: "737060cd8c284d8af7ad3082f209582d"</code>
290
+ */
291
+ readonly IF_RANGE: "if-range";
292
+ /**
293
+ * Only send the response if the entity has not been modified since a specific time. Permanent.
294
+ *
295
+ * @example
296
+ * <code>If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT</code>
297
+ */
298
+ readonly IF_UNMODIFIED_SINCE: "if-unmodified-since";
299
+ /**
300
+ * Limit the number of times the message can be forwarded through proxies or gateways. Permanent.
301
+ *
302
+ * @example
303
+ * <code>Max-Forwards: 10</code>
304
+ */
305
+ readonly MAX_FORWARDS: "max-forwards";
306
+ /**
307
+ * Initiates a request for cross-origin resource sharing (asks server for an 'Access-Control-Allow-Origin' response
308
+ * field). Permanent: standard.
309
+ *
310
+ * @example
311
+ * <code>Origin: http://www.example-social-network.com</code>
312
+ */
313
+ readonly ORIGIN: "origin";
314
+ /**
315
+ * Implementation-specific fields that may have various effects anywhere along the request-response chain. Permanent.
316
+ *
317
+ * @example
318
+ * <code>Pragma: no-cache</code>
319
+ */
320
+ readonly PRAGMA: "pragma";
321
+ /**
322
+ * Authorization credentials for connecting to a proxy. Permanent.
323
+ *
324
+ * @example
325
+ * <code>Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</code>
326
+ */
327
+ readonly PROXY_AUTHORIZATION: "proxy-authorization";
328
+ /**
329
+ * Request only part of an entity. Bytes are numbered from 0. See Byte serving. Permanent.
330
+ *
331
+ * @example
332
+ * <code>Range: bytes=500-999</code>
333
+ */
334
+ readonly RANGE: "range";
335
+ /**
336
+ * This is the address of the previous web page from which a link to the currently requested page was followed. (The
337
+ * word "referrer" has been misspelled in the RFC as well as in most implementations to the point that it has become
338
+ * standard usage and is considered correct terminology). Permanent.
339
+ *
340
+ * @example
341
+ * <code>Referer: http://en.wikipedia.org/wiki/Main_Page</code>
342
+ */
343
+ readonly REFERER: "referer";
344
+ /**
345
+ * The transfer encodings the user agent is willing to accept: the same values as for the response header field
346
+ * Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the
347
+ * server it expects to receive additional fields in the trailer after the last, zero-sized, chunk. Permanent.
348
+ *
349
+ * @example
350
+ * <code>TE: trailers, deflate</code>
351
+ */
352
+ readonly TE: "te";
353
+ /**
354
+ * The user agent string of the user agent. Permanent.
355
+ *
356
+ * @example
357
+ * <code>User-Agent: Mozilla/5.0 (X11, Linux x86_64, rv:12.0) Gecko/20100101 Firefox/21.0</code>
358
+ */
359
+ readonly USER_AGENT: "user-agent";
360
+ /**
361
+ * Ask the server to upgrade to another protocol. Permanent.
362
+ *
363
+ * @example
364
+ * <code>Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11</code>
365
+ */
366
+ readonly UPGRADE: "upgrade";
367
+ /**
368
+ * A general warning about possible problems with the entity body. Permanent.
369
+ *
370
+ * @example
371
+ * <code>Warning: 199 Miscellaneous warning</code>
372
+ */
373
+ readonly WARNING: "warning";
374
+ /**
375
+ * mainly used to identify Ajax requests. Most JavaScript frameworks send this field with value of XMLHttpRequest.
376
+ *
377
+ * @example
378
+ * <code>X-Requested-With: XMLHttpRequest</code>
379
+ */
380
+ readonly X_REQUESTED_WITH: "x-requested-with";
381
+ /**
382
+ * A de facto standard for identifying the originating IP address of a client connecting to a web server through an
383
+ * HTTP proxy or load balancer.
384
+ *
385
+ * @example
386
+ * <code>X-Forwarded-For: client1, proxy1, proxy2</code>
387
+ * <code>X-Forwarded-For: 129.78.138.66, 129.78.64.103</code>
388
+ */
389
+ readonly X_FORWARDED_FOR: "x-forwarded-for";
390
+ /**
391
+ * A de facto standard for identifying the original host requested by the client in the Host HTTP request header, since
392
+ * the host name and/or port of the reverse proxy (load balancer) may differ from the origin server handling the
393
+ * request.
394
+ *
395
+ * @example
396
+ * <code>X-Forwarded-Host: en.wikipedia.org:80</code>
397
+ * <code>X-Forwarded-Host: en.wikipedia.org</code>
398
+ */
399
+ readonly X_FORWARDED_HOST: "x-forwarded-host";
400
+ /**
401
+ * A de facto standard for identifying the originating protocol of an HTTP request, since a reverse proxy (load
402
+ * balancer) may communicate with a web server using HTTP even if the request to the reverse proxy is HTTPS. An
403
+ * alternative form of the header (X-ProxyUser-Ip) is used by Google clients talking to Google servers.
404
+ *
405
+ * @example
406
+ * <code>X-Forwarded-Proto: https</code>
407
+ */
408
+ readonly X_FORWARDED_PROTO: "x-forwarded-proto";
409
+ };
410
+
411
+ /**
412
+ * Defining a constant object with the name HttpRequestMethod.
413
+ */
414
+ declare const HttpRequestMethod: {
415
+ /**
416
+ * The OPTIONS method represents a request for information about the communication options available on the
417
+ * request/response chain identified by the Request-URI. This method allows the client to determine the options and/or
418
+ * requirements associated with a resource, or the capabilities of a server, without implying a resource action or
419
+ * initiating a resource retrieval.
420
+ *
421
+ * Responses to this method are not cacheable.
422
+ *
423
+ * If the OPTIONS request includes an entity-body (as indicated by the presence of Content-Length or
424
+ * Transfer-Encoding), then the media type MUST be indicated by a Content-Type field. Although this specification does
425
+ * not define any use for such a body, future extensions to HTTP might use the OPTIONS body to make more detailed
426
+ * queries on the server. A server that does not support such an extension MAY discard the request body.
427
+ *
428
+ * If the Request-URI is an asterisk ("*"), the OPTIONS request is intended to apply to the server in general rather
429
+ * than to a specific resource. Since a server's communication options typically depend on the resource, the "*"
430
+ * request is only useful as a "ping" or "no-op" type of method, it does nothing beyond allowing the client to test the
431
+ * capabilities of the server. For example, this can be used to test a proxy for HTTP/1.1 compliance (or lack thereof).
432
+ *
433
+ * If the Request-URI is not an asterisk, the OPTIONS request applies only to the options that are available when
434
+ * communicating with that resource.
435
+ *
436
+ * A 200 response SHOULD include any header fields that indicate optional features implemented by the server and
437
+ * applicable to that resource (e.g., Allow), possibly including extensions not defined by this specification. The
438
+ * response body, if any, SHOULD also include information about the communication options. The format for such a body
439
+ * is not defined by this specification, but might be defined by future extensions to HTTP. Content negotiation MAY be
440
+ * used to select the appropriate response format. If no response body is included, the response MUST include a
441
+ * Content-Length field with a field-value of "0".
442
+ *
443
+ * The Max-Forwards request-header field MAY be used to target a specific proxy in the request chain. When a proxy
444
+ * receives an OPTIONS request on an absoluteURI for which request forwarding is permitted, the proxy MUST check for a
445
+ * Max-Forwards field. If the Max-Forwards field-value is zero ("0"), the proxy MUST NOT forward the message, instead,
446
+ * the proxy SHOULD respond with its own communication options. If the Max-Forwards field-value is an integer greater
447
+ * than zero, the proxy MUST decrement the field-value when it forwards the request. If no Max-Forwards field is
448
+ * present in the request, then the forwarded request MUST NOT include a Max-Forwards field.
449
+ */
450
+ readonly OPTIONS: "OPTIONS";
451
+ /**
452
+ * The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If
453
+ * the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in
454
+ * the response and not the source text of the process, unless that text happens to be the output of the process.
455
+ *
456
+ * The semantics of the GET method change to a "conditional GET" if the request message includes an If-Modified-Since;
457
+ * If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the
458
+ * entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET
459
+ * method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring
460
+ * multiple requests or transferring data already held by the client.
461
+ *
462
+ * The semantics of the GET method change to a "partial GET" if the request message includes a Range header field. A
463
+ * partial GET requests that only part of the entity be transferred, as described in section 14.35. The partial GET
464
+ * method is intended to reduce unnecessary network usage by allowing partially-retrieved entities to be completed
465
+ * without transferring data already held by the client.
466
+ *
467
+ * The response to a GET request is cacheable if and only if it meets the requirements for HTTP caching described in
468
+ * section 13.
469
+ *
470
+ * See section 15.1.3 for security considerations when used for forms.
471
+ */
472
+ readonly GET: "GET";
473
+ /**
474
+ * The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The
475
+ * meta information contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information
476
+ * sent in response to a GET request. This method can be used for obtaining meta information about the entity implied by
477
+ * the request without transferring the entity-body itself. This method is often used for testing hypertext links for
478
+ * validity, accessibility, and recent modification.
479
+ *
480
+ * The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be
481
+ * used to update a previously cached entity from that resource. If the new field values indicate that the cached
482
+ * entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or
483
+ * Last-Modified), then the cache MUST treat the cache entry as stale.
484
+ */
485
+ readonly HEAD: "HEAD";
486
+ /**
487
+ * The POST method is used to request that the origin server accept the entity enclosed in the request as a new
488
+ * subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform
489
+ * method to cover the following functions:
490
+ * <ul>
491
+ * <li>Annotation of existing resources,</li>
492
+ * <li>Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles,</li>
493
+ * <li>Providing a block of data, such as the result of submitting a form, to a data-handling process,</li>
494
+ * <li>Extending a database through an append operation.</li>
495
+ * </ul>
496
+ *
497
+ * The actual function performed by the POST method is determined by the server and is usually dependent on the
498
+ * Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory
499
+ * containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a
500
+ * database.
501
+ *
502
+ * The action performed by the POST method might not result in a resource that can be identified by a URI. In this
503
+ * case, either 200 (OK) or 204 (No Content) is the appropriate response status, depending on whether or not the
504
+ * response includes an entity that describes the result.
505
+ *
506
+ * If a resource has been created on the origin server, the response SHOULD be 201 (Created) and contain an entity
507
+ * which describes the status of the request and refers to the new resource, and a Location header (see section 14.30).
508
+ *
509
+ * Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header
510
+ * fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.
511
+ *
512
+ * POST requests MUST obey the message transmission requirements set out in section 8.2.
513
+ *
514
+ * See section 15.1.3 for security considerations.
515
+ */
516
+ readonly POST: "POST";
517
+ /**
518
+ * The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers
519
+ * to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing
520
+ * on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being
521
+ * defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If
522
+ * a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an
523
+ * existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate
524
+ * successful completion of the request. If the resource could not be created or modified with the Request-URI, an
525
+ * appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST
526
+ * \NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a
527
+ * 501 (Not Implemented) response in such cases.
528
+ *
529
+ * If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those
530
+ * entries SHOULD be treated as stale. Responses to this method are not cacheable.
531
+ *
532
+ * The fundamental difference between the POST and PUT requests is reflected in the different meaning of the
533
+ * Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource
534
+ * might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations.
535
+ * In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what
536
+ * URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires
537
+ * that the request be applied to a different URI, it MUST send a 301 (Moved Permanently) response, the user agent MAY
538
+ * then make its own decision regarding whether or not to redirect the request.
539
+ *
540
+ * A single resource MAY be identified by many different URIs. For example, an article might have a URI for identifying
541
+ * "the current version" which is separate from the URI identifying each particular version. In this case, a PUT
542
+ * request on a general URI might result in several other URIs being defined by the origin server.
543
+ *
544
+ * HTTP/1.1 does not define how a PUT method affects the state of an origin server.
545
+ *
546
+ * PUT requests MUST obey the message transmission requirements set out in section 8.2.
547
+ *
548
+ * Unless otherwise specified for a particular entity-header, the entity-headers in the PUT request SHOULD be applied
549
+ * to the resource created or modified by the PUT.
550
+ */
551
+ readonly PUT: "PUT";
552
+ /**
553
+ * The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY
554
+ * be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the
555
+ * operation has been carried out, even if the status code returned from the origin server indicates that the action
556
+ * has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response
557
+ * is given, it intends to delete the resource or move it to an inaccessible location.
558
+ *
559
+ * A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if
560
+ * the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not
561
+ * include an entity.
562
+ *
563
+ * If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those
564
+ * entries SHOULD be treated as stale. Responses to this method are not cacheable.
565
+ */
566
+ readonly DELETE: "DELETE";
567
+ /**
568
+ * The TRACE method is used to invoke a remote, application-layer loop- back of the request message. The final
569
+ * recipient of the request SHOULD reflect the message received back to the client as the entity-body of a 200 (OK)
570
+ * response. The final recipient is either the origin server or the first proxy or gateway to receive a Max-Forwards
571
+ * value of zero (0) in the request (see section 14.31). A TRACE request MUST NOT include an entity.
572
+ *
573
+ * TRACE allows the client to see what is being received at the other end of the request chain and use that data for
574
+ * testing or diagnostic information. The value of the Via header field (section 14.45) is of particular interest,
575
+ * since it acts as a trace of the request chain. Use of the Max-Forwards header field allows the client to limit the
576
+ * length of the request chain, which is useful for testing a chain of proxies forwarding messages in an infinite loop.
577
+ *
578
+ * If the request is valid, the response SHOULD contain the entire request message in the entity-body, with a
579
+ * Content-Type of "message/http". Responses to this method MUST NOT be cached.
580
+ */
581
+ readonly TRACE: "TRACE";
582
+ /**
583
+ * This specification reserves the method name CONNECT for use with a proxy that can dynamically switch to being a
584
+ * tunnel (e.g. SSL tunneling [44]).
585
+ */
586
+ readonly CONNECT: "CONNECT";
587
+ /**
588
+ * The PATCH method requests that a set of changes described in the
589
+ * request entity be applied to the resource identified by the Request-
590
+ * URI. The set of changes is represented in a format called a "patch
591
+ * document" identified by a media type. If the Request-URI does not
592
+ * point to an existing resource, the server MAY create a new resource,
593
+ * depending on the patch document type (whether it can logically modify
594
+ * a null resource) and permissions, etc.
595
+ *
596
+ * The difference between the PUT and PATCH requests is reflected in the
597
+ * way the server processes the enclosed entity to modify the resource
598
+ * identified by the Request-URI. In a PUT request, the enclosed entity
599
+ * is considered to be a modified version of the resource stored on the
600
+ * origin server, and the client is requesting that the stored version
601
+ * be replaced. With PATCH, however, the enclosed entity contains a set
602
+ * of instructions describing how a resource currently residing on the
603
+ * origin server should be modified to produce a new version. The PATCH
604
+ * method affects the resource identified by the Request-URI, and it
605
+ * also MAY have side effects on other resources; i.e., new resources
606
+ * may be created, or existing ones modified, by the application of a
607
+ * PATCH.
608
+ *
609
+ * PATCH is neither safe nor idempotent as defined by [RFC2616], Section
610
+ * 9.1.
611
+ *
612
+ * A PATCH request can be issued in such a way as to be idempotent,
613
+ * which also helps prevent bad outcomes from collisions between two
614
+ * PATCH requests on the same resource in a similar time frame.
615
+ * Collisions from multiple PATCH requests may be more dangerous than
616
+ * PUT collisions because some patch formats need to operate from a
617
+ * known base-point or else they will corrupt the resource. Clients
618
+ * using this kind of patch application SHOULD use a conditional request
619
+ * such that the request will fail if the resource has been updated
620
+ * since the client last accessed the resource. For example, the client
621
+ * can use a strong ETag [RFC2616] in an If-Match header on the PATCH
622
+ * request.
623
+ *
624
+ * There are also cases where patch formats do not need to operate from
625
+ * a known base-point (e.g., appending text lines to log files, or non-
626
+ * colliding rows to database tables), in which case the same care in
627
+ * client requests is not needed.
628
+ *
629
+ * The server MUST apply the entire set of changes atomically and never
630
+ * provide (e.g., in response to a GET during this operation) a
631
+ * partially modified representation. If the entire patch document
632
+ * cannot be successfully applied, then the server MUST NOT apply any of
633
+ * the changes. The determination of what constitutes a successful
634
+ * PATCH can vary depending on the patch document and the type of
635
+ * resource(s) being modified. For example, the common 'diff' utility
636
+ * can generate a patch document that applies to multiple files in a
637
+ * directory hierarchy. The atomicity requirement holds for all
638
+ * directly affected files. See "Error Handling", Section 2.2, for
639
+ * details on status codes and possible error conditions.
640
+ *
641
+ * If the request passes through a cache and the Request-URI identifies
642
+ * one or more currently cached entities, those entries SHOULD be
643
+ * treated as stale. A response to this method is only cacheable if it
644
+ * contains explicit freshness information (such as an Expires header or
645
+ * "Cache-Control: max-age" directive) as well as the Content-Location
646
+ * header matching the Request-URI, indicating that the PATCH response
647
+ * body is a resource representation. A cached PATCH response can only
648
+ * be used to respond to subsequent GET and HEAD requests; it MUST NOT
649
+ * be used to respond to other methods (in particular, PATCH).
650
+ *
651
+ * Note that entity-headers contained in the request apply only to the
652
+ * contained patch document and MUST NOT be applied to the resource
653
+ * being modified. Thus, a Content-Language header could be present on
654
+ * the request, but it would only mean (for whatever that's worth) that
655
+ * the patch document had a language. Servers SHOULD NOT store such
656
+ * headers except as trace information, and SHOULD NOT use such header
657
+ * values the same way they might be used on PUT requests. Therefore,
658
+ * this document does not specify a way to modify a document's Content-
659
+ * Type or Content-Language value through headers, though a mechanism
660
+ * could well be designed to achieve this goal through a patch document.
661
+ *
662
+ * There is no guarantee that a resource can be modified with PATCH.
663
+ * Further, it is expected that different patch document formats will be
664
+ * appropriate for different types of resources and that no single
665
+ * format will be appropriate for all types of resources. Therefore,
666
+ * there is no single default patch document format that implementations
667
+ * are required to support. Servers MUST ensure that a received patch
668
+ * document is appropriate for the type of resource identified by the
669
+ * Request-URI.
670
+ *
671
+ * Clients need to choose when to use PATCH rather than PUT. For
672
+ * example, if the patch document size is larger than the size of the
673
+ * new resource data that would be used in a PUT, then it might make
674
+ * sense to use PUT instead of PATCH. A comparison to POST is even more
675
+ * difficult, because POST is used in widely varying ways and can
676
+ * encompass PUT and PATCH-like operations if the server chooses. If
677
+ * the operation does not modify the resource identified by the Request-
678
+ * URI in a predictable way, POST should be considered instead of PATCH
679
+ * or PUT.
680
+ */
681
+ readonly PATCH: "PATCH";
682
+ };
683
+
684
+ /** Defining a constant object HTTP response headers */
685
+ declare const HttpResponseHeader: {
686
+ /**
687
+ * 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.
688
+ *
689
+ * @example
690
+ * proxy-connection: keep-alive
691
+ */
692
+ readonly PROXY_CONNECTION: "proxy-connection";
693
+ /**
694
+ * Server-side deep packet insertion of a unique ID identifying customers of Verizon Wireless, also known as "perma-cookie" or "supercookie"
695
+ *
696
+ * @example
697
+ * x-uidh: ...
698
+ */
699
+ readonly X_UIDH: "x-uidh";
700
+ /**
701
+ * Used to prevent cross-site request forgery. Alternative header names are: X-CSRFToken and X-XSRF-TOKEN
702
+ *
703
+ * @example
704
+ * x-csrf-token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
705
+ */
706
+ readonly X_CSRF_TOKEN: "x-csrf-token";
707
+ /**
708
+ * Specifying which web sites can participate in cross-origin resource sharing
709
+ *
710
+ * @example
711
+ * access-control-allow-origin: *
712
+ * Provisional
713
+ */
714
+ readonly ACCESS_CONTROL_ALLOW_ORIGIN: "access-control-allow-origin";
715
+ /**
716
+ * Specifies which patch document formats this server supports
717
+ *
718
+ * @example
719
+ * accept-patch: text/example,charset=utf-8
720
+ * Permanent
721
+ */
722
+ readonly ACCEPT_PATCH: "accept-patch";
723
+ /**
724
+ * What partial content range types this server supports via byte serving
725
+ *
726
+ * @example
727
+ * accept-ranges: bytes
728
+ * Permanent
729
+ */
730
+ readonly ACCEPT_RANGES: "accept-ranges";
731
+ /**
732
+ * The age the object has been in a proxy cache in seconds
733
+ *
734
+ * @example
735
+ * age: 12
736
+ * Permanent
737
+ */
738
+ readonly AGE: "age";
739
+ /**
740
+ * Valid actions for a specified resource. To be used for a 405 Method not allowed
741
+ *
742
+ * @example
743
+ * allow: GET, HEAD
744
+ * Permanent
745
+ */
746
+ readonly ALLOW: "allow";
747
+ /**
748
+ * Tells all caching mechanisms from server to client whether they may cache this object. It is measured in seconds
749
+ *
750
+ * @example
751
+ * cache-control: max-age=3600
752
+ * Permanent
753
+ */
754
+ readonly CACHE_CONTROL: "cache-control";
755
+ /**
756
+ * Control options for the current connection and list of hop-by-hop response fields
757
+ *
758
+ * @example
759
+ * connection: close
760
+ * Permanent
761
+ */
762
+ readonly CONNECTION: "connection";
763
+ /**
764
+ * 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.
765
+ *
766
+ * @example
767
+ * content-disposition: attachment, filename="fname.ext"
768
+ * Permanent
769
+ */
770
+ readonly CONTENT_DISPOSITION: "content-disposition";
771
+ /**
772
+ * The type of encoding used on the data. See HTTP compression.
773
+ *
774
+ * @example
775
+ * content-encoding: gzip
776
+ * Permanent
777
+ */
778
+ readonly CONTENT_ENCODING: "content-encoding";
779
+ /**
780
+ * The natural language or languages of the intended audience for the enclosed content
781
+ *
782
+ * @example
783
+ * content-language: da
784
+ * Permanent
785
+ */
786
+ readonly CONTENT_LANGUAGE: "content-language";
787
+ /**
788
+ * The length of the response body in octets (8-bit bytes)
789
+ *
790
+ * @example
791
+ * content-length: 348
792
+ * Permanent
793
+ */
794
+ readonly CONTENT_LENGTH: "content-length";
795
+ /**
796
+ * An alternate location for the returned data
797
+ *
798
+ * @example
799
+ * content-location: /index.htm
800
+ * Permanent
801
+ */
802
+ readonly CONTENT_LOCATION: "content-location";
803
+ /**
804
+ * Where in a full body message this partial message belongs
805
+ *
806
+ * @example
807
+ * content-range: bytes 21010-47021/47022
808
+ * Permanent
809
+ */
810
+ readonly CONTENT_RANGE: "content-range";
811
+ /**
812
+ * The MIME type of this content
813
+ *
814
+ * @example
815
+ * content-type: text/html, charset=utf-8
816
+ * Permanent
817
+ */
818
+ readonly CONTENT_TYPE: "content-type";
819
+ /**
820
+ * The date and time that the message was sent (in "HTTP-date" format as defined by RFC 7231)
821
+ *
822
+ * @example
823
+ * date: Tue, 15 Nov 1994 08:12:31 GMT
824
+ * Permanent
825
+ */
826
+ readonly DATE: "date";
827
+ /**
828
+ * An identifier for a specific version of a resource, often a message digest
829
+ *
830
+ * @example
831
+ * etag: "737060cd8c284d8af7ad3082f209582d"
832
+ * Permanent
833
+ */
834
+ readonly ETAG: "etag";
835
+ /**
836
+ * Gives the date/time after which the response is considered stale (in "HTTP-date" format as defined by RFC 7231)
837
+ *
838
+ * @example
839
+ * expires: Thu, 01 Dec 1994 16:00:00 GMT
840
+ * Permanent
841
+ */
842
+ readonly EXPIRES: "expires";
843
+ /**
844
+ * The last modified date for the requested object (in "HTTP-date" format as defined by RFC 7231)
845
+ *
846
+ * @example
847
+ * last-modified: Tue, 15 Nov 1994 12:45:26 GMT
848
+ * Permanent
849
+ */
850
+ readonly LAST_MODIFIED: "last-modified";
851
+ /**
852
+ * Used to express a typed relationship with another resource, where the relation type is defined by RFC 5988
853
+ *
854
+ * @example
855
+ * link: </feed>, rel="alternate"
856
+ * Permanent
857
+ */
858
+ readonly LINK: "link";
859
+ /**
860
+ * Used in redirection, or when a new resource has been created.
861
+ *
862
+ * @example
863
+ * location: http://www.w3.org/pub/WWW/People.html
864
+ * Permanent
865
+ */
866
+ readonly LOCATION: "location";
867
+ /**
868
+ * 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
869
+ * 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.
870
+ *
871
+ * @example
872
+ * 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."
873
+ * Permanent
874
+ */
875
+ readonly P3P: "p3p";
876
+ /**
877
+ * Implementation-specific fields that may have various effects anywhere along the request-response chain.
878
+ *
879
+ * @example
880
+ * pragma: no-cache
881
+ * Permanent
882
+ */
883
+ readonly PRAGMA: "pragma";
884
+ /**
885
+ * Request authentication to access the proxy.
886
+ *
887
+ * @example
888
+ * proxy-authenticate: Basic
889
+ * Permanent
890
+ */
891
+ readonly PROXY_AUTHENTICATION: "proxy-authenticate";
892
+ /**
893
+ * HTTP Public Key Pinning, announces hash of website's authentic TLS certificate
894
+ *
895
+ * @example
896
+ * public-key-pins: max-age=2592000, pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=",
897
+ * Permanent
898
+ */
899
+ readonly PUBLIC_KEY_PINS: "public-key-pins";
900
+ /**
901
+ * 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.
902
+ *
903
+ * @example
904
+ * retry-after: 120
905
+ * retry-after: Fri, 07 Nov 2014 23:59:59 GMT
906
+ * Permanent
907
+ */
908
+ readonly RETRY_AFTER: "retry-after";
909
+ /**
910
+ * A name for the server
911
+ *
912
+ * @example
913
+ * server: Apache/2.4.1 (Unix)
914
+ * Permanent
915
+ */
916
+ readonly SERVER: "server";
917
+ /**
918
+ * An HTTP cookie
919
+ *
920
+ * @example
921
+ * set-cookie: UserID=JohnDoe, Max-Age=3600, Version=1
922
+ * Permanent
923
+ */
924
+ readonly SET_COOKIE: "set-cookie";
925
+ /**
926
+ * CGI header field specifying the status of the HTTP response. Normal HTTP responses use a separate "Status-Line" instead, defined by RFC 7230.
927
+ *
928
+ * @example
929
+ * status: 200 OK
930
+ */
931
+ readonly STATUS: "status";
932
+ /**
933
+ * A HSTS Policy informing the HTTP client how long to cache the HTTPS only policy and whether this applies to subdomains.
934
+ *
935
+ * @example
936
+ * strict-transport-security: max-age=16070400, includeSubDomains
937
+ * Permanent
938
+ */
939
+ readonly STRICT_TRANSPORT_SECURITY: "strict-transport-security";
940
+ /**
941
+ * 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.
942
+ *
943
+ * @example
944
+ * trailer: Max-Forwards
945
+ * Permanent
946
+ */
947
+ readonly TRAILER: "trailer";
948
+ /**
949
+ * The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.
950
+ *
951
+ * @example
952
+ * transfer-encoding: chunked
953
+ * Permanent
954
+ */
955
+ readonly TRANSFER_ENCODING: "transfer-encoding";
956
+ /**
957
+ * Ask the client to upgrade to another protocol.
958
+ *
959
+ * @example
960
+ * upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11
961
+ * Permanent
962
+ */
963
+ readonly UPGRADE: "upgrade";
964
+ /**
965
+ * 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.
966
+ *
967
+ * @example
968
+ * vary: *
969
+ * Permanent
970
+ */
971
+ readonly VARY: "vary";
972
+ /**
973
+ * Informs the client of proxies through which the response was sent.
974
+ *
975
+ * @example
976
+ * via: 1.0 fred, 1.1 example.com (Apache/1.1)
977
+ * Permanent
978
+ */
979
+ readonly VIA: "via";
980
+ /**
981
+ * A general warning about possible problems with the entity body.
982
+ *
983
+ * @example
984
+ * warning: 199 Miscellaneous warning
985
+ * Permanent
986
+ */
987
+ readonly WARNING: "warning";
988
+ /**
989
+ * Indicates the authentication scheme that should be used to access the requested entity.
990
+ *
991
+ * @example
992
+ * www-authenticate: Basic
993
+ * Permanent
994
+ */
995
+ readonly WWW_AUTHENTICATE: "www-authenticate";
996
+ /**
997
+ * Cross-site scripting (XSS) filter
998
+ *
999
+ * @example
1000
+ * x-xss-protection: 1, mode=block
1001
+ */
1002
+ readonly X_XSS_PROTECTION: "x-xss-protection";
1003
+ /**
1004
+ * The HTTP Content-Security-Policy response header allows web site administrators to control resources the user agent is allowed
1005
+ * to load for a given page. With a few exceptions, policies mostly involve specifying server origins and script endpoints.
1006
+ * This helps guard against cross-site scripting attacks (Cross-site_scripting).
1007
+ *
1008
+ * @example
1009
+ * content-security-policy: default-src
1010
+ */
1011
+ readonly CONTENT_SECURITY_POLICY: "content-security-policy";
1012
+ /**
1013
+ * 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.
1014
+ *
1015
+ * @example
1016
+ * x-content-type-options: nosniff
1017
+ */
1018
+ readonly X_CONTENT_TYPE_OPTIONS: "x-content-type-options";
1019
+ /**
1020
+ * 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)
1021
+ *
1022
+ * @example
1023
+ * x-powered-by: PHP/5.4.0
1024
+ */
1025
+ readonly X_POWERED_BY: "x-powered-by";
1026
+ };
1027
+
1028
+ /**
1029
+ * A class that holds a status code and a status text, typically from a {@link Response}
1030
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status|Response.status
1031
+ * @author D1g1talEntr0py <jason.dimeo@gmail.com>
1032
+ */
1033
+ declare class ResponseStatus {
1034
+ private readonly _code;
1035
+ private readonly _text;
1036
+ /**
1037
+ *
1038
+ * @param code The status code from the {@link Response}
1039
+ * @param text The status text from the {@link Response}
1040
+ */
1041
+ constructor(code: number, text: string);
1042
+ /**
1043
+ * Returns the status code from the {@link Response}
1044
+ *
1045
+ * @returns The status code.
1046
+ */
1047
+ get code(): number;
1048
+ /**
1049
+ * Returns the status text from the {@link Response}.
1050
+ *
1051
+ * @returns The status text.
1052
+ */
1053
+ get text(): string;
1054
+ /**
1055
+ * A String value that is used in the creation of the default string
1056
+ * description of an object. Called by the built-in method {@link Object.prototype.toString}.
1057
+ *
1058
+ * @returns The default string description of this object.
1059
+ */
1060
+ get [Symbol.toStringTag](): string;
1061
+ /**
1062
+ * tostring method for the class.
1063
+ *
1064
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString|Object.prototype.toString}
1065
+ * @returns The status code and status text.
1066
+ */
1067
+ toString(): string;
1068
+ }
1069
+
1070
+ type Function<P = any, R = unknown> = (...args: P[]) => R;
1071
+ type JsonPrimitive = string | number | boolean | null;
1072
+ type JsonArray<T = any> = T extends any ? Array<JsonValue<T>> : never;
1073
+ type JsonObject<T = any> = T extends any ? {
1074
+ [K in keyof T as JsonValue<T[K]> extends never ? never : K]: JsonValue<T[K]>;
1075
+ } : Record<string, any>;
1076
+ type JsonValue<T = any> = T extends JsonPrimitive ? T : T extends {
1077
+ toJSON: () => infer R;
1078
+ } ? R : T extends Function | undefined ? never : T extends Array<infer U> ? JsonArray<U> : T extends Record<string, any> ? JsonObject<T> : Json;
1079
+ type Json = JsonPrimitive | JsonObject | JsonArray;
1080
+ type JsonString<T = unknown> = string & {
1081
+ source: T;
1082
+ };
1083
+ /** The expected response body types returned from a fetch handler. */
1084
+ type ResponseBody = Json | Document | DocumentFragment | HTMLImageElement | Blob | ArrayBuffer | FormData | string | ReadableStream<Uint8Array> | void | null;
1085
+ /** Timing information for a request lifecycle. */
1086
+ type RequestTiming = {
1087
+ /** Timestamp when the request started (ms since epoch). */
1088
+ start: number;
1089
+ /** Timestamp when the response was received (ms since epoch). */
1090
+ end: number;
1091
+ /** Total duration in milliseconds. */
1092
+ duration: number;
1093
+ };
1094
+ /** Options for constructing an {@link HttpError}. */
1095
+ type HttpErrorOptions = {
1096
+ message?: string;
1097
+ cause?: Error;
1098
+ entity?: ResponseBody;
1099
+ /** The request URL. */
1100
+ url?: URL;
1101
+ /** The HTTP method used. */
1102
+ method?: string;
1103
+ /** Request timing information. */
1104
+ timing?: RequestTiming;
1105
+ };
1106
+
1107
+ /**
1108
+ * An error that represents an HTTP error response.
1109
+ * @author D1g1talEntr0py <jason.dimeo@gmail.com>
1110
+ */
1111
+ declare class HttpError extends Error {
1112
+ private readonly _entity;
1113
+ private readonly responseStatus;
1114
+ private readonly _url;
1115
+ private readonly _method;
1116
+ private readonly _timing;
1117
+ /**
1118
+ * Creates an instance of HttpError.
1119
+ * @param status The status code and status text of the {@link Response}.
1120
+ * @param httpErrorOptions The http error options.
1121
+ */
1122
+ constructor(status: ResponseStatus, { message, cause, entity, url, method, timing }?: HttpErrorOptions);
1123
+ /**
1124
+ * It returns the value of the private variable #entity.
1125
+ * @returns The entity property of the class.
1126
+ */
1127
+ get entity(): ResponseBody;
1128
+ /**
1129
+ * It returns the status code of the {@link Response}.
1130
+ * @returns The status code of the {@link Response}.
1131
+ */
1132
+ get statusCode(): number;
1133
+ /**
1134
+ * It returns the status text of the {@link Response}.
1135
+ * @returns The status code and status text of the {@link Response}.
1136
+ */
1137
+ get statusText(): string;
1138
+ /**
1139
+ * The request URL that caused the error.
1140
+ * @returns The URL or undefined.
1141
+ */
1142
+ get url(): URL | undefined;
1143
+ /**
1144
+ * The HTTP method that was used for the failed request.
1145
+ * @returns The method string or undefined.
1146
+ */
1147
+ get method(): string | undefined;
1148
+ /**
1149
+ * Timing information for the failed request.
1150
+ * @returns The timing object or undefined.
1151
+ */
1152
+ get timing(): RequestTiming | undefined;
1153
+ /**
1154
+ * A String value representing the name of the error.
1155
+ * @returns The name of the error.
1156
+ */
1157
+ get name(): string;
1158
+ /**
1159
+ * A String value that is used in the creation of the default string
1160
+ * description of an object. Called by the built-in method {@link Object.prototype.toString}.
1161
+ * @returns The default string description of this object.
1162
+ */
1163
+ get [Symbol.toStringTag](): string;
1164
+ }
1165
+
1166
+ type Prettify<T> = T extends infer U ? {
1167
+ [K in keyof U]: U[K];
1168
+ } : never;
1169
+ type LiteralUnion<T> = T | (string & {});
1170
+ interface TypedResponse<T> extends Response {
1171
+ json: () => Promise<T>;
1172
+ }
1173
+ type RequestBody = BodyInit | JsonObject;
1174
+ type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
1175
+ type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE';
1176
+ type RequestBodyMethod = Extract<RequestMethod, 'POST' | 'PUT' | 'PATCH' | 'DELETE'>;
1177
+ type RequestNoBodyMethod = Exclude<RequestMethod, RequestBodyMethod>;
1178
+ type RequestHeaders = Prettify<TypedHeaders & {
1179
+ [K in Exclude<typeof HttpRequestHeader[keyof typeof HttpRequestHeader], keyof TypedHeaders>]?: string;
1180
+ } & HeadersInit>;
1181
+ type SearchParameters = URLSearchParams | string | string[][] | Record<string, string | number | boolean>;
1182
+ type AuthorizationScheme = 'Basic' | 'Bearer' | 'Digest' | 'HOBA' | 'Mutual' | 'Negotiate' | 'OAuth' | 'SCRAM-SHA-1' | 'SCRAM-SHA-256' | 'vapid';
1183
+ type ResponseHandler<T extends ResponseBody = ResponseBody> = (response: Response) => Promise<T>;
1184
+ type RequestLifecycleEvent = 'configured' | 'success' | 'error' | 'aborted' | 'timeout' | 'retry' | 'complete' | 'all-complete';
1185
+ type RequestEventHandler = (event: Event, data: unknown) => void;
1186
+ type Entry<K, V> = [K, V];
1187
+ type Entries<K, V> = Entry<K, V>[];
1188
+ type ReadOnlyEntries<K, V> = readonly Entry<K, V>[];
1189
+ type AbortSignalEvent = Event & {
1190
+ target: AbortSignal;
1191
+ };
1192
+ type AbortEvent = CustomEvent<{
1193
+ cause: 'AbortError';
1194
+ }>;
1195
+ type TimeoutEvent = CustomEvent<{
1196
+ cause: 'TimeoutError';
1197
+ }>;
1198
+ type AbortConfiguration = {
1199
+ signal?: AbortSignal | null;
1200
+ timeout?: number;
1201
+ };
1202
+ type MediaTypeValues = LiteralUnion<typeof HttpMediaType[keyof typeof HttpMediaType]>;
1203
+ type TypedHeaders = {
1204
+ [HttpRequestHeader.AUTHORIZATION]?: `${AuthorizationScheme} ${string}` | AuthorizationScheme;
1205
+ [HttpRequestHeader.ACCEPT]?: MediaTypeValues;
1206
+ [HttpRequestHeader.CONTENT_TYPE]?: MediaTypeValues;
1207
+ };
1208
+ type EventRegistration = Subscription;
1209
+ type MethodBody = {
1210
+ method?: RequestBodyMethod;
1211
+ body?: RequestBody;
1212
+ } | {
1213
+ method?: RequestNoBodyMethod;
1214
+ body?: never;
1215
+ };
1216
+ type RequestOptions = Prettify<{
1217
+ /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
1218
+ headers?: RequestHeaders;
1219
+ searchParams?: SearchParameters;
1220
+ timeout?: number;
1221
+ global?: boolean;
1222
+ /** Lifecycle hooks for this request. Instance and global hooks run first, then per-request hooks. */
1223
+ hooks?: HookOptions;
1224
+ /** Retry configuration. A number sets the retry limit; an object provides fine-grained control. */
1225
+ retry?: number | RetryOptions;
1226
+ /** When true, identical in-flight GET/HEAD requests share a single fetch. Defaults to false. */
1227
+ dedupe?: boolean;
1228
+ /** XSRF/CSRF protection. When set (or true), reads a cookie and sets a request header. */
1229
+ xsrf?: boolean | XsrfOptions;
1230
+ } & Omit<RequestInit, 'headers'> & MethodBody>;
1231
+ /** Configuration for retry behavior on failed requests. */
1232
+ type RetryOptions = {
1233
+ /** Maximum number of retry attempts. Defaults to 0 (no retries). */
1234
+ limit?: number;
1235
+ /** HTTP status codes that trigger a retry. Defaults to [408, 413, 429, 500, 502, 503, 504]. */
1236
+ statusCodes?: number[];
1237
+ /** HTTP methods allowed to retry. Defaults to ['GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS']. */
1238
+ methods?: RequestMethod[];
1239
+ /** Delay in ms before the first retry, or a function receiving the attempt number (1-based) returning ms. Defaults to 300. */
1240
+ delay?: number | ((attempt: number) => number);
1241
+ /** Multiplier applied to delay after each attempt. Defaults to 2. */
1242
+ backoffFactor?: number;
1243
+ };
1244
+ /** Configuration for XSRF/CSRF token handling. */
1245
+ type XsrfOptions = {
1246
+ /** The name of the cookie to read the token from. Defaults to 'XSRF-TOKEN'. */
1247
+ cookieName?: string;
1248
+ /** The request header name to set the token on. Defaults to 'X-XSRF-TOKEN'. */
1249
+ headerName?: string;
1250
+ };
1251
+ /** Hook called before each request. Can modify the request options. */
1252
+ type BeforeRequestHook = (options: RequestOptions, url: URL) => RequestOptions | void | Promise<RequestOptions | void>;
1253
+ /** Hook called after each successful response. Can modify or replace the response. */
1254
+ type AfterResponseHook = (response: Response, options: RequestOptions) => Response | void | Promise<Response | void>;
1255
+ /** Hook called before an error is thrown. Can transform the error. */
1256
+ type BeforeErrorHook = (error: HttpError) => HttpError | void | Promise<HttpError | void>;
1257
+ /** Configuration for request lifecycle hooks. */
1258
+ type HookOptions = {
1259
+ beforeRequest?: BeforeRequestHook[];
1260
+ afterResponse?: AfterResponseHook[];
1261
+ beforeError?: BeforeErrorHook[];
1262
+ };
1263
+ /** Fully resolved retry configuration with all defaults applied. */
1264
+ type NormalizedRetryOptions = Required<RetryOptions>;
1265
+ /** Options for the internal publish helper. */
1266
+ type PublishOptions = {
1267
+ name: string;
1268
+ event?: Event;
1269
+ data?: unknown;
1270
+ global?: boolean;
1271
+ };
1272
+
1273
+ declare const endsWithSlashRegEx: RegExp;
1274
+ /** Default XSRF cookie name */
1275
+ declare const XSRF_COOKIE_NAME = "XSRF-TOKEN";
1276
+ /** Default XSRF header name */
1277
+ declare const XSRF_HEADER_NAME = "X-XSRF-TOKEN";
1278
+ type MediaTypeKey = 'PNG' | 'TEXT' | 'JSON' | 'HTML' | 'JAVA_SCRIPT' | 'CSS' | 'XML' | 'BIN';
1279
+ declare const mediaTypes: {
1280
+ [key in MediaTypeKey]: MediaType;
1281
+ };
1282
+ declare const defaultMediaType: string;
1283
+ /** Constant object for caching policies */
1284
+ declare const RequestCachingPolicy: {
1285
+ readonly DEFAULT: "default";
1286
+ readonly FORCE_CACHE: "force-cache";
1287
+ readonly NO_CACHE: "no-cache";
1288
+ readonly NO_STORE: "no-store";
1289
+ readonly ONLY_IF_CACHED: "only-if-cached";
1290
+ readonly RELOAD: "reload";
1291
+ };
1292
+ /** Constant object for signal events */
1293
+ declare const SignalEvents: {
1294
+ readonly ABORT: "abort";
1295
+ readonly TIMEOUT: "timeout";
1296
+ };
1297
+ /** Constant object for signal errors */
1298
+ declare const SignalErrors: {
1299
+ readonly ABORT: "AbortError";
1300
+ readonly TIMEOUT: "TimeoutError";
1301
+ };
1302
+ /** Options for adding event listeners */
1303
+ declare const eventListenerOptions: AddEventListenerOptions;
1304
+ /**
1305
+ * Creates a new custom abort event.
1306
+ * @returns A new AbortEvent instance.
1307
+ */
1308
+ declare const abortEvent: () => AbortEvent;
1309
+ /**
1310
+ * Creates a new custom timeout event.
1311
+ * @returns A new TimeoutEvent instance.
1312
+ */
1313
+ declare const timeoutEvent: () => TimeoutEvent;
1314
+ /** Array of request body methods */
1315
+ declare const requestBodyMethods: ReadonlyArray<RequestMethod>;
1316
+ /** Response status for internal server error */
1317
+ declare const internalServerError: ResponseStatus;
1318
+ /** Response status for aborted request */
1319
+ declare const aborted: ResponseStatus;
1320
+ /** Response status for timed out request */
1321
+ declare const timedOut: ResponseStatus;
1322
+ /** Default HTTP status codes that trigger a retry */
1323
+ declare const retryStatusCodes: ReadonlyArray<number>;
1324
+ /** Default HTTP methods allowed to retry (idempotent methods only) */
1325
+ declare const retryMethods: ReadonlyArray<RequestMethod>;
1326
+ /** Default delay in ms before the first retry */
1327
+ declare const retryDelay: number;
1328
+ /** Default backoff factor applied after each retry attempt */
1329
+ declare const retryBackoffFactor: number;
1330
+ /** Constant object for request events */
1331
+ declare const RequestEvent: {
1332
+ readonly CONFIGURED: "configured";
1333
+ readonly SUCCESS: "success";
1334
+ readonly ERROR: "error";
1335
+ readonly ABORTED: "aborted";
1336
+ readonly TIMEOUT: "timeout";
1337
+ readonly RETRY: "retry";
1338
+ readonly COMPLETE: "complete";
1339
+ readonly ALL_COMPLETE: "all-complete";
1340
+ };
1341
+ type RequestEvent = (typeof RequestEvent)[keyof typeof RequestEvent];
1342
+
1343
+ /**
1344
+ * A wrapper around the fetch API that makes it easier to make HTTP requests.
1345
+ * @author D1g1talEntr0py <jason.dimeo@gmail.com>
1346
+ */
1347
+ declare class Transportr {
1348
+ private readonly _baseUrl;
1349
+ private readonly _options;
1350
+ private readonly subscribr;
1351
+ private readonly hooks;
1352
+ private static globalSubscribr;
1353
+ private static globalHooks;
1354
+ private static signalControllers;
1355
+ /** Map of in-flight deduplicated requests keyed by URL + method */
1356
+ private static inflightRequests;
1357
+ /** Cache for parsed MediaType instances to avoid re-parsing the same content-type strings */
1358
+ private static mediaTypeCache;
1359
+ private static contentTypeHandlers;
1360
+ /**
1361
+ * Create a new Transportr instance with the provided location or origin and context path.
1362
+ *
1363
+ * @param url The URL for {@link fetch} requests.
1364
+ * @param options The default {@link RequestOptions} for this instance.
1365
+ */
1366
+ constructor(url?: URL | string | RequestOptions, options?: RequestOptions);
1367
+ /** HTTP Media Types */
1368
+ static readonly MediaType: typeof HttpMediaType;
1369
+ /** HTTP Request Methods */
1370
+ static readonly RequestMethod: typeof HttpRequestMethod;
1371
+ /** HTTP Request Headers */
1372
+ static readonly RequestHeader: typeof HttpRequestHeader;
1373
+ /** HTTP Response Headers */
1374
+ static readonly ResponseHeader: typeof HttpResponseHeader;
1375
+ /** Request Caching Policy */
1376
+ static readonly CachingPolicy: typeof RequestCachingPolicy;
1377
+ /** Credentials Policy */
1378
+ static readonly CredentialsPolicy: {
1379
+ readonly INCLUDE: "include";
1380
+ readonly OMIT: "omit";
1381
+ readonly SAME_ORIGIN: "same-origin";
1382
+ };
1383
+ /** Request Modes */
1384
+ static readonly RequestModes: {
1385
+ readonly CORS: "cors";
1386
+ readonly NAVIGATE: "navigate";
1387
+ readonly NO_CORS: "no-cors";
1388
+ readonly SAME_ORIGIN: "same-origin";
1389
+ };
1390
+ /** Request Priorities */
1391
+ static readonly RequestPriorities: {
1392
+ readonly HIGH: "high";
1393
+ readonly LOW: "low";
1394
+ readonly AUTO: "auto";
1395
+ };
1396
+ /** Redirect Policies */
1397
+ static readonly RedirectPolicies: {
1398
+ readonly ERROR: "error";
1399
+ readonly FOLLOW: "follow";
1400
+ readonly MANUAL: "manual";
1401
+ };
1402
+ /** Referrer Policies */
1403
+ static readonly ReferrerPolicy: {
1404
+ readonly NO_REFERRER: "no-referrer";
1405
+ readonly NO_REFERRER_WHEN_DOWNGRADE: "no-referrer-when-downgrade";
1406
+ readonly ORIGIN: "origin";
1407
+ readonly ORIGIN_WHEN_CROSS_ORIGIN: "origin-when-cross-origin";
1408
+ readonly SAME_ORIGIN: "same-origin";
1409
+ readonly STRICT_ORIGIN: "strict-origin";
1410
+ readonly STRICT_ORIGIN_WHEN_CROSS_ORIGIN: "strict-origin-when-cross-origin";
1411
+ readonly UNSAFE_URL: "unsafe-url";
1412
+ };
1413
+ /** Request Events */
1414
+ static readonly RequestEvents: typeof RequestEvent;
1415
+ /** Default Request Options */
1416
+ private static readonly defaultRequestOptions;
1417
+ /**
1418
+ * Returns a {@link EventRegistration} used for subscribing to global events.
1419
+ *
1420
+ * @param event The event to subscribe to.
1421
+ * @param handler The event handler.
1422
+ * @param context The context to bind the handler to.
1423
+ * @returns A new {@link EventRegistration} instance.
1424
+ */
1425
+ static register(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration;
1426
+ /**
1427
+ * Removes a {@link EventRegistration} from the global event handler.
1428
+ *
1429
+ * @param eventRegistration The {@link EventRegistration} to remove.
1430
+ * @returns True if the {@link EventRegistration} was removed, false otherwise.
1431
+ */
1432
+ static unregister(eventRegistration: EventRegistration): boolean;
1433
+ /**
1434
+ * Aborts all active requests.
1435
+ * This is useful for when the user navigates away from the current page.
1436
+ * This will also clear the {@link Transportr#signalControllers} set.
1437
+ */
1438
+ static abortAll(): void;
1439
+ /**
1440
+ * Registers a custom content-type response handler.
1441
+ * The handler will be matched against response content-type headers using MediaType matching.
1442
+ * New handlers are prepended so they take priority over built-in handlers.
1443
+ *
1444
+ * @param contentType The content-type string to match (e.g. 'application/pdf', 'text', 'csv').
1445
+ * @param handler The response handler function.
1446
+ */
1447
+ static registerContentTypeHandler(contentType: string, handler: ResponseHandler): void;
1448
+ /**
1449
+ * Removes a previously registered content-type response handler.
1450
+ *
1451
+ * @param contentType The content-type string to remove.
1452
+ * @returns True if the handler was found and removed, false otherwise.
1453
+ */
1454
+ static unregisterContentTypeHandler(contentType: string): boolean;
1455
+ /**
1456
+ * Registers global lifecycle hooks that run on all requests from all instances.
1457
+ * Global hooks execute before instance and per-request hooks.
1458
+ *
1459
+ * @param hooks The hooks to register globally.
1460
+ */
1461
+ static addHooks(hooks: HookOptions): void;
1462
+ /**
1463
+ * Removes all global lifecycle hooks.
1464
+ */
1465
+ static clearHooks(): void;
1466
+ /**
1467
+ * Tears down all global state: aborts in-flight requests, clears global event subscriptions,
1468
+ * hooks, in-flight deduplication map, and media type cache (retaining built-in entries).
1469
+ */
1470
+ static unregisterAll(): void;
1471
+ /**
1472
+ * It returns the base {@link URL} for the API.
1473
+ *
1474
+ * @returns The baseUrl property.
1475
+ */
1476
+ get baseUrl(): URL;
1477
+ /**
1478
+ * Registers an event handler with a {@link Transportr} instance.
1479
+ *
1480
+ * @param event The name of the event to listen for.
1481
+ * @param handler The function to call when the event is triggered.
1482
+ * @param context The context to bind to the handler.
1483
+ * @returns An object that can be used to remove the event handler.
1484
+ */
1485
+ register(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration;
1486
+ /**
1487
+ * Unregisters an event handler from a {@link Transportr} instance.
1488
+ *
1489
+ * @param eventRegistration The event registration to remove.
1490
+ * @returns True if the {@link EventRegistration} was removed, false otherwise.
1491
+ */
1492
+ unregister(eventRegistration: EventRegistration): boolean;
1493
+ /**
1494
+ * Registers instance-level lifecycle hooks that run on all requests from this instance.
1495
+ * Instance hooks execute after global hooks but before per-request hooks.
1496
+ *
1497
+ * @param hooks The hooks to register on this instance.
1498
+ * @returns This instance for method chaining.
1499
+ */
1500
+ addHooks(hooks: HookOptions): this;
1501
+ /**
1502
+ * Removes all instance-level lifecycle hooks.
1503
+ * @returns This instance for method chaining.
1504
+ */
1505
+ clearHooks(): this;
1506
+ /**
1507
+ * Tears down this instance: clears all instance subscriptions and hooks.
1508
+ * The instance should not be used after calling this method.
1509
+ */
1510
+ destroy(): void;
1511
+ /**
1512
+ * This function returns a promise that resolves to the result of a request to the specified path with
1513
+ * the specified options, where the method is GET.
1514
+ *
1515
+ * @async
1516
+ * @param path The path to the resource you want to get.
1517
+ * @param options The options for the request.
1518
+ * @returns A promise that resolves to the response of the request.
1519
+ */
1520
+ get<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1521
+ /**
1522
+ * This function makes a POST request to the given path with the given body and options.
1523
+ *
1524
+ * @async
1525
+ * @template T The expected response type (defaults to ResponseBody)
1526
+ * @param path The path to the endpoint you want to call.
1527
+ * @param options The options for the request.
1528
+ * @returns A promise that resolves to the response body.
1529
+ */
1530
+ post<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1531
+ /**
1532
+ * This function returns a promise that resolves to the result of a request to the specified path with
1533
+ * the specified options, where the method is PUT.
1534
+ *
1535
+ * @async
1536
+ * @template T The expected response type (defaults to ResponseBody)
1537
+ * @param path The path to the endpoint you want to call.
1538
+ * @param options The options for the request.
1539
+ * @returns The return value of the #request method.
1540
+ */
1541
+ put<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1542
+ /**
1543
+ * It takes a path and options, and returns a request with the method set to PATCH.
1544
+ *
1545
+ * @async
1546
+ * @template T The expected response type (defaults to ResponseBody)
1547
+ * @param path The path to the endpoint you want to hit.
1548
+ * @param options The options for the request.
1549
+ * @returns A promise that resolves to the response of the request.
1550
+ */
1551
+ patch<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1552
+ /**
1553
+ * It takes a path and options, and returns a request with the method set to DELETE.
1554
+ *
1555
+ * @async
1556
+ * @param path The path to the resource you want to access.
1557
+ * @param options The options for the request.
1558
+ * @returns The result of the request.
1559
+ */
1560
+ delete<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1561
+ /**
1562
+ * Returns the response headers of a request to the given path.
1563
+ *
1564
+ * @async
1565
+ * @param path The path to the resource you want to access.
1566
+ * @param options The options for the request.
1567
+ * @returns A promise that resolves to the response object.
1568
+ */
1569
+ head<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1570
+ /**
1571
+ * It returns a promise that resolves to the allowed request methods for the given resource path.
1572
+ *
1573
+ * @async
1574
+ * @param path The path to the resource.
1575
+ * @param options The options for the request.
1576
+ * @returns A promise that resolves to an array of allowed request methods for this resource.
1577
+ */
1578
+ options(path?: string | RequestOptions, options?: RequestOptions): Promise<string[] | undefined>;
1579
+ /**
1580
+ * It takes a path and options, and makes a request to the server
1581
+ * @async
1582
+ * @param path The path to the endpoint you want to hit.
1583
+ * @param options The options for the request.
1584
+ * @returns The return value of the function is the return value of the function that is passed to the `then` method of the promise returned by the `fetch` method.
1585
+ * @throws {HttpError} If an error occurs during the request.
1586
+ */
1587
+ request<T = unknown>(path?: string | RequestOptions, options?: RequestOptions): Promise<TypedResponse<T>>;
1588
+ /**
1589
+ * It gets the JSON representation of the resource at the given path.
1590
+ *
1591
+ * @async
1592
+ * @template T The expected JSON response type (defaults to JsonObject)
1593
+ * @param path The path to the resource.
1594
+ * @param options The options object to pass to the request.
1595
+ * @returns A promise that resolves to the response body as a typed JSON value.
1596
+ */
1597
+ getJson(path?: string | RequestOptions, options?: RequestOptions): Promise<Json | undefined>;
1598
+ /**
1599
+ * It gets the XML representation of the resource at the given path.
1600
+ *
1601
+ * @async
1602
+ * @param path The path to the resource you want to get.
1603
+ * @param options The options for the request.
1604
+ * @returns The result of the function call to #get.
1605
+ */
1606
+ getXml(path?: string | RequestOptions, options?: RequestOptions): Promise<Document | undefined>;
1607
+ /**
1608
+ * Get the HTML content of the specified path.
1609
+ * When a selector is provided, returns only the first matching element from the parsed document.
1610
+ *
1611
+ * @async
1612
+ * @param path The path to the resource.
1613
+ * @param options The options for the request.
1614
+ * @param selector An optional CSS selector to extract a specific element from the parsed HTML.
1615
+ * @returns A promise that resolves to a Document, an Element (if selector matched), or void.
1616
+ */
1617
+ getHtml(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<Document | Element | null | undefined>;
1618
+ /**
1619
+ * It returns a promise that resolves to the HTML fragment at the given path.
1620
+ * When a selector is provided, returns only the first matching element from the parsed fragment.
1621
+ *
1622
+ * @async
1623
+ * @param path The path to the resource.
1624
+ * @param options The options for the request.
1625
+ * @param selector An optional CSS selector to extract a specific element from the parsed fragment.
1626
+ * @returns A promise that resolves to a DocumentFragment, an Element (if selector matched), or void.
1627
+ */
1628
+ getHtmlFragment(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<DocumentFragment | Element | null | undefined>;
1629
+ /**
1630
+ * It gets a script from the server, and appends the script to the Document HTMLHeadElement
1631
+ * @param path The path to the script.
1632
+ * @param options The options for the request.
1633
+ * @returns A promise that resolves to void.
1634
+ */
1635
+ getScript(path?: string | RequestOptions, options?: RequestOptions): Promise<void>;
1636
+ /**
1637
+ * Gets a stylesheet from the server, and adds it as a Blob URL.
1638
+ * @param path The path to the stylesheet.
1639
+ * @param options The options for the request.
1640
+ * @returns A promise that resolves to void.
1641
+ */
1642
+ getStylesheet(path?: string | RequestOptions, options?: RequestOptions): Promise<void>;
1643
+ /**
1644
+ * It returns a blob from the specified path.
1645
+ * @param path The path to the resource.
1646
+ * @param options The options for the request.
1647
+ * @returns A promise that resolves to a Blob or void.
1648
+ */
1649
+ getBlob(path?: string | RequestOptions, options?: RequestOptions): Promise<Blob | undefined>;
1650
+ /**
1651
+ * It returns a promise that resolves to an `HTMLImageElement`.
1652
+ * The object URL created to load the image is automatically revoked to prevent memory leaks.
1653
+ * Works in both browser and Node.js (via JSDOM) environments.
1654
+ * @param path The path to the image.
1655
+ * @param options The options for the request.
1656
+ * @returns A promise that resolves to an `HTMLImageElement` or `void`.
1657
+ */
1658
+ getImage(path?: string, options?: RequestOptions): Promise<HTMLImageElement | undefined>;
1659
+ /**
1660
+ * It gets a buffer from the specified path
1661
+ * @param path The path to the resource.
1662
+ * @param options The options for the request.
1663
+ * @returns A promise that resolves to an ArrayBuffer or void.
1664
+ */
1665
+ getBuffer(path?: string | RequestOptions, options?: RequestOptions): Promise<ArrayBuffer | undefined>;
1666
+ /**
1667
+ * It returns a readable stream of the response body from the specified path.
1668
+ * @param path The path to the resource.
1669
+ * @param options The options for the request.
1670
+ * @returns A promise that resolves to a ReadableStream, null, or void.
1671
+ */
1672
+ getStream(path?: string | RequestOptions, options?: RequestOptions): Promise<ReadableStream<Uint8Array> | null | undefined>;
1673
+ /**
1674
+ * Handles a GET request.
1675
+ * @async
1676
+ * @param path The path to the resource.
1677
+ * @param userOptions The user options for the request.
1678
+ * @param options The options for the request.
1679
+ * @param responseHandler The response handler for the request.
1680
+ * @returns A promise that resolves to the response body or void.
1681
+ */
1682
+ private _get;
1683
+ /**
1684
+ * It processes the request options and returns a new object with the processed options.
1685
+ * @param path The path to the resource.
1686
+ * @param processedRequestOptions The user options for the request.
1687
+ * @returns A new object with the processed options.
1688
+ */
1689
+ private _request;
1690
+ /**
1691
+ * Normalizes a retry option into a full RetryOptions object.
1692
+ * @param retry The retry option from request options.
1693
+ * @returns Normalized retry configuration.
1694
+ */
1695
+ private static normalizeRetryOptions;
1696
+ /**
1697
+ * Waits for the appropriate delay before a retry attempt.
1698
+ * @param config The retry configuration.
1699
+ * @param attempt The current attempt number (1-based).
1700
+ * @returns A promise that resolves after the delay.
1701
+ */
1702
+ private static retryDelay;
1703
+ /**
1704
+ * It returns a response handler based on the content type of the response.
1705
+ * @param path The path to the resource.
1706
+ * @param userOptions The user options for the request.
1707
+ * @param options The options for the request.
1708
+ * @param responseHandler The response handler for the request.
1709
+ * @returns A response handler function.
1710
+ */
1711
+ private execute;
1712
+ /**
1713
+ * Creates a new set of options for a request.
1714
+ * @param options The user options for the request.
1715
+ * @param userOptions The default options for the request.
1716
+ * @returns A new set of options for the request.
1717
+ */
1718
+ private static createOptions;
1719
+ /**
1720
+ * Merges user and request headers into the target Headers object.
1721
+ * @param target The target Headers object.
1722
+ * @param headerSources Variable number of header sources to merge.
1723
+ * @returns The merged Headers object.
1724
+ */
1725
+ private static mergeHeaders;
1726
+ /**
1727
+ * Merges user and request search parameters into the target URLSearchParams object.
1728
+ * @param target The target URLSearchParams object.
1729
+ * @param sources The search parameters to merge.
1730
+ * @returns The merged URLSearchParams object.
1731
+ */
1732
+ private static mergeSearchParams;
1733
+ /**
1734
+ * Processes request options by merging user, instance, and method-specific options.
1735
+ * This method optimizes performance by using cached instance options and performing
1736
+ * shallow merges where possible instead of deep object cloning.
1737
+ * @param userOptions The user-provided options for the request.
1738
+ * @param options Additional method-specific options.
1739
+ * @returns Processed request options with signal controller and global flag.
1740
+ */
1741
+ private processRequestOptions;
1742
+ /**
1743
+ * Gets the base URL from a URL or string.
1744
+ * @param url The URL or string to parse.
1745
+ * @returns The base URL.
1746
+ */
1747
+ private static getBaseUrl;
1748
+ /**
1749
+ * Parses a content-type string into a MediaType instance with caching.
1750
+ * This method caches parsed MediaType instances to avoid re-parsing the same content-type strings,
1751
+ * which significantly improves performance for repeated requests with the same content types.
1752
+ * @param contentType The content-type string to parse.
1753
+ * @returns The parsed MediaType instance, or undefined if parsing fails.
1754
+ */
1755
+ private static getOrParseMediaType;
1756
+ /**
1757
+ * Creates a new URL with the given path and search parameters.
1758
+ * @param url The base URL.
1759
+ * @param path The path to append to the base URL.
1760
+ * @param searchParams The search parameters to append to the URL.
1761
+ * @returns A new URL with the given path and search parameters.
1762
+ */
1763
+ private static createUrl;
1764
+ /**
1765
+ * It generates a ResponseStatus object from an error name and a Response object.
1766
+ * @param errorName The name of the error.
1767
+ * @param response The Response object.
1768
+ * @returns A ResponseStatus object.
1769
+ */
1770
+ private static generateResponseStatusFromError;
1771
+ /**
1772
+ * Handles an error that occurs during a request.
1773
+ * @param path The path of the request.
1774
+ * @param response The Response object.
1775
+ * @param options Additional error context including cause, entity, url, method, and timing.
1776
+ * @param requestOptions The original request options that led to the error, used for hooks context.
1777
+ * @returns An HttpError object.
1778
+ */
1779
+ private handleError;
1780
+ /**
1781
+ * Publishes an event to the global and instance event handlers.
1782
+ * @param eventObject The event object to publish.
1783
+ */
1784
+ private publish;
1785
+ /**
1786
+ * It returns a response handler based on the content type of the response.
1787
+ * @param contentType The content type of the response.
1788
+ * @returns A response handler function.
1789
+ */
1790
+ private getResponseHandler;
1791
+ /**
1792
+ * A string representation of the Transportr instance.
1793
+ * @returns The string 'Transportr'.
1794
+ */
1795
+ get [Symbol.toStringTag](): string;
1796
+ }
1797
+
1798
+ export { HttpError, HttpErrorOptions, HttpMediaType, HttpRequestHeader, HttpRequestMethod, HttpResponseHeader, Json, JsonArray, JsonObject, JsonPrimitive, JsonString, JsonValue, RequestCachingPolicy, RequestEvent, RequestTiming, ResponseBody, ResponseStatus, SignalErrors, SignalEvents, Transportr, XSRF_COOKIE_NAME, XSRF_HEADER_NAME, abortEvent, aborted, defaultMediaType, endsWithSlashRegEx, eventListenerOptions, internalServerError, mediaTypes, requestBodyMethods, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, timedOut, timeoutEvent };
1799
+ export type { AbortConfiguration, AbortEvent, AbortSignalEvent, AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Entries, EventRegistration, HookOptions, NormalizedRetryOptions, PublishOptions, ReadOnlyEntries, RequestBody, RequestBodyMethod, RequestEventHandler, RequestHeaders, RequestLifecycleEvent, RequestMethod, RequestOptions, ResponseHandler, RetryOptions, SearchParameters, TimeoutEvent, TypedArray, TypedResponse, XsrfOptions };