@opra/common 0.10.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/filter/antlr/OpraFilterLexer.js +1 -1
- package/cjs/filter/antlr/OpraFilterListener.js +1 -1
- package/cjs/filter/antlr/OpraFilterParser.js +5 -5
- package/cjs/filter/antlr/OpraFilterVisitor.js +1 -1
- package/cjs/filter/filter-tree-visitor.js +8 -2
- package/cjs/filter/opra-error-listener.js +2 -2
- package/cjs/filter/parse.js +1 -1
- package/cjs/helpers/responsive-map.js +45 -28
- package/{esm/http/enums/http-headers.enum.js → cjs/http/enums/http-headers-codes.enum.js} +95 -92
- package/{esm/http/enums/http-status.enum.js → cjs/http/enums/http-status-codes.enum.js} +62 -59
- package/cjs/http/http-headers.js +213 -0
- package/cjs/http/http-param-codec.js +6 -0
- package/cjs/http/http-params.js +321 -0
- package/cjs/http/http-request-node.js +105 -0
- package/cjs/http/http-request.js +73 -88
- package/cjs/http/http-response.js +23 -0
- package/cjs/http/index.js +13 -2
- package/cjs/http/multipart/batch-multipart.js +12 -12
- package/cjs/http/param-codec/boolean-codec.js +25 -0
- package/cjs/http/param-codec/date-codec.js +44 -0
- package/cjs/http/param-codec/filter-codec.js +18 -0
- package/cjs/http/param-codec/integer-codec.js +19 -0
- package/cjs/http/param-codec/number-codec.js +26 -0
- package/cjs/http/param-codec/string-codec.js +25 -0
- package/cjs/http/utils/encodeURIParam.js +21 -0
- package/cjs/http/utils/normalize-headers.js +2 -2
- package/cjs/i18n/i18n.js +1 -4
- package/cjs/schema/implementation/opra-document.js +12 -11
- package/cjs/schema/implementation/resource/collection-resource-info.js +7 -0
- package/cjs/url/opra-url-path.js +96 -72
- package/cjs/url/opra-url-search-params.js +16 -234
- package/cjs/url/opra-url.js +201 -160
- package/esm/filter/antlr/OpraFilterLexer.d.ts +1 -1
- package/esm/filter/antlr/OpraFilterLexer.js +1 -1
- package/esm/filter/antlr/OpraFilterListener.d.ts +1 -1
- package/esm/filter/antlr/OpraFilterListener.js +1 -1
- package/esm/filter/antlr/OpraFilterParser.d.ts +1 -1
- package/esm/filter/antlr/OpraFilterParser.js +5 -5
- package/esm/filter/antlr/OpraFilterVisitor.d.ts +1 -1
- package/esm/filter/antlr/OpraFilterVisitor.js +1 -1
- package/esm/filter/ast/expressions/arithmetic-expression.d.ts +1 -1
- package/esm/filter/ast/expressions/comparison-expression.d.ts +1 -1
- package/esm/filter/ast/expressions/logical-expression.d.ts +1 -1
- package/esm/filter/build.d.ts +3 -3
- package/esm/filter/errors.d.ts +4 -2
- package/esm/filter/filter-tree-visitor.d.ts +2 -1
- package/esm/filter/filter-tree-visitor.js +8 -2
- package/esm/filter/opra-error-listener.d.ts +2 -2
- package/esm/filter/opra-error-listener.js +2 -2
- package/esm/filter/parse.d.ts +1 -1
- package/esm/filter/parse.js +1 -1
- package/esm/helpers/responsive-map.d.ts +19 -5
- package/esm/helpers/responsive-map.js +45 -28
- package/esm/http/enums/{http-headers.enum.d.ts → http-headers-codes.enum.d.ts} +1 -1
- package/{cjs/http/enums/http-headers.enum.js → esm/http/enums/http-headers-codes.enum.js} +92 -95
- package/esm/http/enums/{http-status.enum.d.ts → http-status-codes.enum.d.ts} +1 -1
- package/{cjs/http/enums/http-status.enum.js → esm/http/enums/http-status-codes.enum.js} +59 -62
- package/esm/http/http-headers.d.ts +70 -0
- package/esm/http/http-headers.js +209 -0
- package/esm/http/http-param-codec.d.ts +4 -0
- package/esm/http/http-param-codec.js +2 -0
- package/esm/http/http-params.d.ts +99 -0
- package/esm/http/http-params.js +317 -0
- package/esm/http/http-request-node.d.ts +34 -0
- package/esm/http/http-request-node.js +101 -0
- package/esm/http/http-request.d.ts +73 -31
- package/esm/http/http-request.js +72 -87
- package/esm/http/http-response.d.ts +41 -0
- package/esm/http/http-response.js +19 -0
- package/esm/http/index.d.ts +13 -2
- package/esm/http/index.js +13 -2
- package/esm/http/interfaces/client-http-headers.interface.d.ts +1 -1
- package/esm/http/interfaces/server-http-headers.interface.d.ts +1 -1
- package/esm/http/multipart/batch-multipart.d.ts +1 -1
- package/esm/http/multipart/batch-multipart.js +12 -12
- package/esm/http/multipart/http-request-content.d.ts +1 -1
- package/esm/http/multipart/http-response-content.d.ts +1 -1
- package/esm/http/param-codec/boolean-codec.d.ts +5 -0
- package/esm/http/param-codec/boolean-codec.js +21 -0
- package/esm/http/param-codec/date-codec.d.ts +16 -0
- package/esm/http/param-codec/date-codec.js +40 -0
- package/esm/http/param-codec/filter-codec.d.ts +6 -0
- package/esm/http/param-codec/filter-codec.js +14 -0
- package/esm/http/param-codec/integer-codec.d.ts +9 -0
- package/esm/http/param-codec/integer-codec.js +15 -0
- package/esm/http/param-codec/number-codec.d.ts +12 -0
- package/esm/http/param-codec/number-codec.js +22 -0
- package/esm/http/param-codec/string-codec.d.ts +14 -0
- package/esm/http/param-codec/string-codec.js +21 -0
- package/esm/http/utils/encodeURIParam.d.ts +1 -0
- package/esm/http/utils/encodeURIParam.js +17 -0
- package/esm/http/utils/normalize-headers.js +2 -2
- package/esm/i18n/i18n.d.ts +6 -6
- package/esm/i18n/i18n.js +1 -4
- package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +1 -1
- package/esm/schema/decorators/opr-complex-type.decorator.d.ts +1 -1
- package/esm/schema/decorators/opr-simple-type.decorator.d.ts +1 -1
- package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +1 -1
- package/esm/schema/implementation/data-type/complex-type.d.ts +1 -1
- package/esm/schema/implementation/data-type/union-type.d.ts +1 -1
- package/esm/schema/implementation/document-builder.d.ts +1 -1
- package/esm/schema/implementation/opra-document.d.ts +2 -2
- package/esm/schema/implementation/opra-document.js +12 -11
- package/esm/schema/implementation/query/collection-count-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-create-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-delete-many-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-get-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-search-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-update-many-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-update-query.d.ts +1 -1
- package/esm/schema/implementation/query/field-get-query.d.ts +1 -1
- package/esm/schema/implementation/query/index.d.ts +4 -4
- package/esm/schema/implementation/query/singleton-get-query.d.ts +1 -1
- package/esm/schema/implementation/resource/collection-resource-info.d.ts +2 -0
- package/esm/schema/implementation/resource/collection-resource-info.js +7 -0
- package/esm/schema/interfaces/data-type.metadata.d.ts +4 -4
- package/esm/schema/interfaces/resource.metadata.d.ts +9 -9
- package/esm/schema/types.d.ts +8 -8
- package/esm/url/opra-url-path-component.d.ts +1 -1
- package/esm/url/opra-url-path.d.ts +24 -18
- package/esm/url/opra-url-path.js +96 -72
- package/esm/url/opra-url-search-params.d.ts +3 -42
- package/esm/url/opra-url-search-params.js +16 -234
- package/esm/url/opra-url.d.ts +38 -28
- package/esm/url/opra-url.js +201 -160
- package/package.json +12 -12
|
@@ -1,131 +1,128 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// noinspection JSUnusedGlobalSymbols
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.HttpStatus = void 0;
|
|
5
2
|
/**
|
|
6
3
|
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#successful_responses
|
|
7
4
|
*/
|
|
8
|
-
var
|
|
9
|
-
(function (
|
|
5
|
+
export var HttpStatusCodes;
|
|
6
|
+
(function (HttpStatusCodes) {
|
|
10
7
|
/* *** Information responses *** */
|
|
11
8
|
/**
|
|
12
9
|
* This interim response indicates that the client should continue the request or
|
|
13
10
|
* ignore the response if the request is already finished.
|
|
14
11
|
*/
|
|
15
|
-
|
|
12
|
+
HttpStatusCodes[HttpStatusCodes["CONTINUE"] = 100] = "CONTINUE";
|
|
16
13
|
/**
|
|
17
14
|
* This code is sent in response to an Upgrade request header from the client and
|
|
18
15
|
* indicates the protocol the server is switching to.
|
|
19
16
|
*/
|
|
20
|
-
|
|
17
|
+
HttpStatusCodes[HttpStatusCodes["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
21
18
|
/**
|
|
22
19
|
* This code indicates that the server has received and is processing the request, but no response is available yet.
|
|
23
20
|
*/
|
|
24
|
-
|
|
21
|
+
HttpStatusCodes[HttpStatusCodes["PROCESSING"] = 102] = "PROCESSING";
|
|
25
22
|
/**
|
|
26
23
|
* This status code is primarily intended to be used with the Link header, letting the user agent
|
|
27
24
|
* start preloading resources while the server prepares a response.
|
|
28
25
|
*/
|
|
29
|
-
|
|
26
|
+
HttpStatusCodes[HttpStatusCodes["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
30
27
|
/* *** Successful responses *** */
|
|
31
28
|
/**
|
|
32
29
|
* The request succeeded.
|
|
33
30
|
*/
|
|
34
|
-
|
|
31
|
+
HttpStatusCodes[HttpStatusCodes["OK"] = 200] = "OK";
|
|
35
32
|
/**
|
|
36
33
|
* The request succeeded, and a new resource was created as a result.
|
|
37
34
|
* This is typically the response sent after POST requests, or some PUT requests.
|
|
38
35
|
*/
|
|
39
|
-
|
|
36
|
+
HttpStatusCodes[HttpStatusCodes["CREATED"] = 201] = "CREATED";
|
|
40
37
|
/**
|
|
41
38
|
* The request has been received but not yet acted upon. It is noncommittal,
|
|
42
39
|
* since there is no way in HTTP to later send an asynchronous response indicating
|
|
43
40
|
* the outcome of the request. It is intended for cases where another process or
|
|
44
41
|
* server handles the request, or for batch processing.
|
|
45
42
|
*/
|
|
46
|
-
|
|
43
|
+
HttpStatusCodes[HttpStatusCodes["ACCEPTED"] = 202] = "ACCEPTED";
|
|
47
44
|
/**
|
|
48
45
|
* This response code means the returned metadata is not exactly the same as is available from
|
|
49
46
|
* the origin server, but is collected from a local or a third-party copy. This is mostly used
|
|
50
47
|
* for mirrors or backups of another resource. Except for that specific case, the 200 OK
|
|
51
48
|
* response is preferred to this status.
|
|
52
49
|
*/
|
|
53
|
-
|
|
50
|
+
HttpStatusCodes[HttpStatusCodes["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
54
51
|
/**
|
|
55
52
|
* There is no content to send for this request, but the headers may be useful.
|
|
56
53
|
* The user agent may update its cached headers for this resource with the new ones.
|
|
57
54
|
*/
|
|
58
|
-
|
|
55
|
+
HttpStatusCodes[HttpStatusCodes["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
59
56
|
/**
|
|
60
57
|
* Tells the user agent to reset the document which sent this request.
|
|
61
58
|
*/
|
|
62
|
-
|
|
59
|
+
HttpStatusCodes[HttpStatusCodes["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
63
60
|
/**
|
|
64
61
|
* This response code is used when the Range header is sent from the client to request only part of a resource.
|
|
65
62
|
*/
|
|
66
|
-
|
|
63
|
+
HttpStatusCodes[HttpStatusCodes["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
67
64
|
/* *** Redirection messages *** */
|
|
68
65
|
/**
|
|
69
66
|
* The request has more than one possible response. The user agent or user should choose one of them.
|
|
70
67
|
* (There is no standardized way of choosing one of the responses, but HTML links to the possibilities
|
|
71
68
|
* are recommended so the user can pick.)
|
|
72
69
|
*/
|
|
73
|
-
|
|
70
|
+
HttpStatusCodes[HttpStatusCodes["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
74
71
|
/**
|
|
75
72
|
* The URL of the requested resource has been changed permanently. The new URL is given in the response.
|
|
76
73
|
*/
|
|
77
|
-
|
|
74
|
+
HttpStatusCodes[HttpStatusCodes["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
78
75
|
/**
|
|
79
76
|
* This response code means that the URI of requested resource has been changed temporarily.
|
|
80
77
|
* Further changes in the URI might be made in the future. Therefore, this same URI should
|
|
81
78
|
* be used by the client in future requests.
|
|
82
79
|
*/
|
|
83
|
-
|
|
80
|
+
HttpStatusCodes[HttpStatusCodes["FOUND"] = 302] = "FOUND";
|
|
84
81
|
/**
|
|
85
82
|
* This is used for caching purposes. It tells the client that the response has not been modified,
|
|
86
83
|
* so the client can continue to use the same cached version of the response.
|
|
87
84
|
*/
|
|
88
|
-
|
|
85
|
+
HttpStatusCodes[HttpStatusCodes["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
89
86
|
/**
|
|
90
87
|
*
|
|
91
88
|
*/
|
|
92
|
-
|
|
89
|
+
HttpStatusCodes[HttpStatusCodes["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
93
90
|
/**
|
|
94
91
|
* The server sends this response to direct the client to get the requested resource at another
|
|
95
92
|
* URI with same method that was used in the prior request. This has the same semantics as
|
|
96
93
|
* the 302 Found HTTP response code, with the exception that the user agent must not change
|
|
97
94
|
* the HTTP method used: if a POST was used in the first request, a POST must be used in the second request.
|
|
98
95
|
*/
|
|
99
|
-
|
|
96
|
+
HttpStatusCodes[HttpStatusCodes["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
100
97
|
/**
|
|
101
98
|
* This means that the resource is now permanently located at another URI, specified by the Location:
|
|
102
99
|
* HTTP Response header. This has the same semantics as the 301 Moved Permanently HTTP response code,
|
|
103
100
|
* with the exception that the user agent must not change the HTTP method used: if a POST was used
|
|
104
101
|
* in the first request, a POST must be used in the second request.
|
|
105
102
|
*/
|
|
106
|
-
|
|
103
|
+
HttpStatusCodes[HttpStatusCodes["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
107
104
|
/* *** Client error responses *** */
|
|
108
105
|
/**
|
|
109
106
|
* The server cannot or will not process the request due to something that is perceived to be a client error
|
|
110
107
|
* (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
|
|
111
108
|
*/
|
|
112
|
-
|
|
109
|
+
HttpStatusCodes[HttpStatusCodes["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
113
110
|
/**
|
|
114
111
|
* Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated".
|
|
115
112
|
* That is, the client must authenticate itself to get the requested response.
|
|
116
113
|
*/
|
|
117
|
-
|
|
114
|
+
HttpStatusCodes[HttpStatusCodes["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
118
115
|
/**
|
|
119
116
|
* This response code is reserved for future use. The initial aim for creating this code was using
|
|
120
117
|
* it for digital payment systems, however this status code is used very rarely and no standard convention exists.
|
|
121
118
|
*/
|
|
122
|
-
|
|
119
|
+
HttpStatusCodes[HttpStatusCodes["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
123
120
|
/**
|
|
124
121
|
* The client does not have access rights to the content; that is, it is unauthorized,
|
|
125
122
|
* so the server is refusing to give the requested resource. Unlike 401 Unauthorized,
|
|
126
123
|
* the client's identity is known to the server.
|
|
127
124
|
*/
|
|
128
|
-
|
|
125
|
+
HttpStatusCodes[HttpStatusCodes["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
129
126
|
/**
|
|
130
127
|
* The server can not find the requested resource. In the browser, this means the URL is not recognized.
|
|
131
128
|
* In an API, this can also mean that the endpoint is valid but the resource itself does not exist.
|
|
@@ -133,21 +130,21 @@ var HttpStatus;
|
|
|
133
130
|
* from an unauthorized client. This response code is probably the most well known due to its
|
|
134
131
|
* frequent occurrence on the web.
|
|
135
132
|
*/
|
|
136
|
-
|
|
133
|
+
HttpStatusCodes[HttpStatusCodes["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
137
134
|
/**
|
|
138
135
|
* The request method is known by the server but is not supported by the target resource.
|
|
139
136
|
* For example, an API may not allow calling DELETE to remove a resource.
|
|
140
137
|
*/
|
|
141
|
-
|
|
138
|
+
HttpStatusCodes[HttpStatusCodes["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
142
139
|
/**
|
|
143
140
|
* This response is sent when the web server, after performing server-driven content negotiation,
|
|
144
141
|
* doesn't find any content that conforms to the criteria given by the user agent.
|
|
145
142
|
*/
|
|
146
|
-
|
|
143
|
+
HttpStatusCodes[HttpStatusCodes["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
147
144
|
/**
|
|
148
145
|
* This is similar to 401 Unauthorized but authentication is needed to be done by a proxy.
|
|
149
146
|
*/
|
|
150
|
-
|
|
147
|
+
HttpStatusCodes[HttpStatusCodes["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
151
148
|
/**
|
|
152
149
|
* This response is sent on an idle connection by some servers, even without any previous request by the client.
|
|
153
150
|
* It means that the server would like to shut down this unused connection.
|
|
@@ -155,107 +152,107 @@ var HttpStatus;
|
|
|
155
152
|
* like Chrome, Firefox 27+, or IE9, use HTTP pre-connection mechanisms to speed up surfing.
|
|
156
153
|
* Also note that some servers merely shut down the connection without sending this message.
|
|
157
154
|
*/
|
|
158
|
-
|
|
155
|
+
HttpStatusCodes[HttpStatusCodes["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
159
156
|
/**
|
|
160
157
|
* This response is sent when a request conflicts with the current state of the server.
|
|
161
158
|
*/
|
|
162
|
-
|
|
159
|
+
HttpStatusCodes[HttpStatusCodes["CONFLICT"] = 409] = "CONFLICT";
|
|
163
160
|
/**
|
|
164
161
|
* This response is sent when the requested content has been permanently deleted from server,
|
|
165
162
|
* with no forwarding address. Clients are expected to remove their caches and links to the resource.
|
|
166
163
|
* The HTTP specification intends this status code to be used for "limited-time, promotional services".
|
|
167
164
|
* APIs should not feel compelled to indicate resources that have been deleted with this status code.
|
|
168
165
|
*/
|
|
169
|
-
|
|
166
|
+
HttpStatusCodes[HttpStatusCodes["GONE"] = 410] = "GONE";
|
|
170
167
|
/**
|
|
171
168
|
* Server rejected the request because the Content-Length header field is not defined and the server requires it.
|
|
172
169
|
*/
|
|
173
|
-
|
|
170
|
+
HttpStatusCodes[HttpStatusCodes["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
174
171
|
/**
|
|
175
172
|
* The client has indicated preconditions in its headers which the server does not meet.
|
|
176
173
|
*/
|
|
177
|
-
|
|
174
|
+
HttpStatusCodes[HttpStatusCodes["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
178
175
|
/**
|
|
179
176
|
* Request entity is larger than limits defined by server. The server might close the connection or
|
|
180
177
|
* return an Retry-After header field.
|
|
181
178
|
*/
|
|
182
|
-
|
|
179
|
+
HttpStatusCodes[HttpStatusCodes["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
183
180
|
/**
|
|
184
181
|
* The URI requested by the client is longer than the server is willing to interpret.
|
|
185
182
|
*/
|
|
186
|
-
|
|
183
|
+
HttpStatusCodes[HttpStatusCodes["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
187
184
|
/**
|
|
188
185
|
* The media format of the requested data is not supported by the server, so the server is rejecting the request.
|
|
189
186
|
*/
|
|
190
|
-
|
|
187
|
+
HttpStatusCodes[HttpStatusCodes["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
191
188
|
/**
|
|
192
189
|
* The range specified by the Range header field in the request cannot be fulfilled.
|
|
193
190
|
* It's possible that the range is outside the size of the target URI's data.
|
|
194
191
|
*/
|
|
195
|
-
|
|
192
|
+
HttpStatusCodes[HttpStatusCodes["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
196
193
|
/**
|
|
197
194
|
* This response code means the expectation indicated by the Expect request header field cannot be met by the server.
|
|
198
195
|
*/
|
|
199
|
-
|
|
196
|
+
HttpStatusCodes[HttpStatusCodes["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
200
197
|
/**
|
|
201
198
|
* The server refuses the attempt to brew coffee with a teapot.
|
|
202
199
|
*/
|
|
203
|
-
|
|
200
|
+
HttpStatusCodes[HttpStatusCodes["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
204
201
|
/**
|
|
205
202
|
* The request was directed at a server that is not able to produce a response.
|
|
206
203
|
* This can be sent by a server that is not configured to produce responses for
|
|
207
204
|
* the combination of scheme and authority that are included in the request URI.
|
|
208
205
|
*/
|
|
209
|
-
|
|
206
|
+
HttpStatusCodes[HttpStatusCodes["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
210
207
|
/**
|
|
211
208
|
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
212
209
|
*/
|
|
213
|
-
|
|
210
|
+
HttpStatusCodes[HttpStatusCodes["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
214
211
|
/**
|
|
215
212
|
* The resource that is being accessed is locked.
|
|
216
213
|
*/
|
|
217
|
-
|
|
214
|
+
HttpStatusCodes[HttpStatusCodes["LOCKED"] = 423] = "LOCKED";
|
|
218
215
|
/**
|
|
219
216
|
* The request failed due to failure of a previous request.
|
|
220
217
|
*/
|
|
221
|
-
|
|
218
|
+
HttpStatusCodes[HttpStatusCodes["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
222
219
|
/**
|
|
223
220
|
* Indicates that the server is unwilling to risk processing a request that might be replayed.
|
|
224
221
|
*/
|
|
225
|
-
|
|
222
|
+
HttpStatusCodes[HttpStatusCodes["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
226
223
|
/**
|
|
227
224
|
* The server refuses to perform the request using the current protocol but might be willing
|
|
228
225
|
* to do so after the client upgrades to a different protocol. The server sends an Upgrade
|
|
229
226
|
* header in a 426 response to indicate the required protocol(s).
|
|
230
227
|
*/
|
|
231
|
-
|
|
228
|
+
HttpStatusCodes[HttpStatusCodes["UPGRADE_REQUIRED"] = 428] = "UPGRADE_REQUIRED";
|
|
232
229
|
/**
|
|
233
230
|
* The origin server requires the request to be conditional. This response is intended to prevent
|
|
234
231
|
* the 'lost update' problem, where a client GETs a resource's state, modifies it and PUTs
|
|
235
232
|
* it back to the server, when meanwhile a third party has modified the state on the server,
|
|
236
233
|
* leading to a conflict.
|
|
237
234
|
*/
|
|
238
|
-
|
|
235
|
+
HttpStatusCodes[HttpStatusCodes["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
239
236
|
/**
|
|
240
237
|
* The user has sent too many requests in a given amount of time ("rate limiting").
|
|
241
238
|
*/
|
|
242
|
-
|
|
239
|
+
HttpStatusCodes[HttpStatusCodes["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
243
240
|
/* *** Server error responses *** */
|
|
244
241
|
/**
|
|
245
242
|
* The server has encountered a situation it does not know how to handle.
|
|
246
243
|
*/
|
|
247
|
-
|
|
244
|
+
HttpStatusCodes[HttpStatusCodes["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
248
245
|
/**
|
|
249
246
|
* The request method is not supported by the server and cannot be handled.
|
|
250
247
|
* The only methods that servers are required to support (and therefore that must not return this code)
|
|
251
248
|
* are GET and HEAD.
|
|
252
249
|
*/
|
|
253
|
-
|
|
250
|
+
HttpStatusCodes[HttpStatusCodes["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
254
251
|
/**
|
|
255
252
|
* This error response means that the server, while working as a gateway to get
|
|
256
253
|
* a response needed to handle the request, got an invalid response.
|
|
257
254
|
*/
|
|
258
|
-
|
|
255
|
+
HttpStatusCodes[HttpStatusCodes["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
259
256
|
/**
|
|
260
257
|
* The server is not ready to handle the request. Common causes are a server that is down for maintenance
|
|
261
258
|
* or that is overloaded. Note that together with this response, a user-friendly page explaining
|
|
@@ -265,36 +262,36 @@ var HttpStatus;
|
|
|
265
262
|
* headers that are sent along with this response, as these temporary condition responses
|
|
266
263
|
* should usually not be cached.
|
|
267
264
|
*/
|
|
268
|
-
|
|
265
|
+
HttpStatusCodes[HttpStatusCodes["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
269
266
|
/**
|
|
270
267
|
* This error response is given when the server is acting as a gateway and cannot get a response in time.
|
|
271
268
|
*/
|
|
272
|
-
|
|
269
|
+
HttpStatusCodes[HttpStatusCodes["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
273
270
|
/**
|
|
274
271
|
* The HTTP version used in the request is not supported by the server.
|
|
275
272
|
*/
|
|
276
|
-
|
|
273
|
+
HttpStatusCodes[HttpStatusCodes["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
277
274
|
/**
|
|
278
275
|
* The server has an internal configuration error: the chosen variant resource is configured
|
|
279
276
|
* to engage in transparent content negotiation itself, and is therefore not a proper end
|
|
280
277
|
* point in the negotiation process.
|
|
281
278
|
*/
|
|
282
|
-
|
|
279
|
+
HttpStatusCodes[HttpStatusCodes["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
283
280
|
/**
|
|
284
281
|
* The method could not be performed on the resource because the server is unable to store
|
|
285
282
|
* the representation needed to successfully complete the request.
|
|
286
283
|
*/
|
|
287
|
-
|
|
284
|
+
HttpStatusCodes[HttpStatusCodes["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
288
285
|
/**
|
|
289
286
|
* The server detected an infinite loop while processing the request.
|
|
290
287
|
*/
|
|
291
|
-
|
|
288
|
+
HttpStatusCodes[HttpStatusCodes["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
292
289
|
/**
|
|
293
290
|
* Further extensions to the request are required for the server to fulfill it.
|
|
294
291
|
*/
|
|
295
|
-
|
|
292
|
+
HttpStatusCodes[HttpStatusCodes["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
296
293
|
/**
|
|
297
294
|
* Indicates that the client needs to authenticate to gain network access.
|
|
298
295
|
*/
|
|
299
|
-
|
|
300
|
-
})(
|
|
296
|
+
HttpStatusCodes[HttpStatusCodes["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
297
|
+
})(HttpStatusCodes || (HttpStatusCodes = {}));
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ResponsiveMap } from '../helpers/responsive-map.js';
|
|
2
|
+
declare const nodeInspectCustom: unique symbol;
|
|
3
|
+
declare const kEntries: unique symbol;
|
|
4
|
+
declare const kSize: unique symbol;
|
|
5
|
+
declare const kOptions: unique symbol;
|
|
6
|
+
type HeaderValueType = string | number | boolean;
|
|
7
|
+
export type HttpHeadersInit = string | Headers | HttpHeaders | Map<string, any> | Record<string, string | string[]>;
|
|
8
|
+
export interface HttpHeadersOptions {
|
|
9
|
+
onChange?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare class HttpHeaders {
|
|
12
|
+
protected static kEntries: symbol;
|
|
13
|
+
protected static kSize: symbol;
|
|
14
|
+
protected static kOptions: symbol;
|
|
15
|
+
protected [kEntries]: ResponsiveMap<string, string[]>;
|
|
16
|
+
protected [kSize]: number;
|
|
17
|
+
protected [kOptions]: HttpHeadersOptions;
|
|
18
|
+
constructor(init?: HttpHeadersInit, options?: HttpHeadersOptions);
|
|
19
|
+
get size(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Appends a new value to the existing set of values for a header
|
|
22
|
+
* and returns this instance
|
|
23
|
+
*/
|
|
24
|
+
append(name: string, value: HeaderValueType | HeaderValueType[]): this;
|
|
25
|
+
/**
|
|
26
|
+
* Appends multiple values to the existing set of values for a header
|
|
27
|
+
* and returns this instance
|
|
28
|
+
*/
|
|
29
|
+
appendAll(headers: HttpHeadersInit): this;
|
|
30
|
+
changed(): void;
|
|
31
|
+
clear(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Deletes values for a given header
|
|
34
|
+
*/
|
|
35
|
+
delete(name: string, value?: HeaderValueType | HeaderValueType[]): this;
|
|
36
|
+
/**
|
|
37
|
+
* Returns an iterable of key, value pairs for every entry in the map.
|
|
38
|
+
*/
|
|
39
|
+
entries(): IterableIterator<[string, string]>;
|
|
40
|
+
forEach(callbackFn: (value: string, key: string, parent: HttpHeaders) => void, thisArg?: any): void;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves value of a given header at given index
|
|
43
|
+
*/
|
|
44
|
+
get(name: string, index?: number): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves an array of values for a given header.
|
|
47
|
+
*/
|
|
48
|
+
getAll(name: string): string[] | null;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the names of the headers.
|
|
51
|
+
*/
|
|
52
|
+
keys(): IterableIterator<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Checks for existence of a given header.
|
|
55
|
+
*/
|
|
56
|
+
has(name: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Sets or modifies a value for a given header.
|
|
59
|
+
* If the header already exists, its value is replaced with the given value
|
|
60
|
+
*/
|
|
61
|
+
set(name: string, value: HeaderValueType | HeaderValueType[]): this;
|
|
62
|
+
sort(compareFn?: (a: string, b: string) => number): this;
|
|
63
|
+
protected _append(name: string, value: HeaderValueType | HeaderValueType[]): void;
|
|
64
|
+
protected _delete(name: string, value?: HeaderValueType | HeaderValueType[]): boolean;
|
|
65
|
+
protected _set(name: string, value: string | string[]): void;
|
|
66
|
+
[nodeInspectCustom](): ResponsiveMap<string, string[]>;
|
|
67
|
+
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
68
|
+
get [Symbol.toStringTag](): string;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import { ResponsiveMap } from '../helpers/responsive-map.js';
|
|
3
|
+
import { HttpHeaderCodes } from './enums/http-headers-codes.enum.js';
|
|
4
|
+
const knownKeys = Object.keys(HttpHeaderCodes);
|
|
5
|
+
const knownKeysLower = knownKeys.map(x => x.toLowerCase());
|
|
6
|
+
const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
7
|
+
const kEntries = Symbol('kEntries');
|
|
8
|
+
const kSize = Symbol('kSize');
|
|
9
|
+
const kOptions = Symbol('kOptions');
|
|
10
|
+
export class HttpHeaders {
|
|
11
|
+
constructor(init, options) {
|
|
12
|
+
this[_a] = new ResponsiveMap();
|
|
13
|
+
this[_b] = 0;
|
|
14
|
+
this[kOptions] = { ...options, onChange: undefined };
|
|
15
|
+
if (init)
|
|
16
|
+
this.appendAll(init);
|
|
17
|
+
this[kOptions].onChange = options?.onChange;
|
|
18
|
+
}
|
|
19
|
+
get size() {
|
|
20
|
+
return this[kSize];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Appends a new value to the existing set of values for a header
|
|
24
|
+
* and returns this instance
|
|
25
|
+
*/
|
|
26
|
+
append(name, value) {
|
|
27
|
+
this._append(name, value);
|
|
28
|
+
this.changed();
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Appends multiple values to the existing set of values for a header
|
|
33
|
+
* and returns this instance
|
|
34
|
+
*/
|
|
35
|
+
appendAll(headers) {
|
|
36
|
+
if (typeof headers === 'string') {
|
|
37
|
+
headers.split('\n').forEach(line => {
|
|
38
|
+
const index = line.indexOf(':');
|
|
39
|
+
if (index > 0) {
|
|
40
|
+
const name = line.slice(0, index);
|
|
41
|
+
const value = line.slice(index + 1).trim();
|
|
42
|
+
this._append(name, value);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else if (headers.forEach && typeof headers.forEach === 'function')
|
|
47
|
+
headers.forEach((value, name) => this._append(name, value));
|
|
48
|
+
else
|
|
49
|
+
Object.keys(headers).forEach(name => this._append(name, headers[name]));
|
|
50
|
+
this.changed();
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
changed() {
|
|
54
|
+
if (this[kOptions].onChange)
|
|
55
|
+
this[kOptions].onChange();
|
|
56
|
+
}
|
|
57
|
+
clear() {
|
|
58
|
+
if (this[kEntries].size) {
|
|
59
|
+
this[kEntries].clear();
|
|
60
|
+
this[kSize] = 0;
|
|
61
|
+
this.changed();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Deletes values for a given header
|
|
66
|
+
*/
|
|
67
|
+
delete(name, value) {
|
|
68
|
+
if (this._delete(name, value))
|
|
69
|
+
this.changed();
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns an iterable of key, value pairs for every entry in the map.
|
|
74
|
+
*/
|
|
75
|
+
entries() {
|
|
76
|
+
const iter = this[kEntries].entries();
|
|
77
|
+
let i = 0;
|
|
78
|
+
let key;
|
|
79
|
+
let values;
|
|
80
|
+
return {
|
|
81
|
+
[Symbol.iterator]() {
|
|
82
|
+
return this;
|
|
83
|
+
},
|
|
84
|
+
next() {
|
|
85
|
+
if (values) {
|
|
86
|
+
if (i >= values.length) {
|
|
87
|
+
values = undefined;
|
|
88
|
+
i = 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!values) {
|
|
92
|
+
const n = iter.next();
|
|
93
|
+
if (n.done)
|
|
94
|
+
return { done: true, value: undefined };
|
|
95
|
+
key = n.value[0];
|
|
96
|
+
values = n.value[1];
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
done: false,
|
|
100
|
+
value: [key, values[i++]]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
forEach(callbackFn, thisArg) {
|
|
106
|
+
const iterator = this.entries();
|
|
107
|
+
let entry = iterator.next();
|
|
108
|
+
while (!entry.done) {
|
|
109
|
+
callbackFn.call(thisArg || this, entry.value[1], entry.value[0], this);
|
|
110
|
+
entry = iterator.next();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Retrieves value of a given header at given index
|
|
115
|
+
*/
|
|
116
|
+
get(name, index = 0) {
|
|
117
|
+
const values = this[kEntries].get(name.toLowerCase());
|
|
118
|
+
return values && values.length > index ? values[index] : null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves an array of values for a given header.
|
|
122
|
+
*/
|
|
123
|
+
getAll(name) {
|
|
124
|
+
const entry = this[kEntries].get(name);
|
|
125
|
+
return entry ? entry.slice(0) : null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Retrieves the names of the headers.
|
|
129
|
+
*/
|
|
130
|
+
keys() {
|
|
131
|
+
return this[kEntries].keys();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Checks for existence of a given header.
|
|
135
|
+
*/
|
|
136
|
+
has(name) {
|
|
137
|
+
return this[kEntries].has(name);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Sets or modifies a value for a given header.
|
|
141
|
+
* If the header already exists, its value is replaced with the given value
|
|
142
|
+
*/
|
|
143
|
+
set(name, value) {
|
|
144
|
+
this._set(name, String(value));
|
|
145
|
+
this.changed();
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
sort(compareFn) {
|
|
149
|
+
this[kEntries].sort(compareFn);
|
|
150
|
+
this.changed();
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
_append(name, value) {
|
|
154
|
+
const i = knownKeysLower.indexOf(name);
|
|
155
|
+
const normalizedName = knownKeys[i] || name;
|
|
156
|
+
let values = this[kEntries].get(normalizedName);
|
|
157
|
+
if (!values) {
|
|
158
|
+
values = [];
|
|
159
|
+
this[kEntries].set(normalizedName, values);
|
|
160
|
+
}
|
|
161
|
+
const oldSize = values.length;
|
|
162
|
+
if (Array.isArray(value))
|
|
163
|
+
values.push(...value.map(x => String(x)));
|
|
164
|
+
else
|
|
165
|
+
values.push(String(value));
|
|
166
|
+
this[kSize] = -oldSize + values.length;
|
|
167
|
+
}
|
|
168
|
+
_delete(name, value) {
|
|
169
|
+
const oldValues = this[kEntries].get(name);
|
|
170
|
+
if (!oldValues)
|
|
171
|
+
return false;
|
|
172
|
+
const oldSize = this[kSize];
|
|
173
|
+
if (value) {
|
|
174
|
+
const valueToDelete = Array.isArray(value) ? value.map(x => String(x)) : [String(value)];
|
|
175
|
+
const newValues = oldValues.filter(x => !valueToDelete.includes(x));
|
|
176
|
+
this[kEntries].set(name, newValues);
|
|
177
|
+
this[kSize] += -oldValues.length + newValues.length;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
this[kEntries].delete(name);
|
|
181
|
+
this[kSize] -= oldValues.length;
|
|
182
|
+
}
|
|
183
|
+
return oldSize !== this[kSize];
|
|
184
|
+
}
|
|
185
|
+
_set(name, value) {
|
|
186
|
+
if (value == null) {
|
|
187
|
+
this._delete(name);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const oldValues = this[kEntries].get(name);
|
|
191
|
+
const i = knownKeysLower.indexOf(name);
|
|
192
|
+
const normalizedName = knownKeys[i] || name;
|
|
193
|
+
const newValues = Array.isArray(value) ? value : [value];
|
|
194
|
+
this[kEntries].set(normalizedName, newValues);
|
|
195
|
+
this[kSize] += -(oldValues?.length || 0) + newValues.length;
|
|
196
|
+
}
|
|
197
|
+
[(_a = kEntries, _b = kSize, nodeInspectCustom)]() {
|
|
198
|
+
return this[kEntries];
|
|
199
|
+
}
|
|
200
|
+
[Symbol.iterator]() {
|
|
201
|
+
return this.entries();
|
|
202
|
+
}
|
|
203
|
+
get [Symbol.toStringTag]() {
|
|
204
|
+
return 'HttpHeaders';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
HttpHeaders.kEntries = kEntries;
|
|
208
|
+
HttpHeaders.kSize = kSize;
|
|
209
|
+
HttpHeaders.kOptions = kOptions;
|