@gatling.io/http 3.11.7 → 3.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/jest.config.js +5 -0
- package/package.json +4 -4
- package/src/bodyPart.ts +590 -0
- package/src/checks.ts +142 -0
- package/src/cookies.ts +227 -0
- package/src/feeders.ts +13 -0
- package/src/headers.ts +32 -0
- package/src/index.test.ts +425 -0
- package/src/index.ts +242 -0
- package/src/method.ts +65 -0
- package/src/polling.ts +59 -0
- package/src/protocol.ts +966 -0
- package/src/proxy.ts +61 -0
- package/src/request/body.ts +12 -0
- package/src/request/index.ts +837 -0
- package/src/request/request.ts +36 -0
- package/src/response/body.ts +19 -0
- package/src/response/index.ts +61 -0
- package/src/response/status.ts +428 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Wrapper } from "@gatling.io/core";
|
|
2
|
+
|
|
3
|
+
import { HttpHeaders, wrapHttpHeaders } from "../headers";
|
|
4
|
+
import { RequestBody, wrapRequestBody } from "./body";
|
|
5
|
+
|
|
6
|
+
import JvmRequest = io.gatling.http.client.Request;
|
|
7
|
+
|
|
8
|
+
export interface Request extends Wrapper<JvmRequest> {
|
|
9
|
+
//copyWithCopiedHeaders(): Request;
|
|
10
|
+
//copyWithHttp2PriorKnowledge(arg0: any /*io.gatling.http.client.Http2PriorKnowledge*/): Request;
|
|
11
|
+
//copyWithNewBody(arg0: io.gatling.http.client.body.RequestBody): Request;
|
|
12
|
+
//copyWithNewUri(arg0: any /*io.gatling.http.client.uri.Uri*/): Request;
|
|
13
|
+
body(): RequestBody;
|
|
14
|
+
//getCookies(): java.util.List<any /*io.netty.handler.codec.http.cookie.Cookie*/>;
|
|
15
|
+
headers(): HttpHeaders;
|
|
16
|
+
//getHttp2PriorKnowledge(): any /*io.gatling.http.client.Http2PriorKnowledge*/;
|
|
17
|
+
//getLocalAddresses(): any /*io.gatling.http.client.LocalAddresses*/;
|
|
18
|
+
//getMethod(): any /*io.netty.handler.codec.http.HttpMethod*/;
|
|
19
|
+
//getName(): string;
|
|
20
|
+
//getNameResolver(): any /*io.gatling.http.client.resolver.InetAddressNameResolver*/;
|
|
21
|
+
//getProxyServer(): any /*io.gatling.http.client.proxy.ProxyServer*/;
|
|
22
|
+
//getRealm(): any /*io.gatling.http.client.realm.Realm*/;
|
|
23
|
+
//getRequestTimeout(): long;
|
|
24
|
+
//getSignatureCalculator(): Func<Request, Request>;
|
|
25
|
+
//getUri(): any /*io.gatling.http.client.uri.Uri*/;
|
|
26
|
+
//getVirtualHost(): string;
|
|
27
|
+
//getWsSubprotocol(): string;
|
|
28
|
+
//isAutoOrigin(): boolean;
|
|
29
|
+
//isHttp2Enabled(): boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const wrapRequest = (_underlying: JvmRequest): Request => ({
|
|
33
|
+
_underlying,
|
|
34
|
+
body: (): RequestBody => wrapRequestBody(_underlying.getBody()),
|
|
35
|
+
headers: (): HttpHeaders => wrapHttpHeaders(_underlying.getHeaders())
|
|
36
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Wrapper } from "@gatling.io/core";
|
|
2
|
+
|
|
3
|
+
import JvmResponseBody = io.gatling.http.response.ResponseBody;
|
|
4
|
+
|
|
5
|
+
export interface ResponseBody extends Wrapper<JvmResponseBody> {
|
|
6
|
+
bytes(): number[];
|
|
7
|
+
chars(): string[];
|
|
8
|
+
// TODO charset(): any /*java.nio.charset.Charset*/;
|
|
9
|
+
length(): number;
|
|
10
|
+
string(): string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const wrapResponseBody = (_underlying: JvmResponseBody): ResponseBody => ({
|
|
14
|
+
_underlying,
|
|
15
|
+
bytes: (): number[] => _underlying.bytes(),
|
|
16
|
+
chars: (): string[] => _underlying.chars(),
|
|
17
|
+
length: (): number => _underlying.length(),
|
|
18
|
+
string: (): string => _underlying.string()
|
|
19
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Wrapper } from "@gatling.io/core";
|
|
2
|
+
|
|
3
|
+
import { HttpHeaders, wrapHttpHeaders } from "../headers";
|
|
4
|
+
import { ResponseBody, wrapResponseBody } from "./body";
|
|
5
|
+
import { fromJvmHttpResponseStatus, HttpResponseStatus } from "./status";
|
|
6
|
+
|
|
7
|
+
import JvmResponse = io.gatling.http.response.Response;
|
|
8
|
+
|
|
9
|
+
export * from "./body";
|
|
10
|
+
export * from "./status";
|
|
11
|
+
|
|
12
|
+
export interface Response extends Wrapper<JvmResponse> {
|
|
13
|
+
body(): ResponseBody;
|
|
14
|
+
//checksum(algorithm: any /*io.gatling.core.check.ChecksumAlgorithm*/): any /*scala.Option*/;
|
|
15
|
+
//checksums(): any /*scala.collection.immutable.Map*/;
|
|
16
|
+
//cookies(): any /*scala.collection.immutable.List*/;
|
|
17
|
+
//copy(
|
|
18
|
+
//request: Request,
|
|
19
|
+
//startTimestamp: number,
|
|
20
|
+
//endTimestamp: number,
|
|
21
|
+
////status: any /*io.netty.handler.codec.http.HttpResponseStatus*/,
|
|
22
|
+
////headers: HttpHeaders,
|
|
23
|
+
////body: any /*io.gatling.http.response.ResponseBody*/,
|
|
24
|
+
////checksums: any /*scala.collection.immutable.Map*/,
|
|
25
|
+
//isHttp2: boolean
|
|
26
|
+
//): Response;
|
|
27
|
+
//endTimestamp(): long;
|
|
28
|
+
//header(name: string): any;
|
|
29
|
+
headers(): HttpHeaders;
|
|
30
|
+
//headers(name: any /*java.lang.CharSequence*/): any /*scala.collection.immutable.Seq*/;
|
|
31
|
+
isHttp2(): boolean;
|
|
32
|
+
isRedirect(): boolean;
|
|
33
|
+
//lastModifiedOrEtag(protocol: any /*io.gatling.http.protocol.HttpProtocol*/): any /*scala.Option*/;
|
|
34
|
+
//request(): io.gatling.http.client.Request;
|
|
35
|
+
//startTimestamp(): long;
|
|
36
|
+
status(): HttpResponseStatus;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const wrapResponse = (_underlying: JvmResponse): Response => ({
|
|
40
|
+
_underlying,
|
|
41
|
+
body: (): ResponseBody => wrapResponseBody(_underlying.body()),
|
|
42
|
+
//copy: (
|
|
43
|
+
// request: Request = wrapRequest(_underlying.request()),
|
|
44
|
+
// startTimestamp: number = _underlying.startTimestamp(),
|
|
45
|
+
// endTimestamp: number = _underlying.endTimestamp(),
|
|
46
|
+
// //status: any /*io.netty.handler.codec.http.HttpResponseStatus*/,
|
|
47
|
+
// //headers: HttpHeaders,
|
|
48
|
+
// //body: any /*io.gatling.http.response.ResponseBody*/,
|
|
49
|
+
// //checksums: any /*scala.collection.immutable.Map*/,
|
|
50
|
+
// isHttp2: boolean = _underlying.isHttp2()
|
|
51
|
+
//): Response => wrapResponse(_underlying.copy(
|
|
52
|
+
// request = request._underlying,
|
|
53
|
+
// startTimestamp = startTimestamp,
|
|
54
|
+
// endTimestamp = endTimestamp,
|
|
55
|
+
// isHttp2
|
|
56
|
+
//)),
|
|
57
|
+
headers: (): HttpHeaders => wrapHttpHeaders(_underlying.headers()),
|
|
58
|
+
isHttp2: (): boolean => _underlying.isHttp2(),
|
|
59
|
+
isRedirect: (): boolean => _underlying.isRedirect(),
|
|
60
|
+
status: (): HttpResponseStatus => fromJvmHttpResponseStatus(_underlying.status())
|
|
61
|
+
});
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
export class HttpResponseStatus {
|
|
2
|
+
/**
|
|
3
|
+
* 100 Continue
|
|
4
|
+
*/
|
|
5
|
+
public static readonly CONTINUE = new HttpResponseStatus(100, "Continue");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 101 Switching Protocols
|
|
9
|
+
*/
|
|
10
|
+
public static readonly SWITCHING_PROTOCOLS = new HttpResponseStatus(101, "Switching Protocols");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 102 Processing (WebDAV, RFC2518)
|
|
14
|
+
*/
|
|
15
|
+
public static readonly PROCESSING = new HttpResponseStatus(102, "Processing");
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 103 Early Hints (RFC 8297)
|
|
19
|
+
*/
|
|
20
|
+
public static readonly EARLY_HINTS = new HttpResponseStatus(103, "Early Hints");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 200 OK
|
|
24
|
+
*/
|
|
25
|
+
public static readonly OK = new HttpResponseStatus(200, "OK");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 201 Created
|
|
29
|
+
*/
|
|
30
|
+
public static readonly CREATED = new HttpResponseStatus(201, "Created");
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 202 Accepted
|
|
34
|
+
*/
|
|
35
|
+
public static readonly ACCEPTED = new HttpResponseStatus(202, "Accepted");
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 203 Non-Authoritative Information (since HTTP/1.1)
|
|
39
|
+
*/
|
|
40
|
+
public static readonly NON_AUTHORITATIVE_INFORMATION = new HttpResponseStatus(203, "Non-Authoritative Information");
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 204 No Content
|
|
44
|
+
*/
|
|
45
|
+
public static readonly NO_CONTENT = new HttpResponseStatus(204, "No Content");
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 205 Reset Content
|
|
49
|
+
*/
|
|
50
|
+
public static readonly RESET_CONTENT = new HttpResponseStatus(205, "Reset Content");
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 206 Partial Content
|
|
54
|
+
*/
|
|
55
|
+
public static readonly PARTIAL_CONTENT = new HttpResponseStatus(206, "Partial Content");
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 207 Multi-Status (WebDAV, RFC2518)
|
|
59
|
+
*/
|
|
60
|
+
public static readonly MULTI_STATUS = new HttpResponseStatus(207, "Multi-Status");
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 300 Multiple Choices
|
|
64
|
+
*/
|
|
65
|
+
public static readonly MULTIPLE_CHOICES = new HttpResponseStatus(300, "Multiple Choices");
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 301 Moved Permanently
|
|
69
|
+
*/
|
|
70
|
+
public static readonly MOVED_PERMANENTLY = new HttpResponseStatus(301, "Moved Permanently");
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 302 Found
|
|
74
|
+
*/
|
|
75
|
+
public static readonly FOUND = new HttpResponseStatus(302, "Found");
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 303 See Other (since HTTP/1.1)
|
|
79
|
+
*/
|
|
80
|
+
public static readonly SEE_OTHER = new HttpResponseStatus(303, "See Other");
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 304 Not Modified
|
|
84
|
+
*/
|
|
85
|
+
public static readonly NOT_MODIFIED = new HttpResponseStatus(304, "Not Modified");
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 305 Use Proxy (since HTTP/1.1)
|
|
89
|
+
*/
|
|
90
|
+
public static readonly USE_PROXY = new HttpResponseStatus(305, "Use Proxy");
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 307 Temporary Redirect (since HTTP/1.1)
|
|
94
|
+
*/
|
|
95
|
+
public static readonly TEMPORARY_REDIRECT = new HttpResponseStatus(307, "Temporary Redirect");
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 308 Permanent Redirect (RFC7538)
|
|
99
|
+
*/
|
|
100
|
+
public static readonly PERMANENT_REDIRECT = new HttpResponseStatus(308, "Permanent Redirect");
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 400 Bad Request
|
|
104
|
+
*/
|
|
105
|
+
public static readonly BAD_REQUEST = new HttpResponseStatus(400, "Bad Request");
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 401 Unauthorized
|
|
109
|
+
*/
|
|
110
|
+
public static readonly UNAUTHORIZED = new HttpResponseStatus(401, "Unauthorized");
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 402 Payment Required
|
|
114
|
+
*/
|
|
115
|
+
public static readonly PAYMENT_REQUIRED = new HttpResponseStatus(402, "Payment Required");
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 403 Forbidden
|
|
119
|
+
*/
|
|
120
|
+
public static readonly FORBIDDEN = new HttpResponseStatus(403, "Forbidden");
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 404 Not Found
|
|
124
|
+
*/
|
|
125
|
+
public static readonly NOT_FOUND = new HttpResponseStatus(404, "Not Found");
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 405 Method Not Allowed
|
|
129
|
+
*/
|
|
130
|
+
public static readonly METHOD_NOT_ALLOWED = new HttpResponseStatus(405, "Method Not Allowed");
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 406 Not Acceptable
|
|
134
|
+
*/
|
|
135
|
+
public static readonly NOT_ACCEPTABLE = new HttpResponseStatus(406, "Not Acceptable");
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 407 Proxy Authentication Required
|
|
139
|
+
*/
|
|
140
|
+
public static readonly PROXY_AUTHENTICATION_REQUIRED = new HttpResponseStatus(407, "Proxy Authentication Required");
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 408 Request Timeout
|
|
144
|
+
*/
|
|
145
|
+
public static readonly REQUEST_TIMEOUT = new HttpResponseStatus(408, "Request Timeout");
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 409 Conflict
|
|
149
|
+
*/
|
|
150
|
+
public static readonly CONFLICT = new HttpResponseStatus(409, "Conflict");
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 410 Gone
|
|
154
|
+
*/
|
|
155
|
+
public static readonly GONE = new HttpResponseStatus(410, "Gone");
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 411 Length Required
|
|
159
|
+
*/
|
|
160
|
+
public static readonly LENGTH_REQUIRED = new HttpResponseStatus(411, "Length Required");
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 412 Precondition Failed
|
|
164
|
+
*/
|
|
165
|
+
public static readonly PRECONDITION_FAILED = new HttpResponseStatus(412, "Precondition Failed");
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 413 Request Entity Too Large
|
|
169
|
+
*/
|
|
170
|
+
public static readonly REQUEST_ENTITY_TOO_LARGE = new HttpResponseStatus(413, "Request Entity Too Large");
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 414 Request-URI Too Long
|
|
174
|
+
*/
|
|
175
|
+
public static readonly REQUEST_URI_TOO_LONG = new HttpResponseStatus(414, "Request-URI Too Long");
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 415 Unsupported Media Type
|
|
179
|
+
*/
|
|
180
|
+
public static readonly UNSUPPORTED_MEDIA_TYPE = new HttpResponseStatus(415, "Unsupported Media Type");
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 416 Requested Range Not Satisfiable
|
|
184
|
+
*/
|
|
185
|
+
public static readonly REQUESTED_RANGE_NOT_SATISFIABLE = new HttpResponseStatus(
|
|
186
|
+
416,
|
|
187
|
+
"Requested Range Not Satisfiable"
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 417 Expectation Failed
|
|
192
|
+
*/
|
|
193
|
+
public static readonly EXPECTATION_FAILED = new HttpResponseStatus(417, "Expectation Failed");
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 421 Misdirected Request
|
|
197
|
+
*
|
|
198
|
+
* @see <a href="https://tools.ietf.org/html/rfc7540#section-9.1.2">421 (Misdirected Request) Status Code</a>
|
|
199
|
+
*/
|
|
200
|
+
public static readonly MISDIRECTED_REQUEST = new HttpResponseStatus(421, "Misdirected Request");
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 422 Unprocessable Entity (WebDAV, RFC4918)
|
|
204
|
+
*/
|
|
205
|
+
public static readonly UNPROCESSABLE_ENTITY = new HttpResponseStatus(422, "Unprocessable Entity");
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 423 Locked (WebDAV, RFC4918)
|
|
209
|
+
*/
|
|
210
|
+
public static readonly LOCKED = new HttpResponseStatus(423, "Locked");
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 424 Failed Dependency (WebDAV, RFC4918)
|
|
214
|
+
*/
|
|
215
|
+
public static readonly FAILED_DEPENDENCY = new HttpResponseStatus(424, "Failed Dependency");
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 425 Unordered Collection (WebDAV, RFC3648)
|
|
219
|
+
*/
|
|
220
|
+
public static readonly UNORDERED_COLLECTION = new HttpResponseStatus(425, "Unordered Collection");
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 426 Upgrade Required (RFC2817)
|
|
224
|
+
*/
|
|
225
|
+
public static readonly UPGRADE_REQUIRED = new HttpResponseStatus(426, "Upgrade Required");
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 428 Precondition Required (RFC6585)
|
|
229
|
+
*/
|
|
230
|
+
public static readonly PRECONDITION_REQUIRED = new HttpResponseStatus(428, "Precondition Required");
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 429 Too Many Requests (RFC6585)
|
|
234
|
+
*/
|
|
235
|
+
public static readonly TOO_MANY_REQUESTS = new HttpResponseStatus(429, "Too Many Requests");
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 431 Request Header Fields Too Large (RFC6585)
|
|
239
|
+
*/
|
|
240
|
+
public static readonly REQUEST_HEADER_FIELDS_TOO_LARGE = new HttpResponseStatus(
|
|
241
|
+
431,
|
|
242
|
+
"Request Header Fields Too Large"
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 500 Internal Server Error
|
|
247
|
+
*/
|
|
248
|
+
public static readonly INTERNAL_SERVER_ERROR = new HttpResponseStatus(500, "Internal Server Error");
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 501 Not Implemented
|
|
252
|
+
*/
|
|
253
|
+
public static readonly NOT_IMPLEMENTED = new HttpResponseStatus(501, "Not Implemented");
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 502 Bad Gateway
|
|
257
|
+
*/
|
|
258
|
+
public static readonly BAD_GATEWAY = new HttpResponseStatus(502, "Bad Gateway");
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 503 Service Unavailable
|
|
262
|
+
*/
|
|
263
|
+
public static readonly SERVICE_UNAVAILABLE = new HttpResponseStatus(503, "Service Unavailable");
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 504 Gateway Timeout
|
|
267
|
+
*/
|
|
268
|
+
public static readonly GATEWAY_TIMEOUT = new HttpResponseStatus(504, "Gateway Timeout");
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 505 HTTP Version Not Supported
|
|
272
|
+
*/
|
|
273
|
+
public static readonly HTTP_VERSION_NOT_SUPPORTED = new HttpResponseStatus(505, "HTTP Version Not Supported");
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* 506 Variant Also Negotiates (RFC2295)
|
|
277
|
+
*/
|
|
278
|
+
public static readonly VARIANT_ALSO_NEGOTIATES = new HttpResponseStatus(506, "Variant Also Negotiates");
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 507 Insufficient Storage (WebDAV, RFC4918)
|
|
282
|
+
*/
|
|
283
|
+
public static readonly INSUFFICIENT_STORAGE = new HttpResponseStatus(507, "Insufficient Storage");
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 510 Not Extended (RFC2774)
|
|
287
|
+
*/
|
|
288
|
+
public static readonly NOT_EXTENDED = new HttpResponseStatus(510, "Not Extended");
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 511 Network Authentication Required (RFC6585)
|
|
292
|
+
*/
|
|
293
|
+
public static readonly NETWORK_AUTHENTICATION_REQUIRED = new HttpResponseStatus(
|
|
294
|
+
511,
|
|
295
|
+
"Network Authentication Required"
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
private constructor(
|
|
299
|
+
public readonly code: number,
|
|
300
|
+
public readonly reasonPhrase: string
|
|
301
|
+
) {
|
|
302
|
+
// Do nothing.
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export const fromJvmHttpResponseStatus = (
|
|
307
|
+
jvmStatus: io.netty.handler.codec.http.HttpResponseStatus
|
|
308
|
+
): HttpResponseStatus => {
|
|
309
|
+
switch (jvmStatus.code()) {
|
|
310
|
+
case 100:
|
|
311
|
+
return HttpResponseStatus.CONTINUE;
|
|
312
|
+
case 101:
|
|
313
|
+
return HttpResponseStatus.SWITCHING_PROTOCOLS;
|
|
314
|
+
case 102:
|
|
315
|
+
return HttpResponseStatus.PROCESSING;
|
|
316
|
+
case 103:
|
|
317
|
+
return HttpResponseStatus.EARLY_HINTS;
|
|
318
|
+
case 200:
|
|
319
|
+
return HttpResponseStatus.OK;
|
|
320
|
+
case 201:
|
|
321
|
+
return HttpResponseStatus.CREATED;
|
|
322
|
+
case 202:
|
|
323
|
+
return HttpResponseStatus.ACCEPTED;
|
|
324
|
+
case 203:
|
|
325
|
+
return HttpResponseStatus.NON_AUTHORITATIVE_INFORMATION;
|
|
326
|
+
case 204:
|
|
327
|
+
return HttpResponseStatus.NO_CONTENT;
|
|
328
|
+
case 205:
|
|
329
|
+
return HttpResponseStatus.RESET_CONTENT;
|
|
330
|
+
case 206:
|
|
331
|
+
return HttpResponseStatus.PARTIAL_CONTENT;
|
|
332
|
+
case 207:
|
|
333
|
+
return HttpResponseStatus.MULTI_STATUS;
|
|
334
|
+
case 300:
|
|
335
|
+
return HttpResponseStatus.MULTIPLE_CHOICES;
|
|
336
|
+
case 301:
|
|
337
|
+
return HttpResponseStatus.MOVED_PERMANENTLY;
|
|
338
|
+
case 302:
|
|
339
|
+
return HttpResponseStatus.FOUND;
|
|
340
|
+
case 303:
|
|
341
|
+
return HttpResponseStatus.SEE_OTHER;
|
|
342
|
+
case 304:
|
|
343
|
+
return HttpResponseStatus.NOT_MODIFIED;
|
|
344
|
+
case 305:
|
|
345
|
+
return HttpResponseStatus.USE_PROXY;
|
|
346
|
+
case 307:
|
|
347
|
+
return HttpResponseStatus.TEMPORARY_REDIRECT;
|
|
348
|
+
case 308:
|
|
349
|
+
return HttpResponseStatus.PERMANENT_REDIRECT;
|
|
350
|
+
case 400:
|
|
351
|
+
return HttpResponseStatus.BAD_REQUEST;
|
|
352
|
+
case 401:
|
|
353
|
+
return HttpResponseStatus.UNAUTHORIZED;
|
|
354
|
+
case 402:
|
|
355
|
+
return HttpResponseStatus.PAYMENT_REQUIRED;
|
|
356
|
+
case 403:
|
|
357
|
+
return HttpResponseStatus.FORBIDDEN;
|
|
358
|
+
case 404:
|
|
359
|
+
return HttpResponseStatus.NOT_FOUND;
|
|
360
|
+
case 405:
|
|
361
|
+
return HttpResponseStatus.METHOD_NOT_ALLOWED;
|
|
362
|
+
case 406:
|
|
363
|
+
return HttpResponseStatus.NOT_ACCEPTABLE;
|
|
364
|
+
case 407:
|
|
365
|
+
return HttpResponseStatus.PROXY_AUTHENTICATION_REQUIRED;
|
|
366
|
+
case 408:
|
|
367
|
+
return HttpResponseStatus.REQUEST_TIMEOUT;
|
|
368
|
+
case 409:
|
|
369
|
+
return HttpResponseStatus.CONFLICT;
|
|
370
|
+
case 410:
|
|
371
|
+
return HttpResponseStatus.GONE;
|
|
372
|
+
case 411:
|
|
373
|
+
return HttpResponseStatus.LENGTH_REQUIRED;
|
|
374
|
+
case 412:
|
|
375
|
+
return HttpResponseStatus.PRECONDITION_FAILED;
|
|
376
|
+
case 413:
|
|
377
|
+
return HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE;
|
|
378
|
+
case 414:
|
|
379
|
+
return HttpResponseStatus.REQUEST_URI_TOO_LONG;
|
|
380
|
+
case 415:
|
|
381
|
+
return HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE;
|
|
382
|
+
case 416:
|
|
383
|
+
return HttpResponseStatus.REQUESTED_RANGE_NOT_SATISFIABLE;
|
|
384
|
+
case 417:
|
|
385
|
+
return HttpResponseStatus.EXPECTATION_FAILED;
|
|
386
|
+
case 421:
|
|
387
|
+
return HttpResponseStatus.MISDIRECTED_REQUEST;
|
|
388
|
+
case 422:
|
|
389
|
+
return HttpResponseStatus.UNPROCESSABLE_ENTITY;
|
|
390
|
+
case 423:
|
|
391
|
+
return HttpResponseStatus.LOCKED;
|
|
392
|
+
case 424:
|
|
393
|
+
return HttpResponseStatus.FAILED_DEPENDENCY;
|
|
394
|
+
case 425:
|
|
395
|
+
return HttpResponseStatus.UNORDERED_COLLECTION;
|
|
396
|
+
case 426:
|
|
397
|
+
return HttpResponseStatus.UPGRADE_REQUIRED;
|
|
398
|
+
case 428:
|
|
399
|
+
return HttpResponseStatus.PRECONDITION_REQUIRED;
|
|
400
|
+
case 429:
|
|
401
|
+
return HttpResponseStatus.TOO_MANY_REQUESTS;
|
|
402
|
+
case 431:
|
|
403
|
+
return HttpResponseStatus.REQUEST_HEADER_FIELDS_TOO_LARGE;
|
|
404
|
+
case 500:
|
|
405
|
+
return HttpResponseStatus.INTERNAL_SERVER_ERROR;
|
|
406
|
+
case 501:
|
|
407
|
+
return HttpResponseStatus.NOT_IMPLEMENTED;
|
|
408
|
+
case 502:
|
|
409
|
+
return HttpResponseStatus.BAD_GATEWAY;
|
|
410
|
+
case 503:
|
|
411
|
+
return HttpResponseStatus.SERVICE_UNAVAILABLE;
|
|
412
|
+
case 504:
|
|
413
|
+
return HttpResponseStatus.GATEWAY_TIMEOUT;
|
|
414
|
+
case 505:
|
|
415
|
+
return HttpResponseStatus.HTTP_VERSION_NOT_SUPPORTED;
|
|
416
|
+
case 506:
|
|
417
|
+
return HttpResponseStatus.VARIANT_ALSO_NEGOTIATES;
|
|
418
|
+
case 507:
|
|
419
|
+
return HttpResponseStatus.INSUFFICIENT_STORAGE;
|
|
420
|
+
case 510:
|
|
421
|
+
return HttpResponseStatus.NOT_EXTENDED;
|
|
422
|
+
case 511:
|
|
423
|
+
return HttpResponseStatus.NETWORK_AUTHENTICATION_REQUIRED;
|
|
424
|
+
}
|
|
425
|
+
throw Error(
|
|
426
|
+
"This shouldn't happen unless we lag behind the original implementation, call support if this ever happens."
|
|
427
|
+
);
|
|
428
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": "./",
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"outDir": "target",
|
|
6
|
+
"lib": ["es2021"],
|
|
7
|
+
"target": "es2021",
|
|
8
|
+
"module": "node16",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"moduleResolution": "node16",
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"resolveJsonModule": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*.ts"],
|
|
17
|
+
"exclude": ["**/*.test.ts", "jest.config.ts"]
|
|
18
|
+
}
|