@gatling.io/http 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,361 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromJvmHttpResponseStatus = exports.HttpResponseStatus = void 0;
4
+ class HttpResponseStatus {
5
+ constructor(code, reasonPhrase) {
6
+ this.code = code;
7
+ this.reasonPhrase = reasonPhrase;
8
+ // Do nothing.
9
+ }
10
+ }
11
+ exports.HttpResponseStatus = HttpResponseStatus;
12
+ /**
13
+ * 100 Continue
14
+ */
15
+ HttpResponseStatus.CONTINUE = new HttpResponseStatus(100, "Continue");
16
+ /**
17
+ * 101 Switching Protocols
18
+ */
19
+ HttpResponseStatus.SWITCHING_PROTOCOLS = new HttpResponseStatus(101, "Switching Protocols");
20
+ /**
21
+ * 102 Processing (WebDAV, RFC2518)
22
+ */
23
+ HttpResponseStatus.PROCESSING = new HttpResponseStatus(102, "Processing");
24
+ /**
25
+ * 103 Early Hints (RFC 8297)
26
+ */
27
+ HttpResponseStatus.EARLY_HINTS = new HttpResponseStatus(103, "Early Hints");
28
+ /**
29
+ * 200 OK
30
+ */
31
+ HttpResponseStatus.OK = new HttpResponseStatus(200, "OK");
32
+ /**
33
+ * 201 Created
34
+ */
35
+ HttpResponseStatus.CREATED = new HttpResponseStatus(201, "Created");
36
+ /**
37
+ * 202 Accepted
38
+ */
39
+ HttpResponseStatus.ACCEPTED = new HttpResponseStatus(202, "Accepted");
40
+ /**
41
+ * 203 Non-Authoritative Information (since HTTP/1.1)
42
+ */
43
+ HttpResponseStatus.NON_AUTHORITATIVE_INFORMATION = new HttpResponseStatus(203, "Non-Authoritative Information");
44
+ /**
45
+ * 204 No Content
46
+ */
47
+ HttpResponseStatus.NO_CONTENT = new HttpResponseStatus(204, "No Content");
48
+ /**
49
+ * 205 Reset Content
50
+ */
51
+ HttpResponseStatus.RESET_CONTENT = new HttpResponseStatus(205, "Reset Content");
52
+ /**
53
+ * 206 Partial Content
54
+ */
55
+ HttpResponseStatus.PARTIAL_CONTENT = new HttpResponseStatus(206, "Partial Content");
56
+ /**
57
+ * 207 Multi-Status (WebDAV, RFC2518)
58
+ */
59
+ HttpResponseStatus.MULTI_STATUS = new HttpResponseStatus(207, "Multi-Status");
60
+ /**
61
+ * 300 Multiple Choices
62
+ */
63
+ HttpResponseStatus.MULTIPLE_CHOICES = new HttpResponseStatus(300, "Multiple Choices");
64
+ /**
65
+ * 301 Moved Permanently
66
+ */
67
+ HttpResponseStatus.MOVED_PERMANENTLY = new HttpResponseStatus(301, "Moved Permanently");
68
+ /**
69
+ * 302 Found
70
+ */
71
+ HttpResponseStatus.FOUND = new HttpResponseStatus(302, "Found");
72
+ /**
73
+ * 303 See Other (since HTTP/1.1)
74
+ */
75
+ HttpResponseStatus.SEE_OTHER = new HttpResponseStatus(303, "See Other");
76
+ /**
77
+ * 304 Not Modified
78
+ */
79
+ HttpResponseStatus.NOT_MODIFIED = new HttpResponseStatus(304, "Not Modified");
80
+ /**
81
+ * 305 Use Proxy (since HTTP/1.1)
82
+ */
83
+ HttpResponseStatus.USE_PROXY = new HttpResponseStatus(305, "Use Proxy");
84
+ /**
85
+ * 307 Temporary Redirect (since HTTP/1.1)
86
+ */
87
+ HttpResponseStatus.TEMPORARY_REDIRECT = new HttpResponseStatus(307, "Temporary Redirect");
88
+ /**
89
+ * 308 Permanent Redirect (RFC7538)
90
+ */
91
+ HttpResponseStatus.PERMANENT_REDIRECT = new HttpResponseStatus(308, "Permanent Redirect");
92
+ /**
93
+ * 400 Bad Request
94
+ */
95
+ HttpResponseStatus.BAD_REQUEST = new HttpResponseStatus(400, "Bad Request");
96
+ /**
97
+ * 401 Unauthorized
98
+ */
99
+ HttpResponseStatus.UNAUTHORIZED = new HttpResponseStatus(401, "Unauthorized");
100
+ /**
101
+ * 402 Payment Required
102
+ */
103
+ HttpResponseStatus.PAYMENT_REQUIRED = new HttpResponseStatus(402, "Payment Required");
104
+ /**
105
+ * 403 Forbidden
106
+ */
107
+ HttpResponseStatus.FORBIDDEN = new HttpResponseStatus(403, "Forbidden");
108
+ /**
109
+ * 404 Not Found
110
+ */
111
+ HttpResponseStatus.NOT_FOUND = new HttpResponseStatus(404, "Not Found");
112
+ /**
113
+ * 405 Method Not Allowed
114
+ */
115
+ HttpResponseStatus.METHOD_NOT_ALLOWED = new HttpResponseStatus(405, "Method Not Allowed");
116
+ /**
117
+ * 406 Not Acceptable
118
+ */
119
+ HttpResponseStatus.NOT_ACCEPTABLE = new HttpResponseStatus(406, "Not Acceptable");
120
+ /**
121
+ * 407 Proxy Authentication Required
122
+ */
123
+ HttpResponseStatus.PROXY_AUTHENTICATION_REQUIRED = new HttpResponseStatus(407, "Proxy Authentication Required");
124
+ /**
125
+ * 408 Request Timeout
126
+ */
127
+ HttpResponseStatus.REQUEST_TIMEOUT = new HttpResponseStatus(408, "Request Timeout");
128
+ /**
129
+ * 409 Conflict
130
+ */
131
+ HttpResponseStatus.CONFLICT = new HttpResponseStatus(409, "Conflict");
132
+ /**
133
+ * 410 Gone
134
+ */
135
+ HttpResponseStatus.GONE = new HttpResponseStatus(410, "Gone");
136
+ /**
137
+ * 411 Length Required
138
+ */
139
+ HttpResponseStatus.LENGTH_REQUIRED = new HttpResponseStatus(411, "Length Required");
140
+ /**
141
+ * 412 Precondition Failed
142
+ */
143
+ HttpResponseStatus.PRECONDITION_FAILED = new HttpResponseStatus(412, "Precondition Failed");
144
+ /**
145
+ * 413 Request Entity Too Large
146
+ */
147
+ HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE = new HttpResponseStatus(413, "Request Entity Too Large");
148
+ /**
149
+ * 414 Request-URI Too Long
150
+ */
151
+ HttpResponseStatus.REQUEST_URI_TOO_LONG = new HttpResponseStatus(414, "Request-URI Too Long");
152
+ /**
153
+ * 415 Unsupported Media Type
154
+ */
155
+ HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE = new HttpResponseStatus(415, "Unsupported Media Type");
156
+ /**
157
+ * 416 Requested Range Not Satisfiable
158
+ */
159
+ HttpResponseStatus.REQUESTED_RANGE_NOT_SATISFIABLE = new HttpResponseStatus(416, "Requested Range Not Satisfiable");
160
+ /**
161
+ * 417 Expectation Failed
162
+ */
163
+ HttpResponseStatus.EXPECTATION_FAILED = new HttpResponseStatus(417, "Expectation Failed");
164
+ /**
165
+ * 421 Misdirected Request
166
+ *
167
+ * @see <a href="https://tools.ietf.org/html/rfc7540#section-9.1.2">421 (Misdirected Request) Status Code</a>
168
+ */
169
+ HttpResponseStatus.MISDIRECTED_REQUEST = new HttpResponseStatus(421, "Misdirected Request");
170
+ /**
171
+ * 422 Unprocessable Entity (WebDAV, RFC4918)
172
+ */
173
+ HttpResponseStatus.UNPROCESSABLE_ENTITY = new HttpResponseStatus(422, "Unprocessable Entity");
174
+ /**
175
+ * 423 Locked (WebDAV, RFC4918)
176
+ */
177
+ HttpResponseStatus.LOCKED = new HttpResponseStatus(423, "Locked");
178
+ /**
179
+ * 424 Failed Dependency (WebDAV, RFC4918)
180
+ */
181
+ HttpResponseStatus.FAILED_DEPENDENCY = new HttpResponseStatus(424, "Failed Dependency");
182
+ /**
183
+ * 425 Unordered Collection (WebDAV, RFC3648)
184
+ */
185
+ HttpResponseStatus.UNORDERED_COLLECTION = new HttpResponseStatus(425, "Unordered Collection");
186
+ /**
187
+ * 426 Upgrade Required (RFC2817)
188
+ */
189
+ HttpResponseStatus.UPGRADE_REQUIRED = new HttpResponseStatus(426, "Upgrade Required");
190
+ /**
191
+ * 428 Precondition Required (RFC6585)
192
+ */
193
+ HttpResponseStatus.PRECONDITION_REQUIRED = new HttpResponseStatus(428, "Precondition Required");
194
+ /**
195
+ * 429 Too Many Requests (RFC6585)
196
+ */
197
+ HttpResponseStatus.TOO_MANY_REQUESTS = new HttpResponseStatus(429, "Too Many Requests");
198
+ /**
199
+ * 431 Request Header Fields Too Large (RFC6585)
200
+ */
201
+ HttpResponseStatus.REQUEST_HEADER_FIELDS_TOO_LARGE = new HttpResponseStatus(431, "Request Header Fields Too Large");
202
+ /**
203
+ * 500 Internal Server Error
204
+ */
205
+ HttpResponseStatus.INTERNAL_SERVER_ERROR = new HttpResponseStatus(500, "Internal Server Error");
206
+ /**
207
+ * 501 Not Implemented
208
+ */
209
+ HttpResponseStatus.NOT_IMPLEMENTED = new HttpResponseStatus(501, "Not Implemented");
210
+ /**
211
+ * 502 Bad Gateway
212
+ */
213
+ HttpResponseStatus.BAD_GATEWAY = new HttpResponseStatus(502, "Bad Gateway");
214
+ /**
215
+ * 503 Service Unavailable
216
+ */
217
+ HttpResponseStatus.SERVICE_UNAVAILABLE = new HttpResponseStatus(503, "Service Unavailable");
218
+ /**
219
+ * 504 Gateway Timeout
220
+ */
221
+ HttpResponseStatus.GATEWAY_TIMEOUT = new HttpResponseStatus(504, "Gateway Timeout");
222
+ /**
223
+ * 505 HTTP Version Not Supported
224
+ */
225
+ HttpResponseStatus.HTTP_VERSION_NOT_SUPPORTED = new HttpResponseStatus(505, "HTTP Version Not Supported");
226
+ /**
227
+ * 506 Variant Also Negotiates (RFC2295)
228
+ */
229
+ HttpResponseStatus.VARIANT_ALSO_NEGOTIATES = new HttpResponseStatus(506, "Variant Also Negotiates");
230
+ /**
231
+ * 507 Insufficient Storage (WebDAV, RFC4918)
232
+ */
233
+ HttpResponseStatus.INSUFFICIENT_STORAGE = new HttpResponseStatus(507, "Insufficient Storage");
234
+ /**
235
+ * 510 Not Extended (RFC2774)
236
+ */
237
+ HttpResponseStatus.NOT_EXTENDED = new HttpResponseStatus(510, "Not Extended");
238
+ /**
239
+ * 511 Network Authentication Required (RFC6585)
240
+ */
241
+ HttpResponseStatus.NETWORK_AUTHENTICATION_REQUIRED = new HttpResponseStatus(511, "Network Authentication Required");
242
+ const fromJvmHttpResponseStatus = (jvmStatus) => {
243
+ switch (jvmStatus.code()) {
244
+ case 100:
245
+ return HttpResponseStatus.CONTINUE;
246
+ case 101:
247
+ return HttpResponseStatus.SWITCHING_PROTOCOLS;
248
+ case 102:
249
+ return HttpResponseStatus.PROCESSING;
250
+ case 103:
251
+ return HttpResponseStatus.EARLY_HINTS;
252
+ case 200:
253
+ return HttpResponseStatus.OK;
254
+ case 201:
255
+ return HttpResponseStatus.CREATED;
256
+ case 202:
257
+ return HttpResponseStatus.ACCEPTED;
258
+ case 203:
259
+ return HttpResponseStatus.NON_AUTHORITATIVE_INFORMATION;
260
+ case 204:
261
+ return HttpResponseStatus.NO_CONTENT;
262
+ case 205:
263
+ return HttpResponseStatus.RESET_CONTENT;
264
+ case 206:
265
+ return HttpResponseStatus.PARTIAL_CONTENT;
266
+ case 207:
267
+ return HttpResponseStatus.MULTI_STATUS;
268
+ case 300:
269
+ return HttpResponseStatus.MULTIPLE_CHOICES;
270
+ case 301:
271
+ return HttpResponseStatus.MOVED_PERMANENTLY;
272
+ case 302:
273
+ return HttpResponseStatus.FOUND;
274
+ case 303:
275
+ return HttpResponseStatus.SEE_OTHER;
276
+ case 304:
277
+ return HttpResponseStatus.NOT_MODIFIED;
278
+ case 305:
279
+ return HttpResponseStatus.USE_PROXY;
280
+ case 307:
281
+ return HttpResponseStatus.TEMPORARY_REDIRECT;
282
+ case 308:
283
+ return HttpResponseStatus.PERMANENT_REDIRECT;
284
+ case 400:
285
+ return HttpResponseStatus.BAD_REQUEST;
286
+ case 401:
287
+ return HttpResponseStatus.UNAUTHORIZED;
288
+ case 402:
289
+ return HttpResponseStatus.PAYMENT_REQUIRED;
290
+ case 403:
291
+ return HttpResponseStatus.FORBIDDEN;
292
+ case 404:
293
+ return HttpResponseStatus.NOT_FOUND;
294
+ case 405:
295
+ return HttpResponseStatus.METHOD_NOT_ALLOWED;
296
+ case 406:
297
+ return HttpResponseStatus.NOT_ACCEPTABLE;
298
+ case 407:
299
+ return HttpResponseStatus.PROXY_AUTHENTICATION_REQUIRED;
300
+ case 408:
301
+ return HttpResponseStatus.REQUEST_TIMEOUT;
302
+ case 409:
303
+ return HttpResponseStatus.CONFLICT;
304
+ case 410:
305
+ return HttpResponseStatus.GONE;
306
+ case 411:
307
+ return HttpResponseStatus.LENGTH_REQUIRED;
308
+ case 412:
309
+ return HttpResponseStatus.PRECONDITION_FAILED;
310
+ case 413:
311
+ return HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE;
312
+ case 414:
313
+ return HttpResponseStatus.REQUEST_URI_TOO_LONG;
314
+ case 415:
315
+ return HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE;
316
+ case 416:
317
+ return HttpResponseStatus.REQUESTED_RANGE_NOT_SATISFIABLE;
318
+ case 417:
319
+ return HttpResponseStatus.EXPECTATION_FAILED;
320
+ case 421:
321
+ return HttpResponseStatus.MISDIRECTED_REQUEST;
322
+ case 422:
323
+ return HttpResponseStatus.UNPROCESSABLE_ENTITY;
324
+ case 423:
325
+ return HttpResponseStatus.LOCKED;
326
+ case 424:
327
+ return HttpResponseStatus.FAILED_DEPENDENCY;
328
+ case 425:
329
+ return HttpResponseStatus.UNORDERED_COLLECTION;
330
+ case 426:
331
+ return HttpResponseStatus.UPGRADE_REQUIRED;
332
+ case 428:
333
+ return HttpResponseStatus.PRECONDITION_REQUIRED;
334
+ case 429:
335
+ return HttpResponseStatus.TOO_MANY_REQUESTS;
336
+ case 431:
337
+ return HttpResponseStatus.REQUEST_HEADER_FIELDS_TOO_LARGE;
338
+ case 500:
339
+ return HttpResponseStatus.INTERNAL_SERVER_ERROR;
340
+ case 501:
341
+ return HttpResponseStatus.NOT_IMPLEMENTED;
342
+ case 502:
343
+ return HttpResponseStatus.BAD_GATEWAY;
344
+ case 503:
345
+ return HttpResponseStatus.SERVICE_UNAVAILABLE;
346
+ case 504:
347
+ return HttpResponseStatus.GATEWAY_TIMEOUT;
348
+ case 505:
349
+ return HttpResponseStatus.HTTP_VERSION_NOT_SUPPORTED;
350
+ case 506:
351
+ return HttpResponseStatus.VARIANT_ALSO_NEGOTIATES;
352
+ case 507:
353
+ return HttpResponseStatus.INSUFFICIENT_STORAGE;
354
+ case 510:
355
+ return HttpResponseStatus.NOT_EXTENDED;
356
+ case 511:
357
+ return HttpResponseStatus.NETWORK_AUTHENTICATION_REQUIRED;
358
+ }
359
+ throw Error("This shouldn't happen unless we lag behind the original implementation, call support if this ever happens.");
360
+ };
361
+ exports.fromJvmHttpResponseStatus = fromJvmHttpResponseStatus;