@taquito/http-utils 17.3.2 → 17.4.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.
@@ -15,6 +15,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
15
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
16
  PERFORMANCE OF THIS SOFTWARE.
17
17
  ***************************************************************************** */
18
+ /* global Reflect, Promise, SuppressedError, Symbol */
19
+
18
20
 
19
21
  function __awaiter(thisArg, _arguments, P, generator) {
20
22
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -31,678 +33,679 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
31
33
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
34
  };
33
35
 
34
- /* eslint-disable @typescript-eslint/no-var-requires */
35
- const settle = require('axios/lib/core/settle');
36
- const buildURL = require('axios/lib/helpers/buildURL');
37
- const buildFullPath = require('axios/lib/core/buildFullPath');
38
- const { isUndefined, isStandardBrowserEnv, isFormData } = require('axios/lib/utils');
39
- /**
40
- * - Create a request object
41
- * - Get response body
42
- * - Check if timeout
43
- */
44
- function fetchAdapter(config) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const request = createRequest(config);
47
- const promiseChain = [getResponse(request, config)];
48
- if (config.timeout && config.timeout > 0) {
49
- promiseChain.push(new Promise((res) => {
50
- setTimeout(() => {
51
- const message = config.timeoutErrorMessage
52
- ? config.timeoutErrorMessage
53
- : 'timeout of ' + config.timeout + 'ms exceeded';
54
- res(createError(message, config, 'ECONNABORTED', request));
55
- }, config.timeout);
56
- }));
57
- }
58
- const data = yield Promise.race(promiseChain);
59
- return new Promise((resolve, reject) => {
60
- if (data instanceof Error) {
61
- reject(data);
62
- }
63
- else {
64
- const c = config;
65
- 'settle' in c && Object.prototype.toString.call(c.settle) === '[object Function]'
66
- ? c.settle(resolve, reject, data)
67
- : settle(resolve, reject, data);
68
- }
69
- });
70
- });
71
- }
72
- /**
73
- * Fetch API stage two is to get response body. This function tries to retrieve
74
- * response body based on response's type
75
- */
76
- function getResponse(request, config) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- try {
79
- const stageOne = yield fetch(request);
80
- let response = {
81
- ok: stageOne.ok,
82
- status: stageOne.status,
83
- statusText: stageOne.statusText,
84
- headers: new Headers(stageOne.headers),
85
- config: config,
86
- request,
87
- };
88
- if (stageOne.status >= 400) {
89
- return createError('Response Error', config, 'ERR_NETWORK', request, response);
90
- }
91
- response = {
92
- ok: stageOne.ok,
93
- status: stageOne.status,
94
- statusText: stageOne.statusText,
95
- headers: new Headers(stageOne.headers),
96
- config: config,
97
- request,
98
- };
99
- if (stageOne.status >= 200 && stageOne.status !== 204) {
100
- switch (config.responseType) {
101
- case 'arraybuffer':
102
- response.data = yield stageOne.arrayBuffer();
103
- break;
104
- case 'blob':
105
- response.data = yield stageOne.blob();
106
- break;
107
- case 'json':
108
- response.data = yield stageOne.json();
109
- break;
110
- // TODO: the next option does not exist in response type
111
- // case 'formData':
112
- // response.data = await stageOne.formData();
113
- // break;
114
- default:
115
- response.data = yield stageOne.text();
116
- break;
117
- }
118
- }
119
- return response;
120
- }
121
- catch (e) {
122
- return createError('Network Error', config, 'ERR_NETWORK', request);
123
- }
124
- });
125
- }
126
- /**
127
- * This function will create a Request object based on configuration's axios
128
- */
129
- function createRequest(config) {
130
- var _a;
131
- const headers = new Headers(config.headers);
132
- // HTTP basic authentication
133
- if (config.auth) {
134
- const username = config.auth.username || '';
135
- const password = config.auth.password
136
- ? decodeURI(encodeURIComponent(config.auth.password))
137
- : '';
138
- headers.set('Authorization', `Basic ${btoa(username + ':' + password)}`);
139
- }
140
- const method = (_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase();
141
- const options = {
142
- headers: headers,
143
- method,
144
- };
145
- if (method !== 'GET' && method !== 'HEAD') {
146
- options.body = config.data;
147
- // In these cases the browser will automatically set the correct Content-Type,
148
- // but only if that header hasn't been set yet. So that's why we're deleting it.
149
- if (isFormData(options.body) && isStandardBrowserEnv()) {
150
- headers.delete('Content-Type');
151
- }
152
- }
153
- const c = config;
154
- if ('mode' in c) {
155
- options.mode = c.mode;
156
- }
157
- if ('cache' in c) {
158
- options.cache = c.cache;
159
- }
160
- if ('integrity' in c) {
161
- options.integrity = c.integrity;
162
- }
163
- if ('redirect' in c) {
164
- options.redirect = c.redirect;
165
- }
166
- if ('referrer' in c) {
167
- options.referrer = c.referrer;
168
- }
169
- // This config is similar to XHR’s withCredentials flag, but with three available values instead of two.
170
- // So if withCredentials is not set, default value 'same-origin' will be used
171
- if (!isUndefined(c.withCredentials)) {
172
- options.credentials = c.withCredentials ? 'include' : 'omit';
173
- }
174
- const fullPath = buildFullPath(c.baseURL, c.url);
175
- const url = buildURL(fullPath, c.params, c.paramsSerializer);
176
- // Expected browser to throw error if there is any wrong configuration value
177
- return new Request(url, options);
178
- }
179
- /**
180
- * Note:
181
- *
182
- * From version >= 0.27.0, createError function is replaced by AxiosError class.
183
- * So I copy the old createError function here for backward compatible.
184
- *
185
- *
186
- *
187
- * Create an Error with the specified message, config, error code, request and response.
188
- *
189
- * @param {string} message The error message.
190
- * @param {Object} config The config.
191
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
192
- * @param {Object} [request] The request.
193
- * @param {Object} [response] The response.
194
- * @returns {Error} The created error.
195
- */
196
- function createError(message, config, code, request, response) {
197
- // TODO: this code never runs
198
- // if ('AxiosError' in axios && axios.AxiosError && typeof axios.AxiosError === 'function' && isConstructor(axios.AxiosError)) {
199
- // return new axios.AxiosError(message, axios.AxiosError[code], config, request, response);
200
- // }
201
- const error = new Error(message);
202
- return enhanceError(error, config, code, request, response);
203
- }
204
- /**
205
- *
206
- * Note:
207
- *
208
- * This function is for backward compatible.
209
- *
210
- *
211
- * Update an Error with the specified config, error code, and response.
212
- *
213
- * @param {Error} error The error to update.
214
- * @param {Object} config The config.
215
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
216
- * @param {Object} [request] The request.
217
- * @param {Object} [response] The response.
218
- * @returns {Error} The error.
219
- */
220
- function enhanceError(error, config, code, request, response) {
221
- error.config = config;
222
- if (code) {
223
- error.code = code;
224
- }
225
- error.request = request;
226
- error.response = response;
227
- error.isAxiosError = true;
228
- error.toJSON = function toJSON() {
229
- return {
230
- // Standard
231
- message: this.message,
232
- name: this.name,
233
- // Microsoft
234
- description: 'description' in this ? this.description : undefined,
235
- number: 'number' in this ? this.number : undefined,
236
- // Mozilla
237
- fileName: 'fileName' in this ? this.fileName : undefined,
238
- lineNumber: 'lineNumber' in this ? this.lineNumber : undefined,
239
- columnNumber: 'columnNumber' in this ? this.columnNumber : undefined,
240
- stack: this.stack,
241
- // Axios
242
- config: this.config,
243
- code: this.code,
244
- status: this.response && this.response.status ? this.response.status : null,
245
- };
246
- };
247
- return error;
36
+ /* eslint-disable @typescript-eslint/no-var-requires */
37
+ /* eslint-disable @typescript-eslint/no-explicit-any */
38
+ const settle = require('axios/lib/core/settle');
39
+ const buildURL = require('axios/lib/helpers/buildURL');
40
+ const buildFullPath = require('axios/lib/core/buildFullPath');
41
+ const { isUndefined, isStandardBrowserEnv, isFormData } = require('axios/lib/utils');
42
+ /**
43
+ * - Create a request object
44
+ * - Get response body
45
+ * - Check if timeout
46
+ */
47
+ function fetchAdapter(config) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const request = createRequest(config);
50
+ const promiseChain = [getResponse(request, config)];
51
+ if (config.timeout && config.timeout > 0) {
52
+ promiseChain.push(new Promise((res) => {
53
+ setTimeout(() => {
54
+ const message = config.timeoutErrorMessage
55
+ ? config.timeoutErrorMessage
56
+ : 'timeout of ' + config.timeout + 'ms exceeded';
57
+ res(createError(message, config, 'ECONNABORTED', request));
58
+ }, config.timeout);
59
+ }));
60
+ }
61
+ const data = yield Promise.race(promiseChain);
62
+ return new Promise((resolve, reject) => {
63
+ if (data instanceof Error) {
64
+ reject(data);
65
+ }
66
+ else {
67
+ const c = config;
68
+ 'settle' in c && Object.prototype.toString.call(c.settle) === '[object Function]'
69
+ ? c.settle(resolve, reject, data)
70
+ : settle(resolve, reject, data);
71
+ }
72
+ });
73
+ });
74
+ }
75
+ /**
76
+ * Fetch API stage two is to get response body. This function tries to retrieve
77
+ * response body based on response's type
78
+ */
79
+ function getResponse(request, config) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ try {
82
+ const stageOne = yield fetch(request);
83
+ let response = {
84
+ ok: stageOne.ok,
85
+ status: stageOne.status,
86
+ statusText: stageOne.statusText,
87
+ headers: new Headers(stageOne.headers),
88
+ config: config,
89
+ request,
90
+ };
91
+ if (stageOne.status >= 400) {
92
+ return createError('Response Error', config, 'ERR_NETWORK', request, response);
93
+ }
94
+ response = {
95
+ ok: stageOne.ok,
96
+ status: stageOne.status,
97
+ statusText: stageOne.statusText,
98
+ headers: new Headers(stageOne.headers),
99
+ config: config,
100
+ request,
101
+ };
102
+ if (stageOne.status >= 200 && stageOne.status !== 204) {
103
+ switch (config.responseType) {
104
+ case 'arraybuffer':
105
+ response.data = yield stageOne.arrayBuffer();
106
+ break;
107
+ case 'blob':
108
+ response.data = yield stageOne.blob();
109
+ break;
110
+ case 'json':
111
+ response.data = yield stageOne.json();
112
+ break;
113
+ // TODO: the next option does not exist in response type
114
+ // case 'formData':
115
+ // response.data = await stageOne.formData();
116
+ // break;
117
+ default:
118
+ response.data = yield stageOne.text();
119
+ break;
120
+ }
121
+ }
122
+ return response;
123
+ }
124
+ catch (e) {
125
+ return createError('Network Error', config, 'ERR_NETWORK', request);
126
+ }
127
+ });
128
+ }
129
+ /**
130
+ * This function will create a Request object based on configuration's axios
131
+ */
132
+ function createRequest(config) {
133
+ var _a;
134
+ const headers = new Headers(config.headers);
135
+ // HTTP basic authentication
136
+ if (config.auth) {
137
+ const username = config.auth.username || '';
138
+ const password = config.auth.password
139
+ ? decodeURI(encodeURIComponent(config.auth.password))
140
+ : '';
141
+ headers.set('Authorization', `Basic ${btoa(username + ':' + password)}`);
142
+ }
143
+ const method = (_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase();
144
+ const options = {
145
+ headers: headers,
146
+ method,
147
+ };
148
+ if (method !== 'GET' && method !== 'HEAD') {
149
+ options.body = config.data;
150
+ // In these cases the browser will automatically set the correct Content-Type,
151
+ // but only if that header hasn't been set yet. So that's why we're deleting it.
152
+ if (isFormData(options.body) && isStandardBrowserEnv()) {
153
+ headers.delete('Content-Type');
154
+ }
155
+ }
156
+ const c = config;
157
+ if ('mode' in c) {
158
+ options.mode = c.mode;
159
+ }
160
+ if ('cache' in c) {
161
+ options.cache = c.cache;
162
+ }
163
+ if ('integrity' in c) {
164
+ options.integrity = c.integrity;
165
+ }
166
+ if ('redirect' in c) {
167
+ options.redirect = c.redirect;
168
+ }
169
+ if ('referrer' in c) {
170
+ options.referrer = c.referrer;
171
+ }
172
+ // This config is similar to XHR’s withCredentials flag, but with three available values instead of two.
173
+ // So if withCredentials is not set, default value 'same-origin' will be used
174
+ if (!isUndefined(c.withCredentials)) {
175
+ options.credentials = c.withCredentials ? 'include' : 'omit';
176
+ }
177
+ const fullPath = buildFullPath(c.baseURL, c.url);
178
+ const url = buildURL(fullPath, c.params, c.paramsSerializer);
179
+ // Expected browser to throw error if there is any wrong configuration value
180
+ return new Request(url, options);
181
+ }
182
+ /**
183
+ * Note:
184
+ *
185
+ * From version >= 0.27.0, createError function is replaced by AxiosError class.
186
+ * So I copy the old createError function here for backward compatible.
187
+ *
188
+ *
189
+ *
190
+ * Create an Error with the specified message, config, error code, request and response.
191
+ *
192
+ * @param {string} message The error message.
193
+ * @param {Object} config The config.
194
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
195
+ * @param {Object} [request] The request.
196
+ * @param {Object} [response] The response.
197
+ * @returns {Error} The created error.
198
+ */
199
+ function createError(message, config, code, request, response) {
200
+ // TODO: this code never runs
201
+ // if ('AxiosError' in axios && axios.AxiosError && typeof axios.AxiosError === 'function' && isConstructor(axios.AxiosError)) {
202
+ // return new axios.AxiosError(message, axios.AxiosError[code], config, request, response);
203
+ // }
204
+ const error = new Error(message);
205
+ return enhanceError(error, config, code, request, response);
206
+ }
207
+ /**
208
+ *
209
+ * Note:
210
+ *
211
+ * This function is for backward compatible.
212
+ *
213
+ *
214
+ * Update an Error with the specified config, error code, and response.
215
+ *
216
+ * @param {Error} error The error to update.
217
+ * @param {Object} config The config.
218
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
219
+ * @param {Object} [request] The request.
220
+ * @param {Object} [response] The response.
221
+ * @returns {Error} The error.
222
+ */
223
+ function enhanceError(error, config, code, request, response) {
224
+ error.config = config;
225
+ if (code) {
226
+ error.code = code;
227
+ }
228
+ error.request = request;
229
+ error.response = response;
230
+ error.isAxiosError = true;
231
+ error.toJSON = function toJSON() {
232
+ return {
233
+ // Standard
234
+ message: this.message,
235
+ name: this.name,
236
+ // Microsoft
237
+ description: 'description' in this ? this.description : undefined,
238
+ number: 'number' in this ? this.number : undefined,
239
+ // Mozilla
240
+ fileName: 'fileName' in this ? this.fileName : undefined,
241
+ lineNumber: 'lineNumber' in this ? this.lineNumber : undefined,
242
+ columnNumber: 'columnNumber' in this ? this.columnNumber : undefined,
243
+ stack: this.stack,
244
+ // Axios
245
+ config: this.config,
246
+ code: this.code,
247
+ status: this.response && this.response.status ? this.response.status : null,
248
+ };
249
+ };
250
+ return error;
248
251
  }
249
252
 
250
- /**
251
- * @category Error
252
- * @description Error that indicates a general failure in making the HTTP request
253
- */
254
- class HttpRequestFailed extends NetworkError {
255
- constructor(method, url, cause) {
256
- super();
257
- this.method = method;
258
- this.url = url;
259
- this.cause = cause;
260
- this.name = 'HttpRequestFailed';
261
- this.message = `${method} ${url} ${String(cause)}`;
262
- }
263
- }
264
- /**
265
- * @category Error
266
- * @description Error thrown when the endpoint returns an HTTP error to the client
267
- */
268
- class HttpResponseError extends NetworkError {
269
- constructor(message, status, statusText, body, url) {
270
- super();
271
- this.message = message;
272
- this.status = status;
273
- this.statusText = statusText;
274
- this.body = body;
275
- this.url = url;
276
- this.name = 'HttpResponse';
277
- }
253
+ /**
254
+ * @category Error
255
+ * @description Error that indicates a general failure in making the HTTP request
256
+ */
257
+ class HttpRequestFailed extends NetworkError {
258
+ constructor(method, url, cause) {
259
+ super();
260
+ this.method = method;
261
+ this.url = url;
262
+ this.cause = cause;
263
+ this.name = 'HttpRequestFailed';
264
+ this.message = `${method} ${url} ${String(cause)}`;
265
+ }
266
+ }
267
+ /**
268
+ * @category Error
269
+ * @description Error thrown when the endpoint returns an HTTP error to the client
270
+ */
271
+ class HttpResponseError extends NetworkError {
272
+ constructor(message, status, statusText, body, url) {
273
+ super();
274
+ this.message = message;
275
+ this.status = status;
276
+ this.statusText = statusText;
277
+ this.body = body;
278
+ this.url = url;
279
+ this.name = 'HttpResponse';
280
+ }
278
281
  }
279
282
 
280
- /**
281
- * Hypertext Transfer Protocol (HTTP) response status codes.
282
- * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
283
- */
284
- var STATUS_CODE;
285
- (function (STATUS_CODE) {
286
- /**
287
- * The server has received the request headers and the client should proceed to send the request body
288
- * (in the case of a request for which a body needs to be sent; for example, a POST request).
289
- * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.
290
- * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request
291
- * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.
292
- */
293
- STATUS_CODE[STATUS_CODE["CONTINUE"] = 100] = "CONTINUE";
294
- /**
295
- * The requester has asked the server to switch protocols and the server has agreed to do so.
296
- */
297
- STATUS_CODE[STATUS_CODE["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
298
- /**
299
- * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.
300
- * This code indicates that the server has received and is processing the request, but no response is available yet.
301
- * This prevents the client from timing out and assuming the request was lost.
302
- */
303
- STATUS_CODE[STATUS_CODE["PROCESSING"] = 102] = "PROCESSING";
304
- /**
305
- * Standard response for successful HTTP requests.
306
- * The actual response will depend on the request method used.
307
- * In a GET request, the response will contain an entity corresponding to the requested resource.
308
- * In a POST request, the response will contain an entity describing or containing the result of the action.
309
- */
310
- STATUS_CODE[STATUS_CODE["OK"] = 200] = "OK";
311
- /**
312
- * The request has been fulfilled, resulting in the creation of a new resource.
313
- */
314
- STATUS_CODE[STATUS_CODE["CREATED"] = 201] = "CREATED";
315
- /**
316
- * The request has been accepted for processing, but the processing has not been completed.
317
- * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
318
- */
319
- STATUS_CODE[STATUS_CODE["ACCEPTED"] = 202] = "ACCEPTED";
320
- /**
321
- * SINCE HTTP/1.1
322
- * The server is a transforming proxy that received a 200 OK from its origin,
323
- * but is returning a modified version of the origin's response.
324
- */
325
- STATUS_CODE[STATUS_CODE["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
326
- /**
327
- * The server successfully processed the request and is not returning any content.
328
- */
329
- STATUS_CODE[STATUS_CODE["NO_CONTENT"] = 204] = "NO_CONTENT";
330
- /**
331
- * The server successfully processed the request, but is not returning any content.
332
- * Unlike a 204 response, this response requires that the requester reset the document view.
333
- */
334
- STATUS_CODE[STATUS_CODE["RESET_CONTENT"] = 205] = "RESET_CONTENT";
335
- /**
336
- * The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
337
- * The range header is used by HTTP clients to enable resuming of interrupted downloads,
338
- * or split a download into multiple simultaneous streams.
339
- */
340
- STATUS_CODE[STATUS_CODE["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
341
- /**
342
- * The message body that follows is an XML message and can contain a number of separate response codes,
343
- * depending on how many sub-requests were made.
344
- */
345
- STATUS_CODE[STATUS_CODE["MULTI_STATUS"] = 207] = "MULTI_STATUS";
346
- /**
347
- * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,
348
- * and are not being included again.
349
- */
350
- STATUS_CODE[STATUS_CODE["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
351
- /**
352
- * The server has fulfilled a request for the resource,
353
- * and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
354
- */
355
- STATUS_CODE[STATUS_CODE["IM_USED"] = 226] = "IM_USED";
356
- /**
357
- * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).
358
- * For example, this code could be used to present multiple video format options,
359
- * to list files with different filename extensions, or to suggest word-sense disambiguation.
360
- */
361
- STATUS_CODE[STATUS_CODE["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
362
- /**
363
- * This and all future requests should be directed to the given URI.
364
- */
365
- STATUS_CODE[STATUS_CODE["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
366
- /**
367
- * This is an example of industry practice contradicting the standard.
368
- * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect
369
- * (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302
370
- * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307
371
- * to distinguish between the two behaviours. However, some Web applications and frameworks
372
- * use the 302 status code as if it were the 303.
373
- */
374
- STATUS_CODE[STATUS_CODE["FOUND"] = 302] = "FOUND";
375
- /**
376
- * SINCE HTTP/1.1
377
- * The response to the request can be found under another URI using a GET method.
378
- * When received in response to a POST (or PUT/DELETE), the client should presume that
379
- * the server has received the data and should issue a redirect with a separate GET message.
380
- */
381
- STATUS_CODE[STATUS_CODE["SEE_OTHER"] = 303] = "SEE_OTHER";
382
- /**
383
- * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.
384
- * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
385
- */
386
- STATUS_CODE[STATUS_CODE["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
387
- /**
388
- * SINCE HTTP/1.1
389
- * The requested resource is available only through a proxy, the address for which is provided in the response.
390
- * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.
391
- */
392
- STATUS_CODE[STATUS_CODE["USE_PROXY"] = 305] = "USE_PROXY";
393
- /**
394
- * No longer used. Originally meant "Subsequent requests should use the specified proxy."
395
- */
396
- STATUS_CODE[STATUS_CODE["SWITCH_PROXY"] = 306] = "SWITCH_PROXY";
397
- /**
398
- * SINCE HTTP/1.1
399
- * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.
400
- * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.
401
- * For example, a POST request should be repeated using another POST request.
402
- */
403
- STATUS_CODE[STATUS_CODE["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
404
- /**
405
- * The request and all future requests should be repeated using another URI.
406
- * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
407
- * So, for example, submitting a form to a permanently redirected resource may continue smoothly.
408
- */
409
- STATUS_CODE[STATUS_CODE["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
410
- /**
411
- * The server cannot or will not process the request due to an apparent client error
412
- * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).
413
- */
414
- STATUS_CODE[STATUS_CODE["BAD_REQUEST"] = 400] = "BAD_REQUEST";
415
- /**
416
- * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet
417
- * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the
418
- * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means
419
- * "unauthenticated",i.e. the user does not have the necessary credentials.
420
- */
421
- STATUS_CODE[STATUS_CODE["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
422
- /**
423
- * Reserved for future use. The original intention was that this code might be used as part of some form of digital
424
- * cash or micro payment scheme, but that has not happened, and this code is not usually used.
425
- * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.
426
- */
427
- STATUS_CODE[STATUS_CODE["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
428
- /**
429
- * The request was valid, but the server is refusing action.
430
- * The user might not have the necessary permissions for a resource.
431
- */
432
- STATUS_CODE[STATUS_CODE["FORBIDDEN"] = 403] = "FORBIDDEN";
433
- /**
434
- * The requested resource could not be found but may be available in the future.
435
- * Subsequent requests by the client are permissible.
436
- */
437
- STATUS_CODE[STATUS_CODE["NOT_FOUND"] = 404] = "NOT_FOUND";
438
- /**
439
- * A request method is not supported for the requested resource;
440
- * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
441
- */
442
- STATUS_CODE[STATUS_CODE["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
443
- /**
444
- * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.
445
- */
446
- STATUS_CODE[STATUS_CODE["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
447
- /**
448
- * The client must first authenticate itself with the proxy.
449
- */
450
- STATUS_CODE[STATUS_CODE["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
451
- /**
452
- * The server timed out waiting for the request.
453
- * According to HTTP specifications:
454
- * "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time."
455
- */
456
- STATUS_CODE[STATUS_CODE["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
457
- /**
458
- * Indicates that the request could not be processed because of conflict in the request,
459
- * such as an edit conflict between multiple simultaneous updates.
460
- */
461
- STATUS_CODE[STATUS_CODE["CONFLICT"] = 409] = "CONFLICT";
462
- /**
463
- * Indicates that the resource requested is no longer available and will not be available again.
464
- * This should be used when a resource has been intentionally removed and the resource should be purged.
465
- * Upon receiving a 410 status code, the client should not request the resource in the future.
466
- * Clients such as search engines should remove the resource from their indices.
467
- * Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.
468
- */
469
- STATUS_CODE[STATUS_CODE["GONE"] = 410] = "GONE";
470
- /**
471
- * The request did not specify the length of its content, which is required by the requested resource.
472
- */
473
- STATUS_CODE[STATUS_CODE["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
474
- /**
475
- * The server does not meet one of the preconditions that the requester put on the request.
476
- */
477
- STATUS_CODE[STATUS_CODE["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
478
- /**
479
- * The request is larger than the server is willing or able to process. Previously called "Request Entity Too Large".
480
- */
481
- STATUS_CODE[STATUS_CODE["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
482
- /**
483
- * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,
484
- * in which case it should be converted to a POST request.
485
- * Called "Request-URI Too Long" previously.
486
- */
487
- STATUS_CODE[STATUS_CODE["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
488
- /**
489
- * The request entity has a media type which the server or resource does not support.
490
- * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.
491
- */
492
- STATUS_CODE[STATUS_CODE["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
493
- /**
494
- * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
495
- * For example, if the client asked for a part of the file that lies beyond the end of the file.
496
- * Called "Requested Range Not Satisfiable" previously.
497
- */
498
- STATUS_CODE[STATUS_CODE["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
499
- /**
500
- * The server cannot meet the requirements of the Expect request-header field.
501
- */
502
- STATUS_CODE[STATUS_CODE["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
503
- /**
504
- * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,
505
- * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by
506
- * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.
507
- */
508
- STATUS_CODE[STATUS_CODE["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
509
- /**
510
- * The request was directed at a server that is not able to produce a response (for example because a connection reuse).
511
- */
512
- STATUS_CODE[STATUS_CODE["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
513
- /**
514
- * The request was well-formed but was unable to be followed due to semantic errors.
515
- */
516
- STATUS_CODE[STATUS_CODE["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
517
- /**
518
- * The resource that is being accessed is locked.
519
- */
520
- STATUS_CODE[STATUS_CODE["LOCKED"] = 423] = "LOCKED";
521
- /**
522
- * The request failed due to failure of a previous request (e.g., a PROPPATCH).
523
- */
524
- STATUS_CODE[STATUS_CODE["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
525
- /**
526
- * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
527
- */
528
- STATUS_CODE[STATUS_CODE["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
529
- /**
530
- * The origin server requires the request to be conditional.
531
- * Intended to prevent "the 'lost update' problem, where a client
532
- * GETs a resource's state, modifies it, and PUTs it back to the server,
533
- * when meanwhile a third party has modified the state on the server, leading to a conflict."
534
- */
535
- STATUS_CODE[STATUS_CODE["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
536
- /**
537
- * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
538
- */
539
- STATUS_CODE[STATUS_CODE["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
540
- /**
541
- * The server is unwilling to process the request because either an individual header field,
542
- * or all the header fields collectively, are too large.
543
- */
544
- STATUS_CODE[STATUS_CODE["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
545
- /**
546
- * A server operator has received a legal demand to deny access to a resource or to a set of resources
547
- * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.
548
- */
549
- STATUS_CODE[STATUS_CODE["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
550
- /**
551
- * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
552
- */
553
- STATUS_CODE[STATUS_CODE["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
554
- /**
555
- * The server either does not recognize the request method, or it lacks the ability to fulfill the request.
556
- * Usually this implies future availability (e.g., a new feature of a web-service API).
557
- */
558
- STATUS_CODE[STATUS_CODE["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
559
- /**
560
- * The server was acting as a gateway or proxy and received an invalid response from the upstream server.
561
- */
562
- STATUS_CODE[STATUS_CODE["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
563
- /**
564
- * The server is currently unavailable (because it is overloaded or down for maintenance).
565
- * Generally, this is a temporary state.
566
- */
567
- STATUS_CODE[STATUS_CODE["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
568
- /**
569
- * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
570
- */
571
- STATUS_CODE[STATUS_CODE["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
572
- /**
573
- * The server does not support the HTTP protocol version used in the request
574
- */
575
- STATUS_CODE[STATUS_CODE["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
576
- /**
577
- * Transparent content negotiation for the request results in a circular reference.
578
- */
579
- STATUS_CODE[STATUS_CODE["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
580
- /**
581
- * The server is unable to store the representation needed to complete the request.
582
- */
583
- STATUS_CODE[STATUS_CODE["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
584
- /**
585
- * The server detected an infinite loop while processing the request.
586
- */
587
- STATUS_CODE[STATUS_CODE["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
588
- /**
589
- * Further extensions to the request are required for the server to fulfill it.
590
- */
591
- STATUS_CODE[STATUS_CODE["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
592
- /**
593
- * The client needs to authenticate to gain network access.
594
- * Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used
595
- * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
596
- */
597
- STATUS_CODE[STATUS_CODE["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
283
+ /**
284
+ * Hypertext Transfer Protocol (HTTP) response status codes.
285
+ * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
286
+ */
287
+ var STATUS_CODE;
288
+ (function (STATUS_CODE) {
289
+ /**
290
+ * The server has received the request headers and the client should proceed to send the request body
291
+ * (in the case of a request for which a body needs to be sent; for example, a POST request).
292
+ * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.
293
+ * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request
294
+ * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.
295
+ */
296
+ STATUS_CODE[STATUS_CODE["CONTINUE"] = 100] = "CONTINUE";
297
+ /**
298
+ * The requester has asked the server to switch protocols and the server has agreed to do so.
299
+ */
300
+ STATUS_CODE[STATUS_CODE["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
301
+ /**
302
+ * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.
303
+ * This code indicates that the server has received and is processing the request, but no response is available yet.
304
+ * This prevents the client from timing out and assuming the request was lost.
305
+ */
306
+ STATUS_CODE[STATUS_CODE["PROCESSING"] = 102] = "PROCESSING";
307
+ /**
308
+ * Standard response for successful HTTP requests.
309
+ * The actual response will depend on the request method used.
310
+ * In a GET request, the response will contain an entity corresponding to the requested resource.
311
+ * In a POST request, the response will contain an entity describing or containing the result of the action.
312
+ */
313
+ STATUS_CODE[STATUS_CODE["OK"] = 200] = "OK";
314
+ /**
315
+ * The request has been fulfilled, resulting in the creation of a new resource.
316
+ */
317
+ STATUS_CODE[STATUS_CODE["CREATED"] = 201] = "CREATED";
318
+ /**
319
+ * The request has been accepted for processing, but the processing has not been completed.
320
+ * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
321
+ */
322
+ STATUS_CODE[STATUS_CODE["ACCEPTED"] = 202] = "ACCEPTED";
323
+ /**
324
+ * SINCE HTTP/1.1
325
+ * The server is a transforming proxy that received a 200 OK from its origin,
326
+ * but is returning a modified version of the origin's response.
327
+ */
328
+ STATUS_CODE[STATUS_CODE["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
329
+ /**
330
+ * The server successfully processed the request and is not returning any content.
331
+ */
332
+ STATUS_CODE[STATUS_CODE["NO_CONTENT"] = 204] = "NO_CONTENT";
333
+ /**
334
+ * The server successfully processed the request, but is not returning any content.
335
+ * Unlike a 204 response, this response requires that the requester reset the document view.
336
+ */
337
+ STATUS_CODE[STATUS_CODE["RESET_CONTENT"] = 205] = "RESET_CONTENT";
338
+ /**
339
+ * The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
340
+ * The range header is used by HTTP clients to enable resuming of interrupted downloads,
341
+ * or split a download into multiple simultaneous streams.
342
+ */
343
+ STATUS_CODE[STATUS_CODE["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
344
+ /**
345
+ * The message body that follows is an XML message and can contain a number of separate response codes,
346
+ * depending on how many sub-requests were made.
347
+ */
348
+ STATUS_CODE[STATUS_CODE["MULTI_STATUS"] = 207] = "MULTI_STATUS";
349
+ /**
350
+ * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,
351
+ * and are not being included again.
352
+ */
353
+ STATUS_CODE[STATUS_CODE["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
354
+ /**
355
+ * The server has fulfilled a request for the resource,
356
+ * and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
357
+ */
358
+ STATUS_CODE[STATUS_CODE["IM_USED"] = 226] = "IM_USED";
359
+ /**
360
+ * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).
361
+ * For example, this code could be used to present multiple video format options,
362
+ * to list files with different filename extensions, or to suggest word-sense disambiguation.
363
+ */
364
+ STATUS_CODE[STATUS_CODE["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
365
+ /**
366
+ * This and all future requests should be directed to the given URI.
367
+ */
368
+ STATUS_CODE[STATUS_CODE["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
369
+ /**
370
+ * This is an example of industry practice contradicting the standard.
371
+ * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect
372
+ * (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302
373
+ * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307
374
+ * to distinguish between the two behaviours. However, some Web applications and frameworks
375
+ * use the 302 status code as if it were the 303.
376
+ */
377
+ STATUS_CODE[STATUS_CODE["FOUND"] = 302] = "FOUND";
378
+ /**
379
+ * SINCE HTTP/1.1
380
+ * The response to the request can be found under another URI using a GET method.
381
+ * When received in response to a POST (or PUT/DELETE), the client should presume that
382
+ * the server has received the data and should issue a redirect with a separate GET message.
383
+ */
384
+ STATUS_CODE[STATUS_CODE["SEE_OTHER"] = 303] = "SEE_OTHER";
385
+ /**
386
+ * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.
387
+ * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
388
+ */
389
+ STATUS_CODE[STATUS_CODE["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
390
+ /**
391
+ * SINCE HTTP/1.1
392
+ * The requested resource is available only through a proxy, the address for which is provided in the response.
393
+ * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.
394
+ */
395
+ STATUS_CODE[STATUS_CODE["USE_PROXY"] = 305] = "USE_PROXY";
396
+ /**
397
+ * No longer used. Originally meant "Subsequent requests should use the specified proxy."
398
+ */
399
+ STATUS_CODE[STATUS_CODE["SWITCH_PROXY"] = 306] = "SWITCH_PROXY";
400
+ /**
401
+ * SINCE HTTP/1.1
402
+ * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.
403
+ * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.
404
+ * For example, a POST request should be repeated using another POST request.
405
+ */
406
+ STATUS_CODE[STATUS_CODE["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
407
+ /**
408
+ * The request and all future requests should be repeated using another URI.
409
+ * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
410
+ * So, for example, submitting a form to a permanently redirected resource may continue smoothly.
411
+ */
412
+ STATUS_CODE[STATUS_CODE["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
413
+ /**
414
+ * The server cannot or will not process the request due to an apparent client error
415
+ * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).
416
+ */
417
+ STATUS_CODE[STATUS_CODE["BAD_REQUEST"] = 400] = "BAD_REQUEST";
418
+ /**
419
+ * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet
420
+ * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the
421
+ * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means
422
+ * "unauthenticated",i.e. the user does not have the necessary credentials.
423
+ */
424
+ STATUS_CODE[STATUS_CODE["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
425
+ /**
426
+ * Reserved for future use. The original intention was that this code might be used as part of some form of digital
427
+ * cash or micro payment scheme, but that has not happened, and this code is not usually used.
428
+ * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.
429
+ */
430
+ STATUS_CODE[STATUS_CODE["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
431
+ /**
432
+ * The request was valid, but the server is refusing action.
433
+ * The user might not have the necessary permissions for a resource.
434
+ */
435
+ STATUS_CODE[STATUS_CODE["FORBIDDEN"] = 403] = "FORBIDDEN";
436
+ /**
437
+ * The requested resource could not be found but may be available in the future.
438
+ * Subsequent requests by the client are permissible.
439
+ */
440
+ STATUS_CODE[STATUS_CODE["NOT_FOUND"] = 404] = "NOT_FOUND";
441
+ /**
442
+ * A request method is not supported for the requested resource;
443
+ * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
444
+ */
445
+ STATUS_CODE[STATUS_CODE["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
446
+ /**
447
+ * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.
448
+ */
449
+ STATUS_CODE[STATUS_CODE["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
450
+ /**
451
+ * The client must first authenticate itself with the proxy.
452
+ */
453
+ STATUS_CODE[STATUS_CODE["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
454
+ /**
455
+ * The server timed out waiting for the request.
456
+ * According to HTTP specifications:
457
+ * "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time."
458
+ */
459
+ STATUS_CODE[STATUS_CODE["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
460
+ /**
461
+ * Indicates that the request could not be processed because of conflict in the request,
462
+ * such as an edit conflict between multiple simultaneous updates.
463
+ */
464
+ STATUS_CODE[STATUS_CODE["CONFLICT"] = 409] = "CONFLICT";
465
+ /**
466
+ * Indicates that the resource requested is no longer available and will not be available again.
467
+ * This should be used when a resource has been intentionally removed and the resource should be purged.
468
+ * Upon receiving a 410 status code, the client should not request the resource in the future.
469
+ * Clients such as search engines should remove the resource from their indices.
470
+ * Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.
471
+ */
472
+ STATUS_CODE[STATUS_CODE["GONE"] = 410] = "GONE";
473
+ /**
474
+ * The request did not specify the length of its content, which is required by the requested resource.
475
+ */
476
+ STATUS_CODE[STATUS_CODE["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
477
+ /**
478
+ * The server does not meet one of the preconditions that the requester put on the request.
479
+ */
480
+ STATUS_CODE[STATUS_CODE["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
481
+ /**
482
+ * The request is larger than the server is willing or able to process. Previously called "Request Entity Too Large".
483
+ */
484
+ STATUS_CODE[STATUS_CODE["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
485
+ /**
486
+ * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,
487
+ * in which case it should be converted to a POST request.
488
+ * Called "Request-URI Too Long" previously.
489
+ */
490
+ STATUS_CODE[STATUS_CODE["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
491
+ /**
492
+ * The request entity has a media type which the server or resource does not support.
493
+ * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.
494
+ */
495
+ STATUS_CODE[STATUS_CODE["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
496
+ /**
497
+ * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
498
+ * For example, if the client asked for a part of the file that lies beyond the end of the file.
499
+ * Called "Requested Range Not Satisfiable" previously.
500
+ */
501
+ STATUS_CODE[STATUS_CODE["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
502
+ /**
503
+ * The server cannot meet the requirements of the Expect request-header field.
504
+ */
505
+ STATUS_CODE[STATUS_CODE["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
506
+ /**
507
+ * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,
508
+ * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by
509
+ * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.
510
+ */
511
+ STATUS_CODE[STATUS_CODE["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
512
+ /**
513
+ * The request was directed at a server that is not able to produce a response (for example because a connection reuse).
514
+ */
515
+ STATUS_CODE[STATUS_CODE["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
516
+ /**
517
+ * The request was well-formed but was unable to be followed due to semantic errors.
518
+ */
519
+ STATUS_CODE[STATUS_CODE["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
520
+ /**
521
+ * The resource that is being accessed is locked.
522
+ */
523
+ STATUS_CODE[STATUS_CODE["LOCKED"] = 423] = "LOCKED";
524
+ /**
525
+ * The request failed due to failure of a previous request (e.g., a PROPPATCH).
526
+ */
527
+ STATUS_CODE[STATUS_CODE["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
528
+ /**
529
+ * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
530
+ */
531
+ STATUS_CODE[STATUS_CODE["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
532
+ /**
533
+ * The origin server requires the request to be conditional.
534
+ * Intended to prevent "the 'lost update' problem, where a client
535
+ * GETs a resource's state, modifies it, and PUTs it back to the server,
536
+ * when meanwhile a third party has modified the state on the server, leading to a conflict."
537
+ */
538
+ STATUS_CODE[STATUS_CODE["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
539
+ /**
540
+ * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
541
+ */
542
+ STATUS_CODE[STATUS_CODE["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
543
+ /**
544
+ * The server is unwilling to process the request because either an individual header field,
545
+ * or all the header fields collectively, are too large.
546
+ */
547
+ STATUS_CODE[STATUS_CODE["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
548
+ /**
549
+ * A server operator has received a legal demand to deny access to a resource or to a set of resources
550
+ * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.
551
+ */
552
+ STATUS_CODE[STATUS_CODE["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
553
+ /**
554
+ * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
555
+ */
556
+ STATUS_CODE[STATUS_CODE["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
557
+ /**
558
+ * The server either does not recognize the request method, or it lacks the ability to fulfill the request.
559
+ * Usually this implies future availability (e.g., a new feature of a web-service API).
560
+ */
561
+ STATUS_CODE[STATUS_CODE["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
562
+ /**
563
+ * The server was acting as a gateway or proxy and received an invalid response from the upstream server.
564
+ */
565
+ STATUS_CODE[STATUS_CODE["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
566
+ /**
567
+ * The server is currently unavailable (because it is overloaded or down for maintenance).
568
+ * Generally, this is a temporary state.
569
+ */
570
+ STATUS_CODE[STATUS_CODE["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
571
+ /**
572
+ * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
573
+ */
574
+ STATUS_CODE[STATUS_CODE["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
575
+ /**
576
+ * The server does not support the HTTP protocol version used in the request
577
+ */
578
+ STATUS_CODE[STATUS_CODE["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
579
+ /**
580
+ * Transparent content negotiation for the request results in a circular reference.
581
+ */
582
+ STATUS_CODE[STATUS_CODE["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
583
+ /**
584
+ * The server is unable to store the representation needed to complete the request.
585
+ */
586
+ STATUS_CODE[STATUS_CODE["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
587
+ /**
588
+ * The server detected an infinite loop while processing the request.
589
+ */
590
+ STATUS_CODE[STATUS_CODE["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
591
+ /**
592
+ * Further extensions to the request are required for the server to fulfill it.
593
+ */
594
+ STATUS_CODE[STATUS_CODE["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
595
+ /**
596
+ * The client needs to authenticate to gain network access.
597
+ * Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used
598
+ * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
599
+ */
600
+ STATUS_CODE[STATUS_CODE["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
598
601
  })(STATUS_CODE || (STATUS_CODE = {}));
599
602
 
600
- // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
601
- const VERSION = {
602
- "commitHash": "a97e506efd61b86e39ae30db588401b8fda46553",
603
- "version": "17.3.2"
603
+ // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
604
+ const VERSION = {
605
+ "commitHash": "a908ab176a8c52c025fd43e7acd452415396f54e",
606
+ "version": "17.4.0"
604
607
  };
605
608
 
606
- /**
607
- * @packageDocumentation
608
- * @module @taquito/http-utils
609
- */
610
- var _a;
611
- const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
612
- const adapter = isNode ? undefined : fetchAdapter;
613
- var ResponseType;
614
- (function (ResponseType) {
615
- ResponseType["TEXT"] = "text";
616
- ResponseType["JSON"] = "json";
617
- })(ResponseType || (ResponseType = {}));
618
- class HttpBackend {
619
- constructor(timeout = 30000) {
620
- this.timeout = timeout;
621
- }
622
- serialize(obj) {
623
- if (!obj) {
624
- return '';
625
- }
626
- const str = [];
627
- for (const p in obj) {
628
- // eslint-disable-next-line no-prototype-builtins
629
- if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {
630
- const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];
631
- // query arguments can have no value so we need some way of handling that
632
- // example https://domain.com/query?all
633
- if (prop === null) {
634
- str.push(encodeURIComponent(p));
635
- continue;
636
- }
637
- // another use case is multiple arguments with the same name
638
- // they are passed as array
639
- if (Array.isArray(prop)) {
640
- prop.forEach((item) => {
641
- str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));
642
- });
643
- continue;
644
- }
645
- str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));
646
- }
647
- }
648
- const serialized = str.join('&');
649
- if (serialized) {
650
- return `?${serialized}`;
651
- }
652
- else {
653
- return '';
654
- }
655
- }
656
- /**
657
- *
658
- * @param options contains options to be passed for the HTTP request (url, method and timeout)
659
- * @throws {@link HttpRequestFailed} | {@link HttpResponseError}
660
- */
661
- createRequest({ url, method, timeout = this.timeout, query, headers = {}, json = true }, data) {
662
- return __awaiter(this, void 0, void 0, function* () {
663
- const urlWithQuery = url + this.serialize(query);
664
- let resType;
665
- let transformResponse = undefined;
666
- if (!headers['Content-Type']) {
667
- headers['Content-Type'] = 'application/json';
668
- }
669
- if (!json) {
670
- resType = ResponseType.TEXT;
671
- transformResponse = [(v) => v];
672
- }
673
- else {
674
- resType = ResponseType.JSON;
675
- }
676
- try {
677
- const response = yield axios.request({
678
- url: urlWithQuery,
679
- method: method !== null && method !== void 0 ? method : 'GET',
680
- headers: headers,
681
- responseType: resType,
682
- transformResponse,
683
- timeout: timeout,
684
- data: data,
685
- adapter,
686
- });
687
- return response.data;
688
- }
689
- catch (err) {
690
- if ((axios.isAxiosError(err) && err.response) || (!isNode && err.response)) {
691
- let errorData;
692
- if (typeof err.response.data === 'object') {
693
- errorData = JSON.stringify(err.response.data);
694
- }
695
- else {
696
- errorData = err.response.data;
697
- }
698
- throw new HttpResponseError(`Http error response: (${err.response.status}) ${errorData}`, err.response.status, err.response.statusText, errorData, urlWithQuery);
699
- }
700
- else {
701
- throw new HttpRequestFailed(String(method), urlWithQuery, err);
702
- }
703
- }
704
- });
705
- }
609
+ /**
610
+ * @packageDocumentation
611
+ * @module @taquito/http-utils
612
+ */
613
+ var _a;
614
+ const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
615
+ const adapter = isNode ? undefined : fetchAdapter;
616
+ var ResponseType;
617
+ (function (ResponseType) {
618
+ ResponseType["TEXT"] = "text";
619
+ ResponseType["JSON"] = "json";
620
+ })(ResponseType || (ResponseType = {}));
621
+ class HttpBackend {
622
+ constructor(timeout = 30000) {
623
+ this.timeout = timeout;
624
+ }
625
+ serialize(obj) {
626
+ if (!obj) {
627
+ return '';
628
+ }
629
+ const str = [];
630
+ for (const p in obj) {
631
+ // eslint-disable-next-line no-prototype-builtins
632
+ if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {
633
+ const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];
634
+ // query arguments can have no value so we need some way of handling that
635
+ // example https://domain.com/query?all
636
+ if (prop === null) {
637
+ str.push(encodeURIComponent(p));
638
+ continue;
639
+ }
640
+ // another use case is multiple arguments with the same name
641
+ // they are passed as array
642
+ if (Array.isArray(prop)) {
643
+ prop.forEach((item) => {
644
+ str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));
645
+ });
646
+ continue;
647
+ }
648
+ str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));
649
+ }
650
+ }
651
+ const serialized = str.join('&');
652
+ if (serialized) {
653
+ return `?${serialized}`;
654
+ }
655
+ else {
656
+ return '';
657
+ }
658
+ }
659
+ /**
660
+ *
661
+ * @param options contains options to be passed for the HTTP request (url, method and timeout)
662
+ * @throws {@link HttpRequestFailed} | {@link HttpResponseError}
663
+ */
664
+ createRequest({ url, method, timeout = this.timeout, query, headers = {}, json = true }, data) {
665
+ return __awaiter(this, void 0, void 0, function* () {
666
+ const urlWithQuery = url + this.serialize(query);
667
+ let resType;
668
+ let transformResponse = undefined;
669
+ if (!headers['Content-Type']) {
670
+ headers['Content-Type'] = 'application/json';
671
+ }
672
+ if (!json) {
673
+ resType = ResponseType.TEXT;
674
+ transformResponse = [(v) => v];
675
+ }
676
+ else {
677
+ resType = ResponseType.JSON;
678
+ }
679
+ try {
680
+ const response = yield axios.request({
681
+ url: urlWithQuery,
682
+ method: method !== null && method !== void 0 ? method : 'GET',
683
+ headers: headers,
684
+ responseType: resType,
685
+ transformResponse,
686
+ timeout: timeout,
687
+ data: data,
688
+ adapter,
689
+ });
690
+ return response.data;
691
+ }
692
+ catch (err) {
693
+ if ((axios.isAxiosError(err) && err.response) || (!isNode && err.response)) {
694
+ let errorData;
695
+ if (typeof err.response.data === 'object') {
696
+ errorData = JSON.stringify(err.response.data);
697
+ }
698
+ else {
699
+ errorData = err.response.data;
700
+ }
701
+ throw new HttpResponseError(`Http error response: (${err.response.status}) ${errorData}`, err.response.status, err.response.statusText, errorData, urlWithQuery);
702
+ }
703
+ else {
704
+ throw new HttpRequestFailed(String(method), urlWithQuery, err);
705
+ }
706
+ }
707
+ });
708
+ }
706
709
  }
707
710
 
708
711
  export { HttpBackend, HttpRequestFailed, HttpResponseError, STATUS_CODE, VERSION };