@unshared/client 0.6.5 → 0.6.6
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/HttpHeaders.cjs +1 -1
- package/dist/HttpHeaders.cjs.map +1 -1
- package/dist/HttpHeaders.d.ts +10145 -1117
- package/dist/HttpHeaders.js +1 -1
- package/dist/HttpHeaders.js.map +1 -1
- package/dist/HttpMethods.cjs.map +1 -1
- package/dist/HttpMethods.d.ts +506 -20
- package/dist/HttpMethods.js.map +1 -1
- package/dist/HttpStatusCodes.cjs.map +1 -1
- package/dist/HttpStatusCodes.d.ts +2539 -83
- package/dist/HttpStatusCodes.js.map +1 -1
- package/dist/chunks/B6pUErTM.js.map +1 -1
- package/dist/chunks/BDxlAULu.cjs.map +1 -1
- package/dist/chunks/B_Gz6Yz8.js.map +1 -1
- package/dist/chunks/C83nLcQu.js.map +1 -1
- package/dist/chunks/{uqfvs89o.js → C_VzAX2X.js} +22 -35
- package/dist/chunks/{uqfvs89o.js.map → C_VzAX2X.js.map} +1 -1
- package/dist/chunks/{CThSMMCZ.cjs → CbXCpEzw.cjs} +22 -35
- package/dist/chunks/{CThSMMCZ.cjs.map → CbXCpEzw.cjs.map} +1 -1
- package/dist/chunks/{CQUndCW0.cjs → DCBEtS8k.cjs} +2 -2
- package/dist/chunks/DCBEtS8k.cjs.map +1 -0
- package/dist/chunks/DEyigyGy.cjs.map +1 -1
- package/dist/chunks/DJyo3R5b.cjs.map +1 -1
- package/dist/chunks/{xJaQKKe2.js → Dh-ZK9yy.js} +2 -2
- package/dist/chunks/Dh-ZK9yy.js.map +1 -0
- package/dist/chunks/{DAtM4FUl.d.ts → Dil0c6fd.d.ts} +1 -1
- package/dist/chunks/{BGG3bT7O.d.ts → rRfHSRNV.d.ts} +4 -2
- package/dist/createClient.cjs +2 -2
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.ts +3 -2
- package/dist/createClient.js +2 -2
- package/dist/createClient.js.map +1 -1
- package/dist/createService.cjs +1 -1
- package/dist/createService.cjs.map +1 -1
- package/dist/createService.d.ts +3 -2
- package/dist/createService.js +1 -1
- package/dist/createService.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/dist/openapi.cjs.map +1 -1
- package/dist/openapi.d.ts +20 -2
- package/dist/openapi.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +5 -5
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunks/CQUndCW0.cjs.map +0 -1
- package/dist/chunks/xJaQKKe2.js.map +0 -1
package/dist/HttpMethods.d.ts
CHANGED
@@ -3,7 +3,7 @@ declare enum HttpMethod {
|
|
3
3
|
* The **`CONNECT`** HTTP method requests that a [proxy](https://developer.mozilla.org/en-US/docs/Glossary/Proxy_server) establish a HTTP tunnel to a destination server, and if successful, blindly forward data in both directions until the tunnel is closed.
|
4
4
|
*
|
5
5
|
* The request target is unique to this method in that it consists of only the host and port number of the tunnel destination, separated by a colon (see [Syntax](#syntax) for details).
|
6
|
-
* Any [2XX successful response status code](/en-US/docs/Web/HTTP/Status#successful_responses) means that the proxy will switch to 'tunnel mode' and any data in the success response body is from the server identified by the request target.
|
6
|
+
* Any [2XX successful response status code](/en-US/docs/Web/HTTP/Reference/Status#successful_responses) means that the proxy will switch to 'tunnel mode' and any data in the success response body is from the server identified by the request target.
|
7
7
|
*
|
8
8
|
* If a website is behind a proxy and it's enforced via network rules that all external traffic must pass through the proxy, the `CONNECT` method allows you to establish a [TLS](https://developer.mozilla.org/en-US/docs/Glossary/TLS) ([HTTPS](https://developer.mozilla.org/en-US/docs/Glossary/HTTPS)) connection with that website:
|
9
9
|
*
|
@@ -19,12 +19,68 @@ declare enum HttpMethod {
|
|
19
19
|
* > If you are running a proxy that supports `CONNECT`, restrict its use to a set of known ports or a configurable list of safe request targets.
|
20
20
|
* > There are significant risks in establishing a tunnel to arbitrary servers, particularly when the destination is a well-known or reserved TCP port that is not intended for Web traffic.
|
21
21
|
* > A loosely-configured proxy may be abused to forward traffic such as SMTP to relay spam email, for example.
|
22
|
+
*
|
23
|
+
*
|
24
|
+
*
|
25
|
+
* ## Syntax
|
26
|
+
*
|
27
|
+
* ```http
|
28
|
+
* CONNECT <host>:<port> HTTP/1.1
|
29
|
+
* ```
|
30
|
+
*
|
31
|
+
* - `<host>`
|
32
|
+
* - : A host which may be a registered hostname (e.g., `example.com`) or an IP address (IPv4, IPv6).
|
33
|
+
* - `<port>`
|
34
|
+
* - : A port number in decimal (e.g., `80`, `443`). There is no default port, so a client **must** send one.
|
35
|
+
*
|
36
|
+
* ## Examples
|
37
|
+
*
|
38
|
+
* ### Proxy authorization
|
39
|
+
*
|
40
|
+
* A request for proxy servers that require authorization to create a tunnel looks as follows.
|
41
|
+
* See the [Proxy-Authorization](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization) header for more information.
|
42
|
+
*
|
43
|
+
* ```http
|
44
|
+
* CONNECT server.example.com:80 HTTP/1.1
|
45
|
+
* Host: server.example.com:80
|
46
|
+
* Proxy-Authorization: basic aGVsbG86d29ybGQ=
|
47
|
+
* ```
|
48
|
+
*
|
49
|
+
* ## Specifications
|
50
|
+
*
|
51
|
+
* ## Browser compatibility
|
52
|
+
*
|
53
|
+
* ## See also
|
54
|
+
*
|
55
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
56
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
57
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
58
|
+
* - [Proxy server](https://developer.mozilla.org/en-US/docs/Glossary/Proxy_server) glossary entry
|
59
|
+
* - [Proxy-Authorization](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization) header
|
60
|
+
* - [How To Use SSH Over An HTTP Proxy](https://www.dimoulis.net/posts/ssh-over-proxy/) dimoulis.net (2023)
|
22
61
|
*/
|
23
62
|
CONNECT = "CONNECT",
|
24
63
|
/**
|
25
64
|
* The **`DELETE`** HTTP method asks the server to delete a specified resource.
|
26
65
|
*
|
27
66
|
* The `DELETE` method has no defined semantics for the message body, so this should be empty.
|
67
|
+
*
|
68
|
+
*
|
69
|
+
* ```
|
70
|
+
*
|
71
|
+
* ## Specifications
|
72
|
+
*
|
73
|
+
* ## Browser compatibility
|
74
|
+
*
|
75
|
+
* The browser doesn't use the `DELETE` method for user-initiated actions, so "browser compatibility" doesn't apply.
|
76
|
+
* Developers can set this request method using [`fetch()`](/en-US/docs/Web/API/Window/fetch).
|
77
|
+
*
|
78
|
+
* ## See also
|
79
|
+
*
|
80
|
+
* - HTTP statuses: [200](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200), [202](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202), [204](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204)
|
81
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
82
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
83
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
28
84
|
*/
|
29
85
|
DELETE = "DELETE",
|
30
86
|
/**
|
@@ -33,11 +89,64 @@ declare enum HttpMethod {
|
|
33
89
|
*
|
34
90
|
* > [!NOTE]
|
35
91
|
* > The semantics of sending a message body in `GET` requests are undefined.
|
36
|
-
* > Some servers may reject the request with a [4XX client error](/en-US/docs/Web/HTTP/Status#client_error_responses) response.
|
92
|
+
* > Some servers may reject the request with a [4XX client error](/en-US/docs/Web/HTTP/Reference/Status#client_error_responses) response.
|
93
|
+
*
|
94
|
+
*
|
95
|
+
*
|
96
|
+
* ## Syntax
|
97
|
+
*
|
98
|
+
* ```http
|
99
|
+
* GET <request-target>["?"<query>] HTTP/1.1
|
100
|
+
* ```
|
101
|
+
*
|
102
|
+
* - `<request-target>`
|
103
|
+
* - : Identifies the target resource of the request when combined with the information provided in the [Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host) header.
|
104
|
+
* This is an absolute path (e.g., `/path/to/file.html`) in requests to an origin server, and an absolute URL in requests to proxies (e.g., `http://www.example.com/path/to/file.html`).
|
105
|
+
* - `<query>`
|
106
|
+
* - : An optional query component preceded by a question-mark `?`.
|
107
|
+
* Often used to carry identifying information in the form of `key=value` pairs.
|
108
|
+
*
|
109
|
+
* ## Examples
|
110
|
+
*
|
111
|
+
* ### Successfully retrieving a resource
|
112
|
+
*
|
113
|
+
* The following `GET` request asks for the resource at `example.com/contact`:
|
114
|
+
*
|
115
|
+
* ```http
|
116
|
+
* GET /contact HTTP/1.1
|
117
|
+
* Host: example.com
|
118
|
+
* User-Agent: curl/8.6.0
|
119
|
+
* Accept: * /*
|
120
|
+
* ```
|
121
|
+
*
|
122
|
+
* The server sends back the resource with a [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) status code, indicating success:
|
123
|
+
*
|
124
|
+
* ```http
|
125
|
+
* HTTP/1.1 200 OK
|
126
|
+
* Content-Type: text/html; charset=UTF-8
|
127
|
+
* Date: Fri, 21 Jun 2024 14:18:33 GMT
|
128
|
+
* Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
|
129
|
+
* Content-Length: 1234
|
130
|
+
*
|
131
|
+
* <!doctype html>
|
132
|
+
* <!-- HTML content follows -->
|
133
|
+
* ```
|
134
|
+
*
|
135
|
+
* ## Specifications
|
136
|
+
*
|
137
|
+
* ## Browser compatibility
|
138
|
+
*
|
139
|
+
* ## See also
|
140
|
+
*
|
141
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
142
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
143
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
144
|
+
* - [Range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range) header
|
145
|
+
* - [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/POST) method
|
37
146
|
*/
|
38
147
|
GET = "GET",
|
39
148
|
/**
|
40
|
-
* The **`HEAD`** HTTP method requests the metadata of a resource in the form of [headers](/en-US/docs/Web/HTTP/Headers) that the server would have sent if the [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/GET) method was used instead.
|
149
|
+
* The **`HEAD`** HTTP method requests the metadata of a resource in the form of [headers](/en-US/docs/Web/HTTP/Reference/Headers) that the server would have sent if the [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/GET) method was used instead.
|
41
150
|
* This method can be used in cases where a URL might produce a large download, for example, a `HEAD` request can read the [Content-Length](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length) header to check the file size before downloading the file with a `GET`.
|
42
151
|
*
|
43
152
|
* If the response to a `HEAD` request shows that a cached URL response is now outdated, the cached copy is invalidated even if no `GET` request was made.
|
@@ -45,12 +154,177 @@ declare enum HttpMethod {
|
|
45
154
|
* > [!WARNING]
|
46
155
|
* > If a response to a `HEAD` request has a body, the response body must be ignored.
|
47
156
|
* > Any [representation headers](https://developer.mozilla.org/en-US/docs/glossary/Representation_header) that describe the erroneous body are assumed to describe the response body that a `GET` request would have received.
|
157
|
+
*
|
158
|
+
*
|
159
|
+
*
|
160
|
+
* ## Syntax
|
161
|
+
*
|
162
|
+
* ```http
|
163
|
+
* HEAD <request-target>["?"<query>] HTTP/1.1
|
164
|
+
* ```
|
165
|
+
*
|
166
|
+
* - `<request-target>`
|
167
|
+
* - : Identifies the target resource of the request when combined with the information provided in the [Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host) header.
|
168
|
+
* This is an absolute path (e.g., `/path/to/file.html`) in requests to an origin server, and an absolute URL in requests to proxies (e.g., `http://www.example.com/path/to/file.html`).
|
169
|
+
* - `<query>`
|
170
|
+
* - : An optional query component preceded by a question-mark `?`.
|
171
|
+
* Often used to carry identifying information in the form of `key=value` pairs.
|
172
|
+
*
|
173
|
+
* ## Examples
|
174
|
+
*
|
175
|
+
* ### Successfully retrieving resource metadata
|
176
|
+
*
|
177
|
+
* The following `curl` command creates a `HEAD` request for `example.com`:
|
178
|
+
*
|
179
|
+
* ```bash
|
180
|
+
* curl --head example.com
|
181
|
+
* ```
|
182
|
+
*
|
183
|
+
* This is the equivalent to a `GET` request, except the server shouldn't include a message body in the response.
|
184
|
+
* It creates an HTTP request that looks like this:
|
185
|
+
*
|
186
|
+
* ```http
|
187
|
+
* HEAD / HTTP/1.1
|
188
|
+
* Host: example.com
|
189
|
+
* User-Agent: curl/8.6.0
|
190
|
+
* Accept: * /*
|
191
|
+
* ```
|
192
|
+
*
|
193
|
+
* The server sends back a [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) response comprised only of headers.
|
194
|
+
* The response is effectively metadata that describes the resource instead of the resource itself (some [caching](/en-US/docs/Web/HTTP/Guides/Caching) headers are omitted in this example for brevity):
|
195
|
+
*
|
196
|
+
* ```http
|
197
|
+
* HTTP/1.1 200 OK
|
198
|
+
* Content-Type: text/html; charset=UTF-8
|
199
|
+
* Date: Wed, 04 Sep 2024 10:33:11 GMT
|
200
|
+
* Content-Length: 1234567
|
201
|
+
* ```
|
202
|
+
*
|
203
|
+
* ## Specifications
|
204
|
+
*
|
205
|
+
* ## Browser compatibility
|
206
|
+
*
|
207
|
+
* ## See also
|
208
|
+
*
|
209
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
210
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
211
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
212
|
+
* - [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/GET) method
|
48
213
|
*/
|
49
214
|
HEAD = "HEAD",
|
50
215
|
/**
|
51
216
|
* The **`OPTIONS`** HTTP method requests permitted communication options for a given URL or server.
|
52
217
|
* This can be used to test the allowed HTTP methods for a request, or to determine whether a request would succeed when making a CORS preflighted request.
|
53
218
|
* A client can specify a URL with this method, or an asterisk (`*`) to refer to the entire server.
|
219
|
+
*
|
220
|
+
*
|
221
|
+
*
|
222
|
+
* \* Although an `OPTIONS` message with a request body is technically allowed, it has no defined semantics.
|
223
|
+
* You may include a body in an `OPTIONS` message as long as you provide a valid [Content-Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) header, and when you know the server expects it, as behavior is implementation-specific.
|
224
|
+
*
|
225
|
+
* ## Syntax
|
226
|
+
*
|
227
|
+
* ```http
|
228
|
+
* OPTIONS *|<request-target>["?"<query>] HTTP/1.1
|
229
|
+
* ```
|
230
|
+
*
|
231
|
+
* The request target may be either in 'asterisk form' `*` indicating the whole server, or a request target as is common with other methods:
|
232
|
+
*
|
233
|
+
* - `*`
|
234
|
+
* - : Indicates that the client wishes to request `OPTIONS` for the server as a whole, as opposed to a specific named resource of that server.
|
235
|
+
* - `<request-target>`
|
236
|
+
* - : Identifies the target resource of the request when combined with the information provided in the [Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host) header.
|
237
|
+
* This is an absolute path (e.g., `/path/to/file.html`) in requests to an origin server, and an absolute URL in requests to proxies (e.g., `http://www.example.com/path/to/file.html`).
|
238
|
+
* - `<query>`
|
239
|
+
* - : An optional query component preceded by a question-mark `?`.
|
240
|
+
* Often used to carry identifying information in the form of `key=value` pairs.
|
241
|
+
*
|
242
|
+
* ## Examples
|
243
|
+
*
|
244
|
+
* ### Identifying allowed request methods
|
245
|
+
*
|
246
|
+
* To find out which request methods a server supports, one can use the `curl` command-line program to issue an `OPTIONS` request:
|
247
|
+
*
|
248
|
+
* ```bash
|
249
|
+
* curl -X OPTIONS https://example.org -i
|
250
|
+
* ```
|
251
|
+
*
|
252
|
+
* This creates the following HTTP request:
|
253
|
+
*
|
254
|
+
* ```http
|
255
|
+
* OPTIONS / HTTP/2
|
256
|
+
* Host: example.org
|
257
|
+
* User-Agent: curl/8.7.1
|
258
|
+
* Accept: * /*
|
259
|
+
* ```
|
260
|
+
*
|
261
|
+
* The response contains an [Allow](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Allow) header that holds the allowed methods:
|
262
|
+
*
|
263
|
+
* ```http
|
264
|
+
* HTTP/1.1 204 No Content
|
265
|
+
* Allow: OPTIONS, GET, HEAD, POST
|
266
|
+
* Cache-Control: max-age=604800
|
267
|
+
* Date: Thu, 13 Oct 2016 11:45:00 GMT
|
268
|
+
* Server: EOS (lax004/2813)
|
269
|
+
* ```
|
270
|
+
*
|
271
|
+
* ### Preflighted requests in CORS
|
272
|
+
*
|
273
|
+
* In [CORS](/en-US/docs/Web/HTTP/Guides/CORS), a [preflight request](/en-US/docs/Glossary/Preflight_request) is sent with the `OPTIONS` method so that the server can respond if it is acceptable to send the request. In this example, we will request permission for these parameters:
|
274
|
+
*
|
275
|
+
* - The [Access-Control-Request-Method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Method) header sent in the preflight request tells the server that when the actual request is sent, it will have a [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/POST) request method.
|
276
|
+
* - The [Access-Control-Request-Headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Headers) header tells the server that when the actual request is sent, it will have the `X-PINGOTHER` and `Content-Type` headers.
|
277
|
+
*
|
278
|
+
* ```http
|
279
|
+
* OPTIONS /resources/post-here/ HTTP/1.1
|
280
|
+
* Host: bar.example
|
281
|
+
* Accept: text/html,application/xhtml+xml,application/xml;q=0.9,* /*;q=0.8
|
282
|
+
* Accept-Language: en-us,en;q=0.5
|
283
|
+
* Accept-Encoding: gzip,deflate
|
284
|
+
* Connection: keep-alive
|
285
|
+
* Origin: https://foo.example
|
286
|
+
* Access-Control-Request-Method: POST
|
287
|
+
* Access-Control-Request-Headers: content-type,x-pingother
|
288
|
+
* ```
|
289
|
+
*
|
290
|
+
* The server now can respond if it will accept a request under these circumstances. In this example, the server response says that:
|
291
|
+
*
|
292
|
+
* - [Access-Control-Allow-Origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin)
|
293
|
+
* - : The `https://foo.example` origin is permitted to request the `bar.example/resources/post-here/` URL via the following:
|
294
|
+
* - [Access-Control-Allow-Methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods)
|
295
|
+
* - : [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/POST), [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/GET), and `OPTIONS` are permitted methods for the URL. (This header is similar to the [Allow](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Allow) response header, but used only for [CORS](/en-US/docs/Web/HTTP/Guides/CORS).)
|
296
|
+
* - [Access-Control-Allow-Headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)
|
297
|
+
* - : `X-PINGOTHER` and `Content-Type` are permitted request headers for the URL.
|
298
|
+
* - [Access-Control-Max-Age](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age)
|
299
|
+
* - : The above permissions may be cached for 86,400 seconds (1 day).
|
300
|
+
*
|
301
|
+
* ```http
|
302
|
+
* HTTP/1.1 200 OK
|
303
|
+
* Date: Mon, 01 Dec 2008 01:15:39 GMT
|
304
|
+
* Server: Apache/2.0.61 (Unix)
|
305
|
+
* Access-Control-Allow-Origin: https://foo.example
|
306
|
+
* Access-Control-Allow-Methods: POST, GET, OPTIONS
|
307
|
+
* Access-Control-Allow-Headers: X-PINGOTHER, Content-Type
|
308
|
+
* Access-Control-Max-Age: 86400
|
309
|
+
* Vary: Accept-Encoding, Origin
|
310
|
+
* Keep-Alive: timeout=2, max=100
|
311
|
+
* Connection: Keep-Alive
|
312
|
+
* ```
|
313
|
+
*
|
314
|
+
* > [!NOTE]
|
315
|
+
* > Both [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) and [204 No Content](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204) are [permitted status codes](https://fetch.spec.whatwg.org/#ref-for-ok-status), but some browsers incorrectly believe `204 No Content` applies to the resource and do not send a subsequent request to fetch it.
|
316
|
+
*
|
317
|
+
* ## Specifications
|
318
|
+
*
|
319
|
+
* ## Browser compatibility
|
320
|
+
*
|
321
|
+
* ## See also
|
322
|
+
*
|
323
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
324
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
325
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
326
|
+
* - [Allow](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Allow) header
|
327
|
+
* - [CORS](/en-US/docs/Web/HTTP/Guides/CORS)
|
54
328
|
*/
|
55
329
|
OPTIONS = "OPTIONS",
|
56
330
|
/**
|
@@ -64,8 +338,89 @@ declare enum HttpMethod {
|
|
64
338
|
*
|
65
339
|
* Like [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/POST), a `PATCH` request can potentially have side effects on other resources.
|
66
340
|
*
|
67
|
-
* A server can advertise support for `PATCH` by adding it to the list in the [Allow](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Allow) or [Access-Control-Allow-Methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods) (for [CORS](/en-US/docs/Web/HTTP/CORS)) response headers.
|
341
|
+
* A server can advertise support for `PATCH` by adding it to the list in the [Allow](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Allow) or [Access-Control-Allow-Methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods) (for [CORS](/en-US/docs/Web/HTTP/Guides/CORS)) response headers.
|
68
342
|
* Another implicit indication that `PATCH` is supported is the [Accept-Patch](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Patch) header (usually after an [OPTIONS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/OPTIONS) request on a resource), which lists the media-types the server is able to understand in a `PATCH` request for a resource.
|
343
|
+
*
|
344
|
+
*
|
345
|
+
*
|
346
|
+
* ## Syntax
|
347
|
+
*
|
348
|
+
* ```http
|
349
|
+
* PATCH <request-target>["?"<query>] HTTP/1.1
|
350
|
+
* ```
|
351
|
+
*
|
352
|
+
* - `<request-target>`
|
353
|
+
* - : Identifies the target resource of the request when combined with the information provided in the [Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host) header.
|
354
|
+
* This is an absolute path (e.g., `/path/to/file.html`) in requests to an origin server, and an absolute URL in requests to proxies (e.g., `http://www.example.com/path/to/file.html`).
|
355
|
+
* - `<query>`
|
356
|
+
* - : An optional query component preceded by a question-mark `?`.
|
357
|
+
* Often used to carry identifying information in the form of `key=value` pairs.
|
358
|
+
*
|
359
|
+
* ## Examples
|
360
|
+
*
|
361
|
+
* ### Successfully modifying a resource
|
362
|
+
*
|
363
|
+
* Assume there is a resource on the server representing a user with a numeric ID of `123` in the following format:
|
364
|
+
*
|
365
|
+
* ```json
|
366
|
+
* {
|
367
|
+
* "firstName": "Example",
|
368
|
+
* "LastName": "User",
|
369
|
+
* "userId": 123,
|
370
|
+
* "signupDate": "2024-09-09T21:48:58Z",
|
371
|
+
* "status": "active",
|
372
|
+
* "registeredDevice": {
|
373
|
+
* "id": 1,
|
374
|
+
* "name": "personal",
|
375
|
+
* "manufacturer": {
|
376
|
+
* "name": "Hardware corp"
|
377
|
+
* }
|
378
|
+
* }
|
379
|
+
* }
|
380
|
+
* ```
|
381
|
+
*
|
382
|
+
* Instead of sending a JSON object to fully overwrite a resource, a `PATCH` modifies only specific parts of the resource.
|
383
|
+
* This request updates the `status` field:
|
384
|
+
*
|
385
|
+
* ```http
|
386
|
+
* PATCH /users/123 HTTP/1.1
|
387
|
+
* Host: example.com
|
388
|
+
* Content-Type: application/json
|
389
|
+
* Content-Length: 27
|
390
|
+
* Authorization: Bearer ABC123
|
391
|
+
*
|
392
|
+
* {
|
393
|
+
* "status": "suspended"
|
394
|
+
* }
|
395
|
+
* ```
|
396
|
+
*
|
397
|
+
* The interpretation and authentication of the `PATCH` request depend on the implementation.
|
398
|
+
* Success can be indicated by any of the [successful response status codes](/en-US/docs/Web/HTTP/Reference/Status#successful_responses).
|
399
|
+
* In this example, a [204 No Content](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204) is used as there's no need to transmit a body with additional context about the operation.
|
400
|
+
* An [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) is provided so the caller can perform a [conditional request](/en-US/docs/Web/HTTP/Guides/Conditional_requests) in future:
|
401
|
+
*
|
402
|
+
* ```http
|
403
|
+
* HTTP/1.1 204 No Content
|
404
|
+
* Content-Location: /users/123
|
405
|
+
* ETag: "e0023aa4f"
|
406
|
+
* ```
|
407
|
+
*
|
408
|
+
* ## Specifications
|
409
|
+
*
|
410
|
+
* ## Browser compatibility
|
411
|
+
*
|
412
|
+
* The browser doesn't use the `PATCH` method for user-initiated actions, so "browser compatibility" doesn't apply.
|
413
|
+
* Developers can set this request method using [`fetch()`](/en-US/docs/Web/API/Window/fetch).
|
414
|
+
*
|
415
|
+
* ## See also
|
416
|
+
*
|
417
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
418
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
419
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
420
|
+
* - [204](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204)
|
421
|
+
* - [Allow](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Allow), [Access-Control-Allow-Methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods) headers
|
422
|
+
* - [Accept-Patch](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Patch) – specifies the patch document formats accepted by the server
|
423
|
+
* - [JSON Patch Generator](https://jsoning.com/jsonpatch/)
|
69
424
|
*/
|
70
425
|
PATCH = "PATCH",
|
71
426
|
/**
|
@@ -74,30 +429,99 @@ declare enum HttpMethod {
|
|
74
429
|
* The difference between [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/PUT) and `POST` is that `PUT` is [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/idempotent): calling it once is no different from calling it several times successively (there are no _side_ effects).
|
75
430
|
* Successive identical `POST` requests may have additional effects, such as creating the same order several times.
|
76
431
|
*
|
77
|
-
* [HTML forms](/en-US/docs/
|
78
|
-
* For HTML forms the format/encoding of the body content is determined by the [`enctype`](/en-US/docs/Web/HTML/
|
79
|
-
*
|
432
|
+
* [HTML forms](/en-US/docs/Learn_web_development/Extensions/Forms) typically send data using `POST` and this usually results in a change on the server.
|
433
|
+
* For HTML forms the format/encoding of the body content is determined by the [`enctype`](/en-US/docs/Web/HTML/Reference/Elements/form#enctype) attribute of the [form](https://developer.mozilla.org/en-US/docs/HTMLElement/form) element or the [`formenctype`](/en-US/docs/Web/HTML/Reference/Elements/input#formenctype) attribute of the [input") }} or _or_
|
434
|
+
* - : An optional query component preceded by a question-mark `?`.
|
435
|
+
* Often used to carry identifying information in the form of `key=value` pairs.
|
436
|
+
*
|
437
|
+
* ## Examples
|
438
|
+
*
|
439
|
+
* ### URL-encoded form submission
|
440
|
+
*
|
441
|
+
* A form using `application/x-www-form-urlencoded` content encoding (the default) sends a request where the body contains the form data in `key=value` pairs, with each pair separated by an `&` symbol, as shown below:
|
442
|
+
*
|
443
|
+
* ```http
|
444
|
+
* POST /test HTTP/1.1
|
445
|
+
* Host: example.com
|
446
|
+
* Content-Type: application/x-www-form-urlencoded
|
447
|
+
* Content-Length: 27
|
448
|
+
*
|
449
|
+
* field1=value1&field2=value2
|
450
|
+
* ```
|
451
|
+
*
|
452
|
+
* ### Multipart form submission
|
453
|
+
*
|
454
|
+
* The `multipart/form-data` encoding is used when a form includes files or a lot of data.
|
455
|
+
* This request body delineates each part of the form using a boundary string.
|
456
|
+
* An example of a request in this format:
|
457
|
+
*
|
458
|
+
* ```http
|
459
|
+
* POST /test HTTP/1.1
|
460
|
+
* Host: example.com
|
461
|
+
* Content-Type: multipart/form-data;boundary="delimiter12345"
|
80
462
|
*
|
81
|
-
*
|
82
|
-
*
|
83
|
-
* - `multipart/form-data`: each value is sent as a block of data ("body part"), with a user agent-defined delimiter (for example, `boundary="delimiter12345"`) separating each part.
|
84
|
-
* The keys are described in the [Content-Disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) header of each part or block of data.
|
85
|
-
* - `text/plain`
|
463
|
+
* --delimiter12345
|
464
|
+
* Content-Disposition: form-data; name="field1"
|
86
465
|
*
|
87
|
-
*
|
88
|
-
*
|
466
|
+
* value1
|
467
|
+
* --delimiter12345
|
468
|
+
* Content-Disposition: form-data; name="field2"; filename="example.txt"
|
89
469
|
*
|
90
|
-
*
|
91
|
-
*
|
92
|
-
*
|
93
|
-
*
|
94
|
-
* -
|
470
|
+
* value2
|
471
|
+
* --delimiter12345--
|
472
|
+
* ```
|
473
|
+
*
|
474
|
+
* The [Content-Disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) header indicates how the form data should be processed, specifying the field `name` and `filename`, if appropriate.
|
475
|
+
*
|
476
|
+
* ## Specifications
|
477
|
+
*
|
478
|
+
* ## Browser compatibility
|
479
|
+
*
|
480
|
+
* ## See also
|
481
|
+
*
|
482
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
483
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
484
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
485
|
+
* - [Content-Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) header
|
486
|
+
* - [Content-Disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) header
|
487
|
+
* - [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/GET) method
|
95
488
|
*/
|
96
489
|
POST = "POST",
|
97
490
|
/**
|
98
491
|
* The **`PUT`** HTTP method creates a new resource or replaces a representation of the target resource with the request [content](https://developer.mozilla.org/en-US/docs/Glossary/HTTP_Content).
|
99
492
|
*
|
100
493
|
* The difference between `PUT` and [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Method/POST) is that `PUT` is [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/idempotent): calling it once is no different from calling it several times successively (there are no _side_ effects).
|
494
|
+
*
|
495
|
+
*
|
496
|
+
* ```
|
497
|
+
*
|
498
|
+
* If the target resource **does not** have a current representation and the `PUT` request successfully creates one, then the origin server must send a [201 Created](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201) response:
|
499
|
+
*
|
500
|
+
* ```http
|
501
|
+
* HTTP/1.1 201 Created
|
502
|
+
* Content-Location: /new.html
|
503
|
+
* ```
|
504
|
+
*
|
505
|
+
* If the target resource **does** have a current representation and that representation is successfully modified with the state in the request, the origin server must send either a [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) or a [204 No Content](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204) to indicate successful completion of the request:
|
506
|
+
*
|
507
|
+
* ```http
|
508
|
+
* HTTP/1.1 204 No Content
|
509
|
+
* Content-Location: /existing.html
|
510
|
+
* ```
|
511
|
+
*
|
512
|
+
* ## Specifications
|
513
|
+
*
|
514
|
+
* ## Browser compatibility
|
515
|
+
*
|
516
|
+
* The browser doesn't use the `PUT` method for user-initiated actions, so "browser compatibility" doesn't apply.
|
517
|
+
* Developers can set this request method using [`fetch()`](/en-US/docs/Web/API/Window/fetch).
|
518
|
+
*
|
519
|
+
* ## See also
|
520
|
+
*
|
521
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
522
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
523
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
524
|
+
* - [201 Created](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201), [204 No Content](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204) response statuses
|
101
525
|
*/
|
102
526
|
PUT = "PUT",
|
103
527
|
/**
|
@@ -108,7 +532,69 @@ declare enum HttpMethod {
|
|
108
532
|
*
|
109
533
|
* The client must not send [content](https://developer.mozilla.org/en-US/docs/Glossary/HTTP_Content) in the request, or generate headers that might include sensitive data such as user credentials or cookies.
|
110
534
|
* Not all servers implement the `TRACE` method, and some server owners have historically disallowed the use of the `TRACE` method due to security concerns.
|
111
|
-
* In such cases, a [405 Method Not Allowed](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405) [client error response](/en-US/docs/Web/HTTP/Status#client_error_responses) will be sent.
|
535
|
+
* In such cases, a [405 Method Not Allowed](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405) [client error response](/en-US/docs/Web/HTTP/Reference/Status#client_error_responses) will be sent.
|
536
|
+
*
|
537
|
+
*
|
538
|
+
*
|
539
|
+
* ## Syntax
|
540
|
+
*
|
541
|
+
* ```http
|
542
|
+
* TRACE <request-target>["?"<query>] HTTP/1.1
|
543
|
+
* ```
|
544
|
+
*
|
545
|
+
* - `<request-target>`
|
546
|
+
* - : Identifies the target resource of the request when combined with the information provided in the [Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host) header.
|
547
|
+
* This is an absolute path (e.g., `/path/to/file.html`) in requests to an origin server, and an absolute URL in requests to proxies (e.g., `http://www.example.com/path/to/file.html`).
|
548
|
+
* - `<query>`
|
549
|
+
* - : An optional query component preceded by a question-mark `?`.
|
550
|
+
* Often used to carry identifying information in the form of `key=value` pairs.
|
551
|
+
*
|
552
|
+
* ## Examples
|
553
|
+
*
|
554
|
+
* ### Successful TRACE request
|
555
|
+
*
|
556
|
+
* A `TRACE` request can be performed using `curl`:
|
557
|
+
*
|
558
|
+
* ```bash
|
559
|
+
* curl -v -X TRACE example.com
|
560
|
+
* ```
|
561
|
+
*
|
562
|
+
* This produces the following HTTP request:
|
563
|
+
*
|
564
|
+
* ```http
|
565
|
+
* TRACE / HTTP/1.1
|
566
|
+
* Host: example.com
|
567
|
+
* User-Agent: curl/8.7.1
|
568
|
+
* Accept: * /*
|
569
|
+
* ```
|
570
|
+
*
|
571
|
+
* A [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200) response with the request headers contained in response body is sent back to the client:
|
572
|
+
*
|
573
|
+
* ```http
|
574
|
+
* HTTP/1.1 200 OK
|
575
|
+
* Content-Length: 123
|
576
|
+
* Date: Wed, 04 Sep 2024 11:50:24 GMT
|
577
|
+
* Server: Apache/2.4.59 (Unix)
|
578
|
+
* Content-Type: message/http
|
579
|
+
*
|
580
|
+
* TRACE / HTTP/1.1
|
581
|
+
* Host: example.com
|
582
|
+
* User-Agent: curl/8.7.1
|
583
|
+
* Accept: * /*
|
584
|
+
* ```
|
585
|
+
*
|
586
|
+
* ## Specifications
|
587
|
+
*
|
588
|
+
* ## Browser compatibility
|
589
|
+
*
|
590
|
+
* The browser doesn't use the `TRACE` method for user-initiated actions, so "browser compatibility" doesn't apply.
|
591
|
+
*
|
592
|
+
* ## See also
|
593
|
+
*
|
594
|
+
* - [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
|
595
|
+
* - [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
|
596
|
+
* - [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
|
597
|
+
* - [Cross-Site Tracing (XST)](https://owasp.org/www-community/attacks/Cross_Site_Tracing)
|
112
598
|
*/
|
113
599
|
TRACE = "TRACE"
|
114
600
|
}
|