@zthun/webigail-http 5.0.3 → 5.0.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/index.cjs +1020 -1046
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.js +996 -1042
- package/dist/index.js.map +1 -1
- package/dist/service/http-result-error.d.mts +8 -0
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -1,1097 +1,1051 @@
|
|
|
1
|
-
import { ZMimeTypeApplication } from
|
|
2
|
-
import fetch from
|
|
3
|
-
|
|
4
|
-
function _define_property$2(obj, key, value) {
|
|
5
|
-
if (key in obj) {
|
|
6
|
-
Object.defineProperty(obj, key, {
|
|
7
|
-
value: value,
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true
|
|
11
|
-
});
|
|
12
|
-
} else {
|
|
13
|
-
obj[key] = value;
|
|
14
|
-
}
|
|
15
|
-
return obj;
|
|
16
|
-
}
|
|
1
|
+
import { ZMimeTypeApplication } from "@zthun/webigail-url";
|
|
2
|
+
import fetch from "cross-fetch";
|
|
3
|
+
//#region src/request/http-request.mts
|
|
17
4
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
5
|
+
* Represents an available method for an http invocation.
|
|
6
|
+
*/ var ZHttpMethod = /* @__PURE__ */ function(ZHttpMethod) {
|
|
7
|
+
/**
|
|
8
|
+
* GET
|
|
9
|
+
*
|
|
10
|
+
* Used for reads
|
|
11
|
+
*/ ZHttpMethod["Get"] = "GET";
|
|
12
|
+
/**
|
|
13
|
+
* PUT
|
|
14
|
+
*
|
|
15
|
+
* Used for updates and can combine creates.
|
|
16
|
+
*/ ZHttpMethod["Put"] = "PUT";
|
|
17
|
+
/**
|
|
18
|
+
* POST
|
|
19
|
+
*
|
|
20
|
+
* Use for create.
|
|
21
|
+
*/ ZHttpMethod["Post"] = "POST";
|
|
22
|
+
/**
|
|
23
|
+
* DELETE.
|
|
24
|
+
*
|
|
25
|
+
* Used for....delete..duh.
|
|
26
|
+
*/ ZHttpMethod["Delete"] = "DELETE";
|
|
27
|
+
/**
|
|
28
|
+
* PATCH.
|
|
29
|
+
*
|
|
30
|
+
* Used for updates but only
|
|
31
|
+
* partials of objects.
|
|
32
|
+
*/ ZHttpMethod["Patch"] = "PATCH";
|
|
33
|
+
/**
|
|
34
|
+
* OPTIONS
|
|
35
|
+
*
|
|
36
|
+
* Used to retrieve the available methods and
|
|
37
|
+
* accessors for a single api. Normally used
|
|
38
|
+
* by the browser.
|
|
39
|
+
*/ ZHttpMethod["Options"] = "OPTIONS";
|
|
40
|
+
/**
|
|
41
|
+
* HEAD
|
|
42
|
+
*
|
|
43
|
+
* Used for metadata.
|
|
44
|
+
*/ ZHttpMethod["Head"] = "HEAD";
|
|
45
|
+
return ZHttpMethod;
|
|
59
46
|
}({});
|
|
60
47
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
48
|
+
* Represents a builder for an http request.
|
|
49
|
+
*/ var ZHttpRequestBuilder = class ZHttpRequestBuilder {
|
|
50
|
+
_request;
|
|
51
|
+
/**
|
|
52
|
+
* Duplicates a request, keeping it's structure intact.
|
|
53
|
+
*
|
|
54
|
+
* The underlying headers will be duplicated, but everything
|
|
55
|
+
* else will be a shallow copy to preserve the body in the
|
|
56
|
+
* case that it is a blob or other binary structure.
|
|
57
|
+
*
|
|
58
|
+
* @param other -
|
|
59
|
+
* The request to duplicate.
|
|
60
|
+
*
|
|
61
|
+
* @returns
|
|
62
|
+
* The duplicated object.
|
|
63
|
+
*/ static duplicate(other) {
|
|
64
|
+
return {
|
|
65
|
+
...other,
|
|
66
|
+
headers: structuredClone(other.headers)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Initializes a new instance of this object.
|
|
71
|
+
*/ constructor() {
|
|
72
|
+
this._request = {
|
|
73
|
+
method: "GET",
|
|
74
|
+
url: ""
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sets the method.
|
|
79
|
+
*
|
|
80
|
+
* @param method -
|
|
81
|
+
* The method to set.
|
|
82
|
+
* @param body -
|
|
83
|
+
* The post, put, or patch body.
|
|
84
|
+
*
|
|
85
|
+
* @returns
|
|
86
|
+
* This object.
|
|
87
|
+
*/ _method(method, body) {
|
|
88
|
+
this._request.method = method;
|
|
89
|
+
this._request.body = body;
|
|
90
|
+
if (this._request.body === void 0) delete this._request.body;
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Constructs a get request.
|
|
95
|
+
*
|
|
96
|
+
* @returns
|
|
97
|
+
* This object.
|
|
98
|
+
*/ get() {
|
|
99
|
+
return this._method("GET");
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Constructs a post request.
|
|
103
|
+
*
|
|
104
|
+
* @returns
|
|
105
|
+
* This object.
|
|
106
|
+
*/ post(body) {
|
|
107
|
+
return this._method("POST", body).json();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Constructs a put request.
|
|
111
|
+
*
|
|
112
|
+
* @returns
|
|
113
|
+
* This object.
|
|
114
|
+
*/ put(body) {
|
|
115
|
+
return this._method("PUT", body).json();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Constructs a delete request.
|
|
119
|
+
*
|
|
120
|
+
* @returns
|
|
121
|
+
* This object.
|
|
122
|
+
*/ delete() {
|
|
123
|
+
return this._method("DELETE");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Constructs a patch request.
|
|
127
|
+
*
|
|
128
|
+
* @returns
|
|
129
|
+
* This object.
|
|
130
|
+
*/ patch(body) {
|
|
131
|
+
return this._method("PATCH", body).json();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Constructs a options request.
|
|
135
|
+
*
|
|
136
|
+
* @returns
|
|
137
|
+
* This object.
|
|
138
|
+
*/ options() {
|
|
139
|
+
return this._method("OPTIONS");
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Constructs a head request.
|
|
143
|
+
*
|
|
144
|
+
* @returns
|
|
145
|
+
* This object.
|
|
146
|
+
*/ head() {
|
|
147
|
+
return this._method("HEAD");
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Sets the url to make the request from.
|
|
151
|
+
*
|
|
152
|
+
* @param url -
|
|
153
|
+
* The url to make the request to.
|
|
154
|
+
*
|
|
155
|
+
* @returns
|
|
156
|
+
* This object.
|
|
157
|
+
*/ url(url) {
|
|
158
|
+
this._request.url = url;
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Sets the timeout for the url.
|
|
163
|
+
*
|
|
164
|
+
* @param ms -
|
|
165
|
+
* The total number of milliseconds to wait.
|
|
166
|
+
*
|
|
167
|
+
* @returns
|
|
168
|
+
* The object.
|
|
169
|
+
*/ timeout(ms) {
|
|
170
|
+
this._request.timeout = ms;
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Sets the headers.
|
|
175
|
+
*
|
|
176
|
+
* @param headers -
|
|
177
|
+
* The headers to set.
|
|
178
|
+
*
|
|
179
|
+
* @returns
|
|
180
|
+
* This object.
|
|
181
|
+
*/ headers(headers) {
|
|
182
|
+
this._request.headers = headers;
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Sets an individual header.
|
|
187
|
+
*
|
|
188
|
+
* @param key -
|
|
189
|
+
* The header key to set.
|
|
190
|
+
* @param value -
|
|
191
|
+
* The value to set.
|
|
192
|
+
*
|
|
193
|
+
* @returns
|
|
194
|
+
* This object.
|
|
195
|
+
*/ header(key, value) {
|
|
196
|
+
this._request.headers = this._request.headers || {};
|
|
197
|
+
if (value == null) delete this._request.headers[key];
|
|
198
|
+
else this._request.headers[key] = `${value}`;
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Sets the content type header.
|
|
203
|
+
*
|
|
204
|
+
* @param type -
|
|
205
|
+
* The content mime type.
|
|
206
|
+
*
|
|
207
|
+
* @returns
|
|
208
|
+
* This object.
|
|
209
|
+
*/ content(type) {
|
|
210
|
+
return this.header("Content-Type", type);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Sets the content type to json.
|
|
214
|
+
*
|
|
215
|
+
* @returns
|
|
216
|
+
* This object.
|
|
217
|
+
*/ json = this.content.bind(this, ZMimeTypeApplication.JSON);
|
|
218
|
+
/**
|
|
219
|
+
* Copies other to this object.
|
|
220
|
+
*
|
|
221
|
+
* @param other -
|
|
222
|
+
* The request to copy.
|
|
223
|
+
*
|
|
224
|
+
* @returns
|
|
225
|
+
* This object.
|
|
226
|
+
*/ copy(other) {
|
|
227
|
+
this._request = ZHttpRequestBuilder.duplicate(other);
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Returns the constructed request.
|
|
232
|
+
*
|
|
233
|
+
* @returns
|
|
234
|
+
* The constructed request.
|
|
235
|
+
*/ build() {
|
|
236
|
+
return ZHttpRequestBuilder.duplicate(this._request);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/result/http-code-client.mts
|
|
258
241
|
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
242
|
+
* This class of status code is intended for situations in which the error seems to have been caused by the client.
|
|
243
|
+
*
|
|
244
|
+
* Except when responding to a HEAD request, the server should include an entity containing an explanation
|
|
245
|
+
* of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable
|
|
246
|
+
* to any request method. User agents should display any included entity to the user.
|
|
247
|
+
*/ var ZHttpCodeClient = /* @__PURE__ */ function(ZHttpCodeClient) {
|
|
248
|
+
/**
|
|
249
|
+
* The server cannot or will not process the request due to an apparent client error
|
|
250
|
+
* (e.g., malformed request syntax, size too large, invalid request message framing,
|
|
251
|
+
* or deceptive request routing).
|
|
252
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["BadRequest"] = 400] = "BadRequest";
|
|
253
|
+
/**
|
|
254
|
+
* Similar to 403 Forbidden, but specifically for use when authentication is required and has failed
|
|
255
|
+
* or has not yet been provided.
|
|
256
|
+
*
|
|
257
|
+
* The response must include a WWW-Authenticate header field containing a challenge applicable to the
|
|
258
|
+
* requested resource. See Basic access authentication and Digest access authentication. 401
|
|
259
|
+
* semantically means "unauthenticated",[35] i.e. the user does not have the necessary credentials.
|
|
260
|
+
*
|
|
261
|
+
* Note: Some sites issue HTTP 401 when an IP address is banned from the website (usually the website domain)
|
|
262
|
+
* and that specific address is refused permission to access a website.
|
|
263
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["Unauthorized"] = 401] = "Unauthorized";
|
|
264
|
+
/**
|
|
265
|
+
* Reserved for future use.
|
|
266
|
+
*
|
|
267
|
+
* The original intention was that this code might be used as part of some form of digital cash or
|
|
268
|
+
* micro-payment scheme, as proposed for example by GNU Taler, but that has not yet happened, and
|
|
269
|
+
* this code is not usually used. Google Developers API uses this status if a particular developer
|
|
270
|
+
* has exceeded the daily limit on requests
|
|
271
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["PaymentRequired"] = 402] = "PaymentRequired";
|
|
272
|
+
/**
|
|
273
|
+
* The request was valid, but the server is refusing action.
|
|
274
|
+
*
|
|
275
|
+
* The user might not have the necessary permissions for a resource, or may need an account of some sort.
|
|
276
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["Forbidden"] = 403] = "Forbidden";
|
|
277
|
+
/**
|
|
278
|
+
* The requested resource could not be found but may be available in the future.
|
|
279
|
+
*
|
|
280
|
+
* Subsequent requests by the client are permissible.
|
|
281
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["NotFound"] = 404] = "NotFound";
|
|
282
|
+
/**
|
|
283
|
+
* A request method is not supported for the requested resource; for example, a GET
|
|
284
|
+
* request on a form that requires data to be presented via POST, or a PUT request on
|
|
285
|
+
* a read-only resource.
|
|
286
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
287
|
+
/**
|
|
288
|
+
* The requested resource is capable of generating only content not acceptable according
|
|
289
|
+
* to the Accept headers sent in the request.
|
|
290
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["NotAcceptable"] = 406] = "NotAcceptable";
|
|
291
|
+
/**
|
|
292
|
+
* The client must first authenticate itself with the proxy.
|
|
293
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
294
|
+
/**
|
|
295
|
+
* The server timed out waiting for the request.
|
|
296
|
+
*
|
|
297
|
+
* According to HTTP specifications: "The client did not produce a request within the
|
|
298
|
+
* time that the server was prepared to wait. The client MAY repeat the request without
|
|
299
|
+
* modifications at any later time.
|
|
300
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["RequestTimeout"] = 408] = "RequestTimeout";
|
|
301
|
+
/**
|
|
302
|
+
* Indicates that the request could not be processed because of conflict in the request, such
|
|
303
|
+
* as an edit conflict between multiple simultaneous updates.
|
|
304
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["Conflict"] = 409] = "Conflict";
|
|
305
|
+
/**
|
|
306
|
+
* Indicates that the resource requested is no longer available and will not be available again.
|
|
307
|
+
*
|
|
308
|
+
* This should be used when a resource has been intentionally removed and the resource should be
|
|
309
|
+
* purged. Upon receiving a 410 status code, the client should not request the resource in the
|
|
310
|
+
* future. Clients such as search engines should remove the resource from their indices. Most use
|
|
311
|
+
* cases do not require clients and search engines to purge the resource, and a "404 Not Found" may
|
|
312
|
+
* be used instead.
|
|
313
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["Gone"] = 410] = "Gone";
|
|
314
|
+
/**
|
|
315
|
+
* The request did not specify the length of its content, which is required by the requested resource.
|
|
316
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["LengthRequired"] = 411] = "LengthRequired";
|
|
317
|
+
/**
|
|
318
|
+
* The server does not meet one of the preconditions that the requester put on the request.
|
|
319
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
320
|
+
/**
|
|
321
|
+
* The request is larger than the server is willing or able to process. Previously called
|
|
322
|
+
* "Request Entity Too Large".
|
|
323
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
324
|
+
/**
|
|
325
|
+
* The URI provided was too long for the server to process.
|
|
326
|
+
*
|
|
327
|
+
* Often the result of too much data being encoded as a query-string of
|
|
328
|
+
* a GET request, in which case it should be converted to a POST request.
|
|
329
|
+
* Called "Request-URI Too Long" previously.
|
|
330
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["URITooLong"] = 414] = "URITooLong";
|
|
331
|
+
/**
|
|
332
|
+
* The request entity has a media type which the server or resource does not support.
|
|
333
|
+
*
|
|
334
|
+
* For example, the client uploads an image as image/svg+xml, but the server requires that
|
|
335
|
+
* images use a different format.
|
|
336
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
337
|
+
/**
|
|
338
|
+
* The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
|
|
339
|
+
*
|
|
340
|
+
* For example, if the client asked for a part of the file that lies beyond the end of the file.
|
|
341
|
+
* Called "Requested Range Not Satisfiable" previously.
|
|
342
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
343
|
+
/**
|
|
344
|
+
* The server cannot meet the requirements of the Expect request-header field.
|
|
345
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
346
|
+
/**
|
|
347
|
+
* This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper
|
|
348
|
+
* Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers.
|
|
349
|
+
*
|
|
350
|
+
* The RFC specifies this code should be returned by teapots requested to brew coffee. This HTTP
|
|
351
|
+
* status is used as an Easter egg in some websites, including Google.com.
|
|
352
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["ImATeapot"] = 418] = "ImATeapot";
|
|
353
|
+
/**
|
|
354
|
+
* The request was directed at a server that is not able to produce a response[53] (for example because of connection reuse).
|
|
355
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
356
|
+
/**
|
|
357
|
+
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
358
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["UnProcessableEntity"] = 422] = "UnProcessableEntity";
|
|
359
|
+
/**
|
|
360
|
+
* The resource that is being accessed is locked.
|
|
361
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["Locked"] = 423] = "Locked";
|
|
362
|
+
/**
|
|
363
|
+
* The request failed because it depended on another request and that request failed.
|
|
364
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["FailedDependency"] = 424] = "FailedDependency";
|
|
365
|
+
/**
|
|
366
|
+
* The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
|
|
367
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
368
|
+
/**
|
|
369
|
+
* The origin server requires the request to be conditional.
|
|
370
|
+
*
|
|
371
|
+
* Intended to prevent the 'lost update' problem, where a client GETs a resource's state, modifies it,
|
|
372
|
+
* and PUTs it back to the server, when meanwhile a third party has modified the state on the server,
|
|
373
|
+
* leading to a conflict.
|
|
374
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
375
|
+
/**
|
|
376
|
+
* The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
|
|
377
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["TooManyRequests"] = 429] = "TooManyRequests";
|
|
378
|
+
/**
|
|
379
|
+
* The server is unwilling to process the request because either an individual header field, or all the
|
|
380
|
+
* header fields collectively, are too large.[
|
|
381
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
382
|
+
/**
|
|
383
|
+
* A server operator has received a legal demand to deny access to a resource or to a set of resources that includes the
|
|
384
|
+
* requested resource.
|
|
385
|
+
*
|
|
386
|
+
* The code 451 was chosen as a reference to the novel Fahrenheit 451.
|
|
387
|
+
*/ ZHttpCodeClient[ZHttpCodeClient["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
388
|
+
return ZHttpCodeClient;
|
|
406
389
|
}({});
|
|
407
390
|
/**
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
391
|
+
* English friendly names of the codes.
|
|
392
|
+
*/ var ZHttpCodeClientNames = {
|
|
393
|
+
[400]: "Bad Request",
|
|
394
|
+
[401]: "Unauthorized",
|
|
395
|
+
[402]: "Payment Required",
|
|
396
|
+
[403]: "Forbidden",
|
|
397
|
+
[404]: "Not Found",
|
|
398
|
+
[405]: "Method not Allowed",
|
|
399
|
+
[406]: "Not Acceptable",
|
|
400
|
+
[407]: "Proxy Authentication Required",
|
|
401
|
+
[408]: "Request Timeout",
|
|
402
|
+
[409]: "Conflict",
|
|
403
|
+
[410]: "Gone",
|
|
404
|
+
[411]: "Length Required",
|
|
405
|
+
[412]: "Precondition Failed",
|
|
406
|
+
[413]: "Payload Too Large",
|
|
407
|
+
[414]: "URI Too Long",
|
|
408
|
+
[415]: "Unsupported Media Type",
|
|
409
|
+
[416]: "Range Not Satisfiable",
|
|
410
|
+
[417]: "Expectation Failed",
|
|
411
|
+
[418]: "I am a Teapot",
|
|
412
|
+
[421]: "Misdirected Requested",
|
|
413
|
+
[422]: "Entity Not Processable",
|
|
414
|
+
[423]: "Locked",
|
|
415
|
+
[424]: "Failed Dependency",
|
|
416
|
+
[426]: "Upgrade Required",
|
|
417
|
+
[428]: "Precondition Required",
|
|
418
|
+
[429]: "Too Many Requests",
|
|
419
|
+
[431]: "Request Header Fields Too Large",
|
|
420
|
+
[451]: "Unavailable for Legal Reasons"
|
|
438
421
|
};
|
|
439
422
|
/**
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
423
|
+
* English friendly descriptions of HttpClientCodes
|
|
424
|
+
*/ var ZHttpCodeClientDescriptions = {
|
|
425
|
+
[400]: "A bad request was sent.",
|
|
426
|
+
[401]: "You are not authenticated and cannot view this content.",
|
|
427
|
+
[402]: "Payment is required",
|
|
428
|
+
[403]: "You are not authorized to view this content.",
|
|
429
|
+
[404]: "The resource you are looking for could not be found.",
|
|
430
|
+
[405]: "The requested operation was not allowed.",
|
|
431
|
+
[406]: "The requested resource is not capable of generating the content for you.",
|
|
432
|
+
[407]: "You must first authenticate your self with the proxy.",
|
|
433
|
+
[408]: "The server timed out waiting for a request. Please try again.",
|
|
434
|
+
[409]: "There was a conflict with request. Try something else.",
|
|
435
|
+
[410]: "The resource you requested is no longer available.",
|
|
436
|
+
[411]: "Your request did not specify the length of its content, which is required by the requested resource.",
|
|
437
|
+
[412]: "The server did not meet the requirements that was required to meet the request.",
|
|
438
|
+
[413]: "The request is too large and the server cannot handle it.",
|
|
439
|
+
[414]: "The URI provided was too long for the server to process.",
|
|
440
|
+
[415]: "The media type requested is not supported by the server.",
|
|
441
|
+
[416]: "A portion of the file was requested by the server cannot supply said portion.",
|
|
442
|
+
[417]: "The server cannot meet the requirements of the expectation made of it.",
|
|
443
|
+
[418]: "Short and stout. Here is my handle, here is my spout. When I get all steamed up, hear me shout. Tip me over and pour me out!",
|
|
444
|
+
[421]: "The request was directed at the server, but the server cannot produce a response.",
|
|
445
|
+
[422]: "The request was well-formed but was unable to be followed due to semantic errors.",
|
|
446
|
+
[423]: "The resource that is being accessed is locked.",
|
|
447
|
+
[424]: "The request failed because it depended on another request and that request failed.",
|
|
448
|
+
[426]: "The client needs to switch to a different protocol.",
|
|
449
|
+
[428]: "The origin server requires the request to be conditional.",
|
|
450
|
+
[429]: "The user has sent too many requests in a given amount of time.",
|
|
451
|
+
[431]: "The request cannot be processed because the collective header fields are too large.",
|
|
452
|
+
[451]: "Call your lawyer!"
|
|
470
453
|
};
|
|
471
|
-
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/result/http-code-informational-response.mts
|
|
472
456
|
/**
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
457
|
+
* An informational response indicates that the request was received and understood.
|
|
458
|
+
*
|
|
459
|
+
* It is issued on a provisional basis while request processing continues. It alerts the
|
|
460
|
+
* client to wait for a final response. The message consists only of the status line and
|
|
461
|
+
* optional header fields, and is terminated by an empty line. As the HTTP/1.0 standard
|
|
462
|
+
* did not define any 1xx status codes, servers must not[note 1] send a 1xx response to
|
|
463
|
+
* an HTTP/1.0 compliant client except under experimental conditions.[4]
|
|
464
|
+
*/ var ZHttpCodeInformationalResponse = /* @__PURE__ */ function(ZHttpCodeInformationalResponse) {
|
|
465
|
+
/**
|
|
466
|
+
* The server has received the request headers and the client should proceed to send the
|
|
467
|
+
* request body (in the case of a request for which a body needs to be sent; for example, a
|
|
468
|
+
* POST request).
|
|
469
|
+
*
|
|
470
|
+
* Sending a large request body to a server after a request has been rejected
|
|
471
|
+
* for inappropriate headers would be inefficient. To have a server check the request's headers,
|
|
472
|
+
* a client must send Expect: 100-continue as a header in its initial request and receive a 100 Continue status
|
|
473
|
+
* code in response before sending the body. If the client receives an error code such as 403 (Forbidden) or 405
|
|
474
|
+
* (Method Not Allowed) then it shouldn't send the request's body. The response 417 Expectation Failed indicates
|
|
475
|
+
* that the request should be repeated without the Expect header as it indicates that the server doesn't support
|
|
476
|
+
* expectations (this is the case, for example, of HTTP/1.0 servers).
|
|
477
|
+
*/ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["Continue"] = 100] = "Continue";
|
|
478
|
+
/**
|
|
479
|
+
* The requester has asked the server to switch protocols and the server has agreed to do so.
|
|
480
|
+
*/ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
481
|
+
/**
|
|
482
|
+
* A WebDAV request may contain many sub-requests involving file operations, requiring a long time to
|
|
483
|
+
* complete the request. This code indicates that the server has received and is processing the request,
|
|
484
|
+
* but no response is available yet. This prevents the client from timing out and assuming the request was lost.
|
|
485
|
+
*/ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["Processing"] = 102] = "Processing";
|
|
486
|
+
/**
|
|
487
|
+
* Used to return some response headers before final HTTP message.
|
|
488
|
+
*/ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["EarlyHints"] = 103] = "EarlyHints";
|
|
489
|
+
return ZHttpCodeInformationalResponse;
|
|
506
490
|
}({});
|
|
507
491
|
/**
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
492
|
+
* English friendly names of the codes.
|
|
493
|
+
*/ var ZHttpCodeInformationalResponseNames = {
|
|
494
|
+
[100]: "Continue",
|
|
495
|
+
[101]: "Switching Protocols",
|
|
496
|
+
[102]: "Processing",
|
|
497
|
+
[103]: "Early Hints"
|
|
514
498
|
};
|
|
515
499
|
/**
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
500
|
+
* English friendly descriptions of the codes.
|
|
501
|
+
*/ var ZHttpCodeInformationalResponseDescriptions = {
|
|
502
|
+
[100]: "The client should continue to send the request body.",
|
|
503
|
+
[101]: "The requestor has asked the server to switch protocols and the server has agreed to do so.",
|
|
504
|
+
[102]: "The server has received and is processing the request, but a response is not available yet.",
|
|
505
|
+
[103]: "There are some early response headers available for you before the final message."
|
|
522
506
|
};
|
|
523
|
-
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/result/http-code-redirection.mts
|
|
524
509
|
/**
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
510
|
+
* This class of status code indicates the client must take additional action to complete the request.
|
|
511
|
+
*
|
|
512
|
+
* Many of these status codes are used in URL redirection. A user agent may carry out the additional
|
|
513
|
+
* action with no user interaction only if the method used in the second request is GET or HEAD.
|
|
514
|
+
* A user agent may automatically redirect a request. A user agent should detect and intervene
|
|
515
|
+
* to prevent cyclical redirects.
|
|
516
|
+
*/ var ZHttpCodeRedirection = /* @__PURE__ */ function(ZHttpCodeRedirection) {
|
|
517
|
+
/**
|
|
518
|
+
* Indicates multiple options for the resource from which the client may choose
|
|
519
|
+
* (via agent-driven content negotiation).
|
|
520
|
+
*
|
|
521
|
+
* For example, this code could be used to present multiple video format options, to
|
|
522
|
+
* list files with different filename extensions, or to suggest word-sense disambiguation.
|
|
523
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["MultipleChoices"] = 300] = "MultipleChoices";
|
|
524
|
+
/**
|
|
525
|
+
* This and all future requests should be directed to the given URI.
|
|
526
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["MovedPermanently"] = 301] = "MovedPermanently";
|
|
527
|
+
/**
|
|
528
|
+
* Tells the client to look at (browse to) another url. 302 has been superseded by 303 and 307.
|
|
529
|
+
* This is an example of industry practice contradicting the standard. The HTTP/1.0 specification (RFC 1945)
|
|
530
|
+
* required the client to perform a temporary redirect (the original describing phrase was "Moved Temporarily"),
|
|
531
|
+
* [22] but popular browsers implemented 302 with the functionality of a 303 See Other. Therefore, HTTP/1.1
|
|
532
|
+
* added status codes 303 and 307 to distinguish between the two behaviors.[23] However, some Web applications
|
|
533
|
+
* and frameworks use the 302 status code as if it were the 303.
|
|
534
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["Found"] = 302] = "Found";
|
|
535
|
+
/**
|
|
536
|
+
* The response to the request can be found under another URI using the GET method.
|
|
537
|
+
*
|
|
538
|
+
* When received in response to a POST (or PUT/DELETE), the client should presume
|
|
539
|
+
* that the server has received the data and should issue a new GET request to
|
|
540
|
+
* the given URI.
|
|
541
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["SeeOther"] = 303] = "SeeOther";
|
|
542
|
+
/**
|
|
543
|
+
* Indicates that the resource has not been modified since the version specified by the request headers
|
|
544
|
+
* If-Modified-Since or If-None-Match. In such case, there is no need to retransmit the resource since
|
|
545
|
+
* the client still has a previously-downloaded copy.
|
|
546
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["NotModified"] = 304] = "NotModified";
|
|
547
|
+
/**
|
|
548
|
+
* The requested resource is available only through a proxy, the address for which is provided in the response.
|
|
549
|
+
*
|
|
550
|
+
* Many HTTP clients (such as Mozilla[27] and Internet Explorer) do not correctly handle responses with
|
|
551
|
+
* this status code, primarily for security reasons.
|
|
552
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["UseProxy"] = 305] = "UseProxy";
|
|
553
|
+
/**
|
|
554
|
+
* No longer used. Originally meant "Subsequent requests should use the specified proxy.
|
|
555
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["SwitchProxy"] = 306] = "SwitchProxy";
|
|
556
|
+
/**
|
|
557
|
+
* In this case, the request should be repeated with another URI; however, future requests
|
|
558
|
+
* should still use the original URI.
|
|
559
|
+
*
|
|
560
|
+
* In contrast to how 302 was historically implemented, the request method is not allowed to be
|
|
561
|
+
* changed when reissuing the original request. For example, a POST request should be repeated using
|
|
562
|
+
* another POST request.
|
|
563
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
564
|
+
/**
|
|
565
|
+
* The request and all future requests should be repeated using another URI.
|
|
566
|
+
*
|
|
567
|
+
* 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
|
|
568
|
+
* So, for example, submitting a form to a permanently redirected resource may continue smoothly.
|
|
569
|
+
*/ ZHttpCodeRedirection[ZHttpCodeRedirection["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
570
|
+
return ZHttpCodeRedirection;
|
|
586
571
|
}({});
|
|
587
572
|
/**
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
573
|
+
* English friendly names of the redirection codes.
|
|
574
|
+
*/ var ZHttpCodeRedirectionNames = {
|
|
575
|
+
[300]: "Multiple Choices",
|
|
576
|
+
[301]: "Moved Permanently",
|
|
577
|
+
[302]: "Found",
|
|
578
|
+
[303]: "See Other",
|
|
579
|
+
[304]: "Not Modified",
|
|
580
|
+
[305]: "Use Proxy",
|
|
581
|
+
[306]: "Switch Proxy",
|
|
582
|
+
[307]: "Temporary Redirect",
|
|
583
|
+
[308]: "Permanent Redirect"
|
|
599
584
|
};
|
|
600
585
|
/**
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
586
|
+
* English friendly descriptions of the redirection codes.
|
|
587
|
+
*/ var ZHttpCodeRedirectionDescriptions = {
|
|
588
|
+
[300]: "Indicates multiple options for the resource from which the client may choose.",
|
|
589
|
+
[301]: "This and all future requests should be directed to the given URI.",
|
|
590
|
+
[302]: "Tells the client to look at another url",
|
|
591
|
+
[303]: "The response to the request can be found under another URI using the GET method.",
|
|
592
|
+
[304]: "Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.",
|
|
593
|
+
[305]: "The requested resource is available only through a proxy, the address for which is provided in the response.",
|
|
594
|
+
[306]: "No longer used. Originally meant \"Subsequent requests should use the specified proxy.",
|
|
595
|
+
[307]: "In this case, the request should be repeated with another URI; however, future requests should still use the original URI.",
|
|
596
|
+
[308]: "The request and all future requests should be repeated using another URI."
|
|
612
597
|
};
|
|
613
|
-
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region src/result/http-code-server.mts
|
|
614
600
|
/**
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
601
|
+
* The server failed to fulfil a request.
|
|
602
|
+
*
|
|
603
|
+
* Response status codes beginning with the digit "5" indicate
|
|
604
|
+
* cases in which the server is aware that it has encountered an
|
|
605
|
+
* error or is otherwise incapable of performing the request. Except
|
|
606
|
+
* when responding to a HEAD request, the server should include an entity
|
|
607
|
+
* containing an explanation of the error situation, and indicate whether it
|
|
608
|
+
* is a temporary or permanent condition. Likewise, user agents should
|
|
609
|
+
* display any included entity to the user. These response codes are applicable
|
|
610
|
+
* to any request method.
|
|
611
|
+
*/ var ZHttpCodeServer = /* @__PURE__ */ function(ZHttpCodeServer) {
|
|
612
|
+
/**
|
|
613
|
+
* A generic error message, given when an unexpected condition was encountered
|
|
614
|
+
* and no more specific message is suitable.
|
|
615
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["InternalServerError"] = 500] = "InternalServerError";
|
|
616
|
+
/**
|
|
617
|
+
* The server either does not recognize the request method, or it lacks the ability to
|
|
618
|
+
* fulfil the request. Usually this implies future availability (e.g., a new feature of
|
|
619
|
+
* a web-service API).
|
|
620
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["NotImplemented"] = 501] = "NotImplemented";
|
|
621
|
+
/**
|
|
622
|
+
* The server was acting as a gateway or proxy and received an invalid response
|
|
623
|
+
* from the upstream server.
|
|
624
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["BadGateway"] = 502] = "BadGateway";
|
|
625
|
+
/**
|
|
626
|
+
* The server is currently unavailable (because it is overloaded or down for maintenance).
|
|
627
|
+
* Generally, this is a temporary state.
|
|
628
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
629
|
+
/**
|
|
630
|
+
* The server was acting as a gateway or proxy and did not receive a timely response from
|
|
631
|
+
* the upstream server.
|
|
632
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
633
|
+
/**
|
|
634
|
+
* The server does not support the HTTP protocol version used in the request.
|
|
635
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
|
|
636
|
+
/**
|
|
637
|
+
* Transparent content negotiation for the request results in a circular reference.
|
|
638
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
639
|
+
/**
|
|
640
|
+
* The server is unable to store the representation needed to complete the request.
|
|
641
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
642
|
+
/**
|
|
643
|
+
* The server detected an infinite loop while processing the request.
|
|
644
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["LoopDetected"] = 508] = "LoopDetected";
|
|
645
|
+
/**
|
|
646
|
+
* Further extensions to the request are required for the server to fulfil it.
|
|
647
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["NotExtended"] = 510] = "NotExtended";
|
|
648
|
+
/**
|
|
649
|
+
* The client needs to authenticate to gain network access. Intended for use by
|
|
650
|
+
* intercepting proxies used to control access to the network.
|
|
651
|
+
*/ ZHttpCodeServer[ZHttpCodeServer["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
652
|
+
return ZHttpCodeServer;
|
|
667
653
|
}({});
|
|
668
654
|
/**
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
655
|
+
* English friendly names of the server codes.
|
|
656
|
+
*/ var ZHttpCodeServerNames = {
|
|
657
|
+
[500]: "Internal Server Error",
|
|
658
|
+
[501]: "Not Implemented",
|
|
659
|
+
[502]: "Bad Gateway",
|
|
660
|
+
[503]: "Service Unavailable",
|
|
661
|
+
[504]: "Gateway Timeout",
|
|
662
|
+
[505]: "HTTP Version Not Supported",
|
|
663
|
+
[506]: "Variant Also Negotiates",
|
|
664
|
+
[507]: "Insufficient Storage",
|
|
665
|
+
[508]: "Loop Detected",
|
|
666
|
+
[510]: "Not Extended",
|
|
667
|
+
[511]: "Network Authentication Required"
|
|
682
668
|
};
|
|
683
669
|
/**
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
670
|
+
* English friendly names of the server codes.
|
|
671
|
+
*/ var ZHttpCodeServerDescriptions = {
|
|
672
|
+
[500]: "An unexpected condition was encountered on the server.",
|
|
673
|
+
[501]: "The server either does not recognize the request method, or it lacks the ability to fulfil the request. Usually this implies future availability (e.g., a new feature of a web-service API).",
|
|
674
|
+
[502]: " The server was acting as a gateway or proxy and received an invalid response from the upstream server.",
|
|
675
|
+
[503]: "The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.",
|
|
676
|
+
[504]: "The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.",
|
|
677
|
+
[505]: "The server does not support the HTTP protocol version used in the request.",
|
|
678
|
+
[506]: " Transparent content negotiation for the request results in a circular reference.",
|
|
679
|
+
[507]: "The server is unable to store the representation needed to complete the request.",
|
|
680
|
+
[508]: "The server detected an infinite loop while processing the request.",
|
|
681
|
+
[510]: "Further extensions to the request are required for the server to fulfil it.",
|
|
682
|
+
[511]: "The client needs to authenticate to gain network access."
|
|
697
683
|
};
|
|
698
|
-
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/result/http-code-success.mts
|
|
699
686
|
/**
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
687
|
+
* This class of status codes indicates the action requested by
|
|
688
|
+
* the client was received, understood and accepted.
|
|
689
|
+
*/ var ZHttpCodeSuccess = /* @__PURE__ */ function(ZHttpCodeSuccess) {
|
|
690
|
+
/**
|
|
691
|
+
* Standard response for successful HTTP requests.
|
|
692
|
+
*
|
|
693
|
+
* The actual response will depend on the request method used. In a GET
|
|
694
|
+
* request, the response will contain an entity corresponding to the
|
|
695
|
+
* requested resource. In a POST request, the response will contain an
|
|
696
|
+
* entity describing or containing the result of the action.
|
|
697
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["OK"] = 200] = "OK";
|
|
698
|
+
/**
|
|
699
|
+
* The request has been fulfilled, resulting in the creation of a new resource.
|
|
700
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["Created"] = 201] = "Created";
|
|
701
|
+
/**
|
|
702
|
+
* The request has been accepted for processing, but the processing has not been completed.
|
|
703
|
+
*
|
|
704
|
+
* The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
|
|
705
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["Accepted"] = 202] = "Accepted";
|
|
706
|
+
/**
|
|
707
|
+
* The server is a transforming proxy (e.g. a Web accelerator) that received a 200 OK from its origin,
|
|
708
|
+
* but is returning a modified version of the origin's response.
|
|
709
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
710
|
+
/**
|
|
711
|
+
* The server successfully processed the request and is not returning any content.
|
|
712
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["NoContent"] = 204] = "NoContent";
|
|
713
|
+
/**
|
|
714
|
+
* The server successfully processed the request, but is not returning any content.
|
|
715
|
+
*
|
|
716
|
+
* Unlike a 204 response, this response requires that the requester reset the document view.
|
|
717
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["ResetContent"] = 205] = "ResetContent";
|
|
718
|
+
/**
|
|
719
|
+
* The server is delivering only part of the resource (byte serving) due to a range header
|
|
720
|
+
* sent by the client.
|
|
721
|
+
*
|
|
722
|
+
* The range header is used by HTTP clients to enable resuming of interrupted downloads, or
|
|
723
|
+
* split a download into multiple simultaneous streams.
|
|
724
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["PartialContent"] = 206] = "PartialContent";
|
|
725
|
+
/**
|
|
726
|
+
* The message body that follows is by default an XML message and can contain a number of separate
|
|
727
|
+
* response codes, depending on how many sub-requests were made.
|
|
728
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["MultiStatus"] = 207] = "MultiStatus";
|
|
729
|
+
/**
|
|
730
|
+
* The members of a DAV binding have already been enumerated in a preceding part of the
|
|
731
|
+
* response, and are not being included again.
|
|
732
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["AlreadyReported"] = 208] = "AlreadyReported";
|
|
733
|
+
/**
|
|
734
|
+
* The server has fulfilled a request for the resource, and the response is a representation of the result
|
|
735
|
+
* of one or more instance-manipulations applied to the current instance.
|
|
736
|
+
*/ ZHttpCodeSuccess[ZHttpCodeSuccess["IMUsed"] = 226] = "IMUsed";
|
|
737
|
+
return ZHttpCodeSuccess;
|
|
751
738
|
}({});
|
|
752
739
|
/**
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
740
|
+
* Friendly english names of success codes.
|
|
741
|
+
*/ var ZHttpCodeSuccessNames = {
|
|
742
|
+
[200]: "OK",
|
|
743
|
+
[201]: "Created",
|
|
744
|
+
[202]: "Accepted",
|
|
745
|
+
[203]: "Non-Authoritative Information",
|
|
746
|
+
[204]: "No Content",
|
|
747
|
+
[205]: "Reset Content",
|
|
748
|
+
[206]: "Partial Content",
|
|
749
|
+
[207]: "Multi Status",
|
|
750
|
+
[208]: "Already Reported",
|
|
751
|
+
[226]: "IM Used"
|
|
765
752
|
};
|
|
766
753
|
/**
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
754
|
+
* Friendly english descriptions of success codes.
|
|
755
|
+
*/ var ZHttpCodeSuccessDescriptions = {
|
|
756
|
+
[200]: "The request was successful.",
|
|
757
|
+
[201]: "The request has been fulfilled, resulting in the creation of a new resource.",
|
|
758
|
+
[202]: "The request has been accepted for processing, but the processing has not been completed.",
|
|
759
|
+
[203]: "The server is a transforming proxy that received an OK from its origin,but is returning a modified version of the response.",
|
|
760
|
+
[204]: "The server successfully processed the request and is not returning any content.",
|
|
761
|
+
[205]: "The server successfully processed the request, but is not returning any content. The document view must be refreshed.",
|
|
762
|
+
[206]: "he server is delivering only part of the resource due to a range header sent by the client.",
|
|
763
|
+
[207]: "The message body that follows is by default an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.",
|
|
764
|
+
[208]: "The members of a DAV binding have already been enumerated in a preceding part of the response, and are not being included again.",
|
|
765
|
+
[226]: "The server has fulfilled a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance."
|
|
779
766
|
};
|
|
780
|
-
|
|
767
|
+
//#endregion
|
|
768
|
+
//#region src/result/http-code.mts
|
|
781
769
|
/**
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
770
|
+
* Represents the category name for an http code.
|
|
771
|
+
*/ var ZHttpCodeCategory = /* @__PURE__ */ function(ZHttpCodeCategory) {
|
|
772
|
+
/**
|
|
773
|
+
* Error codes 100-199.
|
|
774
|
+
*/ ZHttpCodeCategory["InformationalResponse"] = "Informational Response";
|
|
775
|
+
/**
|
|
776
|
+
* Error codes 200-299.
|
|
777
|
+
*/ ZHttpCodeCategory["Success"] = "Success";
|
|
778
|
+
/**
|
|
779
|
+
* Error codes 300-399.
|
|
780
|
+
*/ ZHttpCodeCategory["Redirection"] = "Redirection";
|
|
781
|
+
/**
|
|
782
|
+
* Error codes 400-499.
|
|
783
|
+
*/ ZHttpCodeCategory["Client"] = "Client Error";
|
|
784
|
+
/**
|
|
785
|
+
* Error codes 500-599.
|
|
786
|
+
*/ ZHttpCodeCategory["Server"] = "Server Error";
|
|
787
|
+
return ZHttpCodeCategory;
|
|
800
788
|
}({});
|
|
801
789
|
/**
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
790
|
+
* Represents a classification of severity for a code.
|
|
791
|
+
*/ var ZHttpCodeSeverity = /* @__PURE__ */ function(ZHttpCodeSeverity) {
|
|
792
|
+
/**
|
|
793
|
+
* Covers information response (100-199) and redirection codes (300-399).
|
|
794
|
+
*/ ZHttpCodeSeverity["Info"] = "info";
|
|
795
|
+
/**
|
|
796
|
+
* Covers the success codes (200-299)
|
|
797
|
+
*/ ZHttpCodeSeverity["Success"] = "success";
|
|
798
|
+
/**
|
|
799
|
+
* Covers client errors (400-499).
|
|
800
|
+
*/ ZHttpCodeSeverity["Warning"] = "warning";
|
|
801
|
+
/**
|
|
802
|
+
* Covers server errors (500-599).
|
|
803
|
+
*/ ZHttpCodeSeverity["Error"] = "error";
|
|
804
|
+
return ZHttpCodeSeverity;
|
|
817
805
|
}({});
|
|
818
806
|
/**
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
807
|
+
* Gets the english friendly name of a code.
|
|
808
|
+
*
|
|
809
|
+
* @param code -
|
|
810
|
+
* The code to retrieve the name for.
|
|
811
|
+
*
|
|
812
|
+
* @returns
|
|
813
|
+
* The english friendly name of a code.
|
|
814
|
+
*/ function getHttpCodeName(code) {
|
|
815
|
+
return ZHttpCodeInformationalResponseNames[code] || ZHttpCodeSuccessNames[code] || ZHttpCodeRedirectionNames[code] || ZHttpCodeClientNames[code] || ZHttpCodeServerNames[code];
|
|
828
816
|
}
|
|
829
817
|
/**
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
818
|
+
* Gets the english friendly description of a code.
|
|
819
|
+
*
|
|
820
|
+
* @param code -
|
|
821
|
+
* The code to retrieve the description for.
|
|
822
|
+
*
|
|
823
|
+
* @returns
|
|
824
|
+
* The english friendly description of a code.
|
|
825
|
+
*/ function getHttpCodeDescription(code) {
|
|
826
|
+
return ZHttpCodeInformationalResponseDescriptions[code] || ZHttpCodeSuccessDescriptions[code] || ZHttpCodeRedirectionDescriptions[code] || ZHttpCodeClientDescriptions[code] || ZHttpCodeServerDescriptions[code];
|
|
839
827
|
}
|
|
840
828
|
/**
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
}
|
|
855
|
-
if (code >= 500) {
|
|
856
|
-
return "error";
|
|
857
|
-
}
|
|
858
|
-
return "info";
|
|
829
|
+
* Gets the severity of a code.
|
|
830
|
+
*
|
|
831
|
+
* @param code -
|
|
832
|
+
* The severity of a code.
|
|
833
|
+
*
|
|
834
|
+
* @returns
|
|
835
|
+
* The severity of a code.
|
|
836
|
+
*/ function getHttpCodeSeverity(code) {
|
|
837
|
+
const _code = +code;
|
|
838
|
+
if (_code >= 200 && _code < 300) return "success";
|
|
839
|
+
if (_code >= 400 && _code < 500) return "warning";
|
|
840
|
+
if (_code >= 500) return "error";
|
|
841
|
+
return "info";
|
|
859
842
|
}
|
|
860
843
|
/**
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
if (code >= 300 && code < 400) {
|
|
876
|
-
return "Redirection";
|
|
877
|
-
}
|
|
878
|
-
if (code >= 400 && code < 500) {
|
|
879
|
-
return "Client Error";
|
|
880
|
-
}
|
|
881
|
-
return "Server Error";
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
function _define_property$1(obj, key, value) {
|
|
885
|
-
if (key in obj) {
|
|
886
|
-
Object.defineProperty(obj, key, {
|
|
887
|
-
value: value,
|
|
888
|
-
enumerable: true,
|
|
889
|
-
configurable: true,
|
|
890
|
-
writable: true
|
|
891
|
-
});
|
|
892
|
-
} else {
|
|
893
|
-
obj[key] = value;
|
|
894
|
-
}
|
|
895
|
-
return obj;
|
|
844
|
+
* Gets the category of a code.
|
|
845
|
+
*
|
|
846
|
+
* @param code -
|
|
847
|
+
* The category of a code.
|
|
848
|
+
*
|
|
849
|
+
* @returns
|
|
850
|
+
* The code category.
|
|
851
|
+
*/ function getHttpCodeCategory(code) {
|
|
852
|
+
const _code = +code;
|
|
853
|
+
if (_code >= 100 && _code < 200) return "Informational Response";
|
|
854
|
+
if (_code >= 200 && _code < 300) return "Success";
|
|
855
|
+
if (_code >= 300 && _code < 400) return "Redirection";
|
|
856
|
+
if (_code >= 400 && _code < 500) return "Client Error";
|
|
857
|
+
return "Server Error";
|
|
896
858
|
}
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/result/http-result.mts
|
|
897
861
|
/**
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
function _define_property(obj, key, value) {
|
|
962
|
-
if (key in obj) {
|
|
963
|
-
Object.defineProperty(obj, key, {
|
|
964
|
-
value: value,
|
|
965
|
-
enumerable: true,
|
|
966
|
-
configurable: true,
|
|
967
|
-
writable: true
|
|
968
|
-
});
|
|
969
|
-
} else {
|
|
970
|
-
obj[key] = value;
|
|
971
|
-
}
|
|
972
|
-
return obj;
|
|
973
|
-
}
|
|
862
|
+
* Represents a builder for an IZHttpResult class.
|
|
863
|
+
*/ var ZHttpResultBuilder = class {
|
|
864
|
+
_result;
|
|
865
|
+
/**
|
|
866
|
+
* Initializes a new instance of this object.
|
|
867
|
+
*
|
|
868
|
+
* @param data -
|
|
869
|
+
* The data result.
|
|
870
|
+
*/ constructor(data) {
|
|
871
|
+
this._result = {
|
|
872
|
+
status: ZHttpCodeSuccess.OK,
|
|
873
|
+
headers: {},
|
|
874
|
+
data
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Sets the data.
|
|
879
|
+
*
|
|
880
|
+
* @param data -
|
|
881
|
+
* The data to set.
|
|
882
|
+
*
|
|
883
|
+
* @returns
|
|
884
|
+
* This object.
|
|
885
|
+
*/ data(data) {
|
|
886
|
+
this._result.data = data;
|
|
887
|
+
return this;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Sets the status code and the english description.
|
|
891
|
+
*
|
|
892
|
+
* @param code -
|
|
893
|
+
* The code to set.
|
|
894
|
+
*
|
|
895
|
+
* @returns
|
|
896
|
+
* This object.
|
|
897
|
+
*/ status(code) {
|
|
898
|
+
this._result.status = code;
|
|
899
|
+
return this;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Sets the return headers.
|
|
903
|
+
*
|
|
904
|
+
* @param headers -
|
|
905
|
+
* The headers to set.
|
|
906
|
+
*
|
|
907
|
+
* @returns
|
|
908
|
+
* This object.
|
|
909
|
+
*/ headers(headers = {}) {
|
|
910
|
+
this._result.headers = headers;
|
|
911
|
+
return this;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Returns the built up result.
|
|
915
|
+
*
|
|
916
|
+
* @returns
|
|
917
|
+
* A shallow copy of the built up result.
|
|
918
|
+
*/ build() {
|
|
919
|
+
return { ...this._result };
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region src/util/body-init.mts
|
|
974
924
|
/**
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
*/ set(endpoint, verb, invoke) {
|
|
988
|
-
this._mapping[endpoint] = this._mapping[endpoint] || {};
|
|
989
|
-
this._mapping[endpoint][verb] = typeof invoke === "function" ? invoke : ()=>invoke;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
* Invokes the request given the allowed api implementations.
|
|
993
|
-
*
|
|
994
|
-
* @param req -
|
|
995
|
-
* The request that has been made.
|
|
996
|
-
*
|
|
997
|
-
* @returns
|
|
998
|
-
* A promise that resolves with the given result if the status code is less than 400.
|
|
999
|
-
* Any status code above 400 will result in a rejected promise.
|
|
1000
|
-
*/ async request(req) {
|
|
1001
|
-
const endpointConfig = this._mapping[req.url];
|
|
1002
|
-
const result = endpointConfig?.[req.method];
|
|
1003
|
-
if (result == null) {
|
|
1004
|
-
const notFound = new ZHttpResultBuilder(null).status(ZHttpCodeClient.NotFound).build();
|
|
1005
|
-
return Promise.reject(notFound);
|
|
1006
|
-
}
|
|
1007
|
-
const errorThreshold = 400;
|
|
1008
|
-
const intermediate = await result(req);
|
|
1009
|
-
return +intermediate.status < errorThreshold ? Promise.resolve(intermediate) : Promise.reject(intermediate);
|
|
1010
|
-
}
|
|
1011
|
-
constructor(){
|
|
1012
|
-
_define_property(this, "_mapping", {});
|
|
1013
|
-
}
|
|
925
|
+
* A method that determines if an object conforms to a Request BodyInit shape.
|
|
926
|
+
*
|
|
927
|
+
* See the BodyInit interface for more information about the possible
|
|
928
|
+
* shapes.
|
|
929
|
+
*
|
|
930
|
+
* @param obj -
|
|
931
|
+
* The object to test.
|
|
932
|
+
*
|
|
933
|
+
* @returns
|
|
934
|
+
* True if obj is a BodyInit shape, false otherwise.
|
|
935
|
+
*/ function isBodyInit(obj) {
|
|
936
|
+
return obj == null || typeof obj === "string" || obj instanceof Blob || obj instanceof ArrayBuffer || ArrayBuffer.isView(obj) || obj instanceof FormData || obj instanceof URLSearchParams || obj instanceof ReadableStream;
|
|
1014
937
|
}
|
|
1015
|
-
|
|
1016
938
|
/**
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
939
|
+
* A helper method that converts an object to a BodyInit.
|
|
940
|
+
*
|
|
941
|
+
* If obj is not a BodyInit supported object, then it will
|
|
942
|
+
* simply be converted to JSON.
|
|
943
|
+
*
|
|
944
|
+
* @param obj -
|
|
945
|
+
* The object to convert.
|
|
946
|
+
*
|
|
947
|
+
* @returns
|
|
948
|
+
* Obj as a body init serialization. If obj is not
|
|
949
|
+
* compatible with a BodyInit shape, then it is converted
|
|
950
|
+
* to JSON.
|
|
951
|
+
*/ function toBodyInit(obj) {
|
|
952
|
+
return isBodyInit(obj) ? obj : JSON.stringify(obj);
|
|
1029
953
|
}
|
|
954
|
+
//#endregion
|
|
955
|
+
//#region src/util/content-type.mts
|
|
1030
956
|
/**
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
* compatible with a BodyInit shape, then it is converted
|
|
1042
|
-
* to JSON.
|
|
1043
|
-
*/ function toBodyInit(obj) {
|
|
1044
|
-
return isBodyInit(obj) ? obj : JSON.stringify(obj);
|
|
957
|
+
* A helper method that takes an HTTP Fetch Response and converts the body data based on its
|
|
958
|
+
* content type.
|
|
959
|
+
*
|
|
960
|
+
* This will favor a blob as the default type.
|
|
961
|
+
*/ function fromContentType(res) {
|
|
962
|
+
const contentType = res.headers.get("content-type");
|
|
963
|
+
if (contentType?.startsWith("application/json") || contentType?.endsWith("+json")) return res.json();
|
|
964
|
+
if (contentType?.startsWith("multipart/form-data")) return res.formData();
|
|
965
|
+
if (contentType?.startsWith("text") || contentType?.endsWith("+xml")) return res.text();
|
|
966
|
+
return res.blob();
|
|
1045
967
|
}
|
|
1046
|
-
|
|
968
|
+
//#endregion
|
|
969
|
+
//#region src/service/http-result-error.mts
|
|
970
|
+
var ZHttpResultError = class extends Error {
|
|
971
|
+
status;
|
|
972
|
+
headers;
|
|
973
|
+
data;
|
|
974
|
+
constructor(result) {
|
|
975
|
+
super(getHttpCodeName(result.status));
|
|
976
|
+
this.status = result.status;
|
|
977
|
+
this.headers = result.headers;
|
|
978
|
+
this.data = result.data;
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/service/http-service.mts
|
|
1047
983
|
/**
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
984
|
+
* Represents an axios based implementation of the http service.
|
|
985
|
+
*/ var ZHttpService = class {
|
|
986
|
+
/**
|
|
987
|
+
* Invokes the request with a real http service.
|
|
988
|
+
*
|
|
989
|
+
* @param req -
|
|
990
|
+
* The request information to make.
|
|
991
|
+
*/ async request(req) {
|
|
992
|
+
try {
|
|
993
|
+
const res = await fetch(req.url, {
|
|
994
|
+
method: req.method,
|
|
995
|
+
body: isBodyInit(req.body) ? req.body : JSON.stringify(req.body),
|
|
996
|
+
headers: req.headers,
|
|
997
|
+
redirect: "follow"
|
|
998
|
+
});
|
|
999
|
+
const result = new ZHttpResultBuilder(await fromContentType(res)).headers(res.headers).status(res.status).build();
|
|
1000
|
+
return res.ok ? Promise.resolve(result) : Promise.reject(new ZHttpResultError(result));
|
|
1001
|
+
} catch (e) {
|
|
1002
|
+
let result = new ZHttpResultBuilder(e.message).headers().status(ZHttpCodeServer.InternalServerError);
|
|
1003
|
+
if (e.code === "ENOTFOUND") result = result.status(ZHttpCodeClient.NotFound);
|
|
1004
|
+
return Promise.reject(new ZHttpResultError(result.build()));
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
//#endregion
|
|
1009
|
+
//#region src/service/http-service-mock.mts
|
|
1066
1010
|
/**
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1011
|
+
* Represents a mock http service that can be useful for demos,
|
|
1012
|
+
* testing, and pre-api implementations.
|
|
1013
|
+
*/ var ZHttpServiceMock = class {
|
|
1014
|
+
_mapping = {};
|
|
1015
|
+
/**
|
|
1016
|
+
* Sets the result of a given endpoint.
|
|
1017
|
+
*
|
|
1018
|
+
* @param endpoint -
|
|
1019
|
+
* The endpoint to set.
|
|
1020
|
+
* @param verb -
|
|
1021
|
+
* The endpoint verb to respond to.
|
|
1022
|
+
* @param invoke -
|
|
1023
|
+
* The result method. If this is falsy, then the endpoint is removed.
|
|
1024
|
+
*/ set(endpoint, verb, invoke) {
|
|
1025
|
+
this._mapping[endpoint] = this._mapping[endpoint] || {};
|
|
1026
|
+
this._mapping[endpoint][verb] = typeof invoke === "function" ? invoke : () => invoke;
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Invokes the request given the allowed api implementations.
|
|
1030
|
+
*
|
|
1031
|
+
* @param req -
|
|
1032
|
+
* The request that has been made.
|
|
1033
|
+
*
|
|
1034
|
+
* @returns
|
|
1035
|
+
* A promise that resolves with the given result if the status code is less than 400.
|
|
1036
|
+
* Any status code above 400 will result in a rejected promise.
|
|
1037
|
+
*/ async request(req) {
|
|
1038
|
+
const result = this._mapping[req.url]?.[req.method];
|
|
1039
|
+
if (result == null) {
|
|
1040
|
+
const notFound = new ZHttpResultBuilder(null).status(ZHttpCodeClient.NotFound).build();
|
|
1041
|
+
return Promise.reject(new ZHttpResultError(notFound));
|
|
1042
|
+
}
|
|
1043
|
+
const errorThreshold = 400;
|
|
1044
|
+
const intermediate = await result(req);
|
|
1045
|
+
return +intermediate.status < errorThreshold ? Promise.resolve(intermediate) : Promise.reject(new ZHttpResultError(intermediate));
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
//#endregion
|
|
1096
1049
|
export { ZHttpCodeCategory, ZHttpCodeClient, ZHttpCodeClientDescriptions, ZHttpCodeClientNames, ZHttpCodeInformationalResponse, ZHttpCodeInformationalResponseDescriptions, ZHttpCodeInformationalResponseNames, ZHttpCodeRedirection, ZHttpCodeRedirectionDescriptions, ZHttpCodeRedirectionNames, ZHttpCodeServer, ZHttpCodeServerDescriptions, ZHttpCodeServerNames, ZHttpCodeSeverity, ZHttpCodeSuccess, ZHttpCodeSuccessDescriptions, ZHttpCodeSuccessNames, ZHttpMethod, ZHttpRequestBuilder, ZHttpResultBuilder, ZHttpService, ZHttpServiceMock, fromContentType, getHttpCodeCategory, getHttpCodeDescription, getHttpCodeName, getHttpCodeSeverity, isBodyInit, toBodyInit };
|
|
1097
|
-
|
|
1050
|
+
|
|
1051
|
+
//# sourceMappingURL=index.js.map
|