|
9 | 9 | kGetNetConnect
|
10 | 10 | } = require('./mock-symbols')
|
11 | 11 | const { buildURL, nop } = require('../core/util')
|
| 12 | +const { STATUS_CODES } = require('http') |
12 | 13 |
|
13 | 14 | function matchValue (match, value) {
|
14 | 15 | if (typeof match === 'string') {
|
@@ -190,72 +191,7 @@ function generateKeyValues (data) {
|
190 | 191 | * @param {number} statusCode
|
191 | 192 | */
|
192 | 193 | function getStatusText (statusCode) {
|
193 |
| - switch (statusCode) { |
194 |
| - case 100: return 'Continue' |
195 |
| - case 101: return 'Switching Protocols' |
196 |
| - case 102: return 'Processing' |
197 |
| - case 103: return 'Early Hints' |
198 |
| - case 200: return 'OK' |
199 |
| - case 201: return 'Created' |
200 |
| - case 202: return 'Accepted' |
201 |
| - case 203: return 'Non-Authoritative Information' |
202 |
| - case 204: return 'No Content' |
203 |
| - case 205: return 'Reset Content' |
204 |
| - case 206: return 'Partial Content' |
205 |
| - case 207: return 'Multi-Status' |
206 |
| - case 208: return 'Already Reported' |
207 |
| - case 226: return 'IM Used' |
208 |
| - case 300: return 'Multiple Choice' |
209 |
| - case 301: return 'Moved Permanently' |
210 |
| - case 302: return 'Found' |
211 |
| - case 303: return 'See Other' |
212 |
| - case 304: return 'Not Modified' |
213 |
| - case 305: return 'Use Proxy' |
214 |
| - case 306: return 'unused' |
215 |
| - case 307: return 'Temporary Redirect' |
216 |
| - case 308: return 'Permanent Redirect' |
217 |
| - case 400: return 'Bad Request' |
218 |
| - case 401: return 'Unauthorized' |
219 |
| - case 402: return 'Payment Required' |
220 |
| - case 403: return 'Forbidden' |
221 |
| - case 404: return 'Not Found' |
222 |
| - case 405: return 'Method Not Allowed' |
223 |
| - case 406: return 'Not Acceptable' |
224 |
| - case 407: return 'Proxy Authentication Required' |
225 |
| - case 408: return 'Request Timeout' |
226 |
| - case 409: return 'Conflict' |
227 |
| - case 410: return 'Gone' |
228 |
| - case 411: return 'Length Required' |
229 |
| - case 412: return 'Precondition Failed' |
230 |
| - case 413: return 'Payload Too Large' |
231 |
| - case 414: return 'URI Too Large' |
232 |
| - case 415: return 'Unsupported Media Type' |
233 |
| - case 416: return 'Range Not Satisfiable' |
234 |
| - case 417: return 'Expectation Failed' |
235 |
| - case 418: return 'I\'m a teapot' |
236 |
| - case 421: return 'Misdirected Request' |
237 |
| - case 422: return 'Unprocessable Entity' |
238 |
| - case 423: return 'Locked' |
239 |
| - case 424: return 'Failed Dependency' |
240 |
| - case 425: return 'Too Early' |
241 |
| - case 426: return 'Upgrade Required' |
242 |
| - case 428: return 'Precondition Required' |
243 |
| - case 429: return 'Too Many Requests' |
244 |
| - case 431: return 'Request Header Fields Too Large' |
245 |
| - case 451: return 'Unavailable For Legal Reasons' |
246 |
| - case 500: return 'Internal Server Error' |
247 |
| - case 501: return 'Not Implemented' |
248 |
| - case 502: return 'Bad Gateway' |
249 |
| - case 503: return 'Service Unavailable' |
250 |
| - case 504: return 'Gateway Timeout' |
251 |
| - case 505: return 'HTTP Version Not Supported' |
252 |
| - case 506: return 'Variant Also Negotiates' |
253 |
| - case 507: return 'Insufficient Storage' |
254 |
| - case 508: return 'Loop Detected' |
255 |
| - case 510: return 'Not Extended' |
256 |
| - case 511: return 'Network Authentication Required' |
257 |
| - default: return 'unknown' |
258 |
| - } |
| 194 | + return STATUS_CODES[statusCode] || 'unknown' |
259 | 195 | }
|
260 | 196 |
|
261 | 197 | async function getResponse (body) {
|
|
0 commit comments