diff --git a/package.json b/package.json index c7d2fef..a605c6c 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,13 @@ "description": "HTTP status codes i18n", "scripts": { "task": "nx affected -t lint test build", + "test": "nx affected -t test", "sync:version": "node ./scripts/sync-version.js", "commit": "git-cz", "changelog": "conventional-changelog --config ./commit-config/changelog-config.js -p -i -o CHANGELOG.md -r 0", "version": "conventional-changelog --config ./commit-config/changelog-config.js -p angular -i -o CHANGELOG.md -r 0 && git add CHANGELOG.md", - "release": "release-it && ./publish.sh" + "release": "release-it", + "release-ci": "npm run commit && release-it && ./publish.sh" }, "dependencies": { "tslib": "^2.3.0" diff --git a/packages/i18n-en/src/lib/helpers.ts b/packages/i18n-en/src/lib/helpers.ts index 3ab2407..562ef3b 100644 --- a/packages/i18n-en/src/lib/helpers.ts +++ b/packages/i18n-en/src/lib/helpers.ts @@ -14,341 +14,59 @@ * Happy coding! Remember, code is poetry, and front-end is art. ツ */ +import { HttpStatusCode, HttpStatusCodeByCode } from './status-code'; +import { HttpStatusText, HttpStatusTextByCode } from './status-text'; +import { HttpStatusDescriptionByCode } from './status-description'; + /** Key-value mapping of HTTP status codes and HTTP status texts. */ -export const statusCodeToStatusTextMap: Record = { - 100: "Continue", - 101: "Switching Protocols", - 102: "Processing", - 200: "OK", - 201: "Created", - 202: "Accepted", - 203: "Non-Authoritative Information", - 204: "No Content", - 205: "Reset Content", - 206: "Partial Content", - 207: "Multi-Status", - 208: "Already Reported", - 226: "IM Used", - 300: "Multiple Choices", - 301: "Moved Permanently", - 302: "Found", - 303: "See Other", - 304: "Not Modified", - 305: "Use Proxy", - 306: "Switch proxy", - 307: "Temporary Redirect", - 308: "Permanent Redirect", - 400: "Bad Request", - 401: "Unauthorized", - 402: "Payment Required", - 403: "Forbidden", - 404: "Not Found", - 405: "Method Not Allowed", - 406: "Not Acceptable", - 407: "Proxy Authentication Required", - 408: "Request Timeout", - 409: "Conflict", - 410: "Gone", - 411: "Length Required", - 412: "Precondition Failed", - 413: "Payload Too Large", - 414: "URI Too Long", - 415: "Unsupported Media Type", - 416: "Range Not Satisfiable", - 417: "Expectation Failed", - 418: "I'm a Teapot", - 421: "Misdirected Request", - 422: "Unprocessable Entity", - 423: "Locked", - 424: "Failed Dependency", - 426: "Upgrade Required", - 428: "Precondition Required", - 429: "Too Many Requests", - 431: "Request Header Fields Too Large", - 440: "Login Timeout (Microsoft)", - 444: "No Response (Nginx)", - 449: "Retry With (Microsoft)", - 450: "Blocked by Windows Parental Controls (Microsoft)", - 451: "Unavailable For Legal Reasons", - 494: "Request Header Too Large (Nginx)", - 495: "Cert Error (Nginx)", - 496: "No Cert (Nginx)", - 497: "HTTP to HTTPS (Nginx)", - 498: "Token expired/invalid (Esri)", - 499: "Token required (Esri)", - 500: "Internal Server Error", - 501: "Not Implemented", - 502: "Bad Gateway", - 503: "Service Unavailable", - 504: "Gateway Timeout", - 505: "HTTP Version Not Supported", - 506: "Variant Also Negotiates", - 507: "Insufficient Storage", - 508: "Loop Detected", - 509: "Bandwidth Limit Exceeded", - 510: "Not Extended", - 511: "Network Authentication Required", - 520: "Unknown Error (Microsoft / CloudFlare)", - 521: "Web Server Is Down (CloudFlare)", - 522: "Connection Timed Out (CloudFlare)", - 523: "Origin Is Unreachable (CloudFlare)", - 524: "A Timeout Occurred (CloudFlare)", - 525: "SSL Handshake Failed (CloudFlare)", - 526: "Invalid SSL Certificate (CloudFlare)", - 527: "Railgun Error (CloudFlare)" -}; +export const statusCodeToStatusTextMap: Record = Object.keys( + HttpStatusCodeByCode +) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusCodeByCode[cur as never]]: HttpStatusTextByCode[cur as never], + }), + {} + ); /** Key-value mapping of HTTP status codes and HTTP status descriptions. */ -export const statusCodeToStatusDescriptionMap: Record = { - 100: "Continue:The server has received the request headers, and that the client should proceed to send the request body.", - 101: "Switching protocols:The requester has asked the server to switch protocols and the server is acknowledging that it will do so.", - 102: "Processing:The server has received and is processing the request, but no response is available yet.", - 200: "OK:The standard response for successful HTTP requests.", - 201: "Created:The request has been fulfilled and a new resource has been created.", - 202: "Accepted:The request has been accepted but has not been processed yet. This code does not guarantee that the request will process successfully.", - 203: "Non-authoritative information:HTTP 1.1. The server successfully processed the request but is returning information from another source.", - 204: "No content:The server accepted the request but is not returning any content. This is often used as a response to a DELETE request.", - 205: "Reset content:Similar to a 204 No Content response but this response requires the requester to reset the document view.", - 206: "Partial content:The server is delivering only a portion of the content, as requested by the client via a range header.", - 207: "Multi-status:The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.", - 208: "Already reported:The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again.", - 226: "IM used:The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.", - 300: "Multiple choices:There are multiple options that the client may follow.", - 301: "Moved permanently:The resource has been moved and all further requests should reference its new URI.", - 302: "Found:The HTTP 1.0 specification described this status as \"Moved Temporarily\", but popular browsers respond to this status similar to behavior intended for 303. The resource can be retrieved by referencing the returned URI.", - 303: "See other:The resource can be retrieved by following other URI using the GET method. When received in response to a POST, PUT, or DELETE, it can usually be assumed that the server processed the request successfully and is sending the client to an informational endpoint.", - 304: "Not modified:The resource has not been modified since the version specified in If-Modified-Since or If-Match headers. The resource will not be returned in response body.", - 305: "Use proxy:HTTP 1.1. The resource is only available through a proxy and the address is provided in the response.", - 306: "Switch proxy:Deprecated in HTTP 1.1. Used to mean that subsequent requests should be sent using the specified proxy.", - 307: "Temporary redirect:HTTP 1.1. The request should be repeated with the URI provided in the response, but future requests should still call the original URI.", - 308: "Resume Incomplete (Google):This code is used in the Resumable HTTP Requests Proposal to resume aborted PUT or POST requests", - 400: "Bad request:The request could not be fulfilled due to the incorrect syntax of the request.", - 401: "Unauthorized:The requester is not authorized to access the resource. This is similar to 403 but is used in cases where authentication is expected but has failed or has not been provided.", - 402: "Payment required:Reserved for future use. Some web services use this as an indication that the client has sent an excessive number of requests.", - 403: "Forbidden:The request was formatted correctly but the server is refusing to supply the requested resource. Unlike 401, authenticating will not make a difference in the server's response.", - 404: "Not found:The resource could not be found. This is often used as a catch-all for all invalid URIs requested of the server.", - 405: "Method not allowed:The resource was requested using a method that is not allowed. For example, requesting a resource via a POST method when the resource only supports the GET method.", - 406: "Not acceptable:The resource is valid, but cannot be provided in a format specified in the Accept headers in the request.", - 407: "Proxy authentication required:Authentication is required with the proxy before requests can be fulfilled.", - 408: "Request timeout:The server timed out waiting for a request from the client. The client is allowed to repeat the request.", - 409: "Conflict:The request cannot be completed due to a conflict in the request parameters.", - 410: "Gone:The resource is no longer available at the requested URI and no redirection will be given.", - 411: "Length required:The request did not specify the length of its content as required by the resource.", - 412: "Precondition failed:The server does not meet one of the preconditions specified by the client.", - 413: "Request entity too large:The request is larger than what the server is able to process.", - 414: "Request-URI too long:The URI provided in the request is too long for the server to process. This is often used when too much data has been encoded into the URI of a GET request and a POST request should be used instead.", - 415: "Unsupported media type:The client provided data with a media type that the server does not support.", - 416: "Requested range not satisfiable:The client has asked for a portion of the resource but the server cannot supply that portion.", - 417: "Expectation failed:The server cannot meet the requirements of the Expect request-header field.", - 418: "I'm a teapot:Any attempt to brew coffee with a teapot should result in the error code \"418 I'm a teapot\". The resulting entity body MAY be short and stout.", - 421: "Misdirected request:The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.", - 422: "Unprocessable entity:The request was formatted correctly but cannot be processed in its current form. Often used when the specified parameters fail validation errors.", - 423: "Locked:The requested resource was found but has been locked and will not be returned.", - 424: "Failed dependency:The request failed due to a failure of a previous request.", - 426: "Upgrade required:The client should repeat the request using an upgraded protocol such as TLS 1.0.", - 428: "Precondition required:The origin server requires the request to be conditional.", - 429: "Too many requests:The user has sent too many requests in a given amount of time (\"rate limiting\").", - 431: "Request header fields too large:The server is unwilling to process the request because its header fields are too large.", - 440: "Login Timeout (Microsoft):A Microsoft extension. Indicates that your session has expired.", - 444: "No Response (Nginx):Used in Nginx logs to indicate that the server has returned no information to the client and closed the connection (useful as a deterrent for malware).", - 449: "Retry With (Microsoft):A Microsoft extension. The request should be retried after performing the appropriate action.", - 450: "Blocked by Windows Parental Controls (Microsoft):A Microsoft extension. This error is given when Windows Parental Controls are turned on and are blocking access to the given webpage.", - 451: "Redirect (Microsoft):Used in Exchange ActiveSync if there either is a more efficient server to use or the server cannot access the users' mailbox.", - 494: "Request Header Too Large (Nginx):Nginx internal code similar to 431 but it was introduced earlier in version 0.9.4 (on January 21, 2011).", - 495: "Cert Error (Nginx):Nginx internal code used when SSL client certificate error occurred to distinguish it from 4XX in a log and an error page redirection.", - 496: "No Cert (Nginx):Nginx internal code used when client didn't provide certificate to distinguish it from 4XX in a log and an error page redirection.", - 497: "HTTP to HTTPS (Nginx):Nginx internal code used for the plain HTTP requests that are sent to HTTPS port to distinguish it from 4XX in a log and an error page redirection.", - 498: "Token expired/invalid (Esri):Returned by ArcGIS for Server. A code of 498 indicates an expired or otherwise invalid token.", - 499: "Token required (Esri):Returned by ArcGIS for Server. A code of 499 indicates that a token is required (if no token was submitted).", - 500: "Internal server error:A generic status for an error in the server itself.", - 501: "Not implemented:The server cannot respond to the request. This usually implies that the server could possibly support the request in the future — otherwise a 4xx status may be more appropriate.", - 502: "Bad gateway:The server is acting as a proxy and did not receive an acceptable response from the upstream server.", - 503: "Service unavailable:The server is down and is not accepting requests.", - 504: "Gateway timeout:The server is acting as a proxy and did not receive a response from the upstream server.", - 505: "HTTP version not supported:The server does not support the HTTP protocol version specified in the request.", - 506: "Variant also negotiates:Transparent content negotiation for the request results in a circular reference.", - 507: "Insufficient storage:The user or server does not have sufficient storage quota to fulfill the request.", - 508: "Loop detected:The server detected an infinite loop in the request.", - 509: "Bandwidth Limit Exceeded (Apache bw/limited extension):This status code is not specified in any RFCs. Its use is unknown.", - 510: "Not extended:Further extensions to the request are necessary for it to be fulfilled.", - 511: "Network authentication required:The client must authenticate with the network before sending requests.", - 520: "Unknown Error (Microsoft / CloudFlare):This status code is not specified in any RFC and is returned by certain services, for instance Microsoft Azure and CloudFlare servers: \"The 520 error is essentially a \"catch-all\" response for when the origin server returns something unexpected or something that is not tolerated/interpreted (protocol violation or empty response).\"", - 521: "Web Server Is Down (CloudFlare):The origin server has refused the connection from CloudFlare.", - 522: "Connection Timed Out (CloudFlare):CloudFlare could not negotiate a TCP handshake with the origin server.", - 523: "Origin Is Unreachable (CloudFlare):CloudFlare could not reach the origin server; for example, if the DNS records for the origin server are incorrect.", - 524: "A Timeout Occurred (CloudFlare):CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response.", - 525: "SSL Handshake Failed (CloudFlare):CloudFlare could not negotiate a SSL/TLS handshake with the origin server.", - 526: "Invalid SSL Certificate (CloudFlare):CloudFlare could not validate the SSL/TLS certificate that the origin server presented.", - 527: "Railgun Error (CloudFlare):The request timed out or failed after the WAN connection has been established." -}; +export const statusCodeToStatusDescriptionMap: Record = Object.keys( + HttpStatusCodeByCode +) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusCodeByCode[cur as never]]: HttpStatusDescriptionByCode[cur as never], + }), + {} + ); /** Key-value mapping of HTTP status texts and HTTP status codes. */ -export const statusTextToStatusCodeMap: Record = { - "Continue": 100, - "Switching Protocols": 101, - "Processing": 102, - "OK": 200, - "Created": 201, - "Accepted": 202, - "Non-Authoritative Information": 203, - "No Content": 204, - "Reset Content": 205, - "Partial Content": 206, - "Multi-Status": 207, - "Already Reported": 208, - "IM Used": 226, - "Multiple Choices": 300, - "Moved Permanently": 301, - "Found": 302, - "See Other": 303, - "Not Modified": 304, - "Use Proxy": 305, - "Switch proxy": 306, - "Temporary Redirect": 307, - "Permanent Redirect": 308, - "Bad Request": 400, - "Unauthorized": 401, - "Payment Required": 402, - "Forbidden": 403, - "Not Found": 404, - "Method Not Allowed": 405, - "Not Acceptable": 406, - "Proxy Authentication Required": 407, - "Request Timeout": 408, - "Conflict": 409, - "Gone": 410, - "Length Required": 411, - "Precondition Failed": 412, - "Payload Too Large": 413, - "URI Too Long": 414, - "Unsupported Media Type": 415, - "Range Not Satisfiable": 416, - "Expectation Failed": 417, - "I'm a Teapot": 418, - "Misdirected Request": 421, - "Unprocessable Entity": 422, - "Locked": 423, - "Failed Dependency": 424, - "Upgrade Required": 426, - "Precondition Required": 428, - "Too Many Requests": 429, - "Request Header Fields Too Large": 431, - "Login Timeout (Microsoft)": 440, - "No Response (Nginx)": 444, - "Retry With (Microsoft)": 449, - "Blocked by Windows Parental Controls (Microsoft)": 450, - "Unavailable For Legal Reasons": 451, - "Request Header Too Large (Nginx)": 494, - "Cert Error (Nginx)": 495, - "No Cert (Nginx)": 496, - "HTTP to HTTPS (Nginx)": 497, - "Token expired/invalid (Esri)": 498, - "Token required (Esri)": 499, - "Internal Server Error": 500, - "Not Implemented": 501, - "Bad Gateway": 502, - "Service Unavailable": 503, - "Gateway Timeout": 504, - "HTTP Version Not Supported": 505, - "Variant Also Negotiates": 506, - "Insufficient Storage": 507, - "Loop Detected": 508, - "Bandwidth Limit Exceeded": 509, - "Not Extended": 510, - "Network Authentication Required": 511, - "Unknown Error (Microsoft / CloudFlare)": 520, - "Web Server Is Down (CloudFlare)": 521, - "Connection Timed Out (CloudFlare)": 522, - "Origin Is Unreachable (CloudFlare)": 523, - "A Timeout Occurred (CloudFlare)": 524, - "SSL Handshake Failed (CloudFlare)": 525, - "Invalid SSL Certificate (CloudFlare)": 526, - "Railgun Error (CloudFlare)": 527 -}; +export const statusTextToStatusCodeMap: Record = Object.keys( + HttpStatusTextByCode +) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusTextByCode[cur as never]]: HttpStatusCodeByCode[cur as never], + }), + {} + ); /** Key-value mapping of HTTP status texts and HTTP status descriptions. */ -export const statusTextToStatusDescriptionMap: Record = { - "Continue": "Continue:The server has received the request headers, and that the client should proceed to send the request body.", - "Switching Protocols": "Switching protocols:The requester has asked the server to switch protocols and the server is acknowledging that it will do so.", - "Processing": "Processing:The server has received and is processing the request, but no response is available yet.", - "OK": "OK:The standard response for successful HTTP requests.", - "Created": "Created:The request has been fulfilled and a new resource has been created.", - "Accepted": "Accepted:The request has been accepted but has not been processed yet. This code does not guarantee that the request will process successfully.", - "Non-Authoritative Information": "Non-authoritative information:HTTP 1.1. The server successfully processed the request but is returning information from another source.", - "No Content": "No content:The server accepted the request but is not returning any content. This is often used as a response to a DELETE request.", - "Reset Content": "Reset content:Similar to a 204 No Content response but this response requires the requester to reset the document view.", - "Partial Content": "Partial content:The server is delivering only a portion of the content, as requested by the client via a range header.", - "Multi-Status": "Multi-status:The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.", - "Already Reported": "Already reported:The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again.", - "IM Used": "IM used:The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.", - "Multiple Choices": "Multiple choices:There are multiple options that the client may follow.", - "Moved Permanently": "Moved permanently:The resource has been moved and all further requests should reference its new URI.", - "Found": "Found:The HTTP 1.0 specification described this status as \"Moved Temporarily\", but popular browsers respond to this status similar to behavior intended for 303. The resource can be retrieved by referencing the returned URI.", - "See Other": "See other:The resource can be retrieved by following other URI using the GET method. When received in response to a POST, PUT, or DELETE, it can usually be assumed that the server processed the request successfully and is sending the client to an informational endpoint.", - "Not Modified": "Not modified:The resource has not been modified since the version specified in If-Modified-Since or If-Match headers. The resource will not be returned in response body.", - "Use Proxy": "Use proxy:HTTP 1.1. The resource is only available through a proxy and the address is provided in the response.", - "Switch proxy": "Switch proxy:Deprecated in HTTP 1.1. Used to mean that subsequent requests should be sent using the specified proxy.", - "Temporary Redirect": "Temporary redirect:HTTP 1.1. The request should be repeated with the URI provided in the response, but future requests should still call the original URI.", - "Permanent Redirect": "Resume Incomplete (Google):This code is used in the Resumable HTTP Requests Proposal to resume aborted PUT or POST requests", - "Bad Request": "Bad request:The request could not be fulfilled due to the incorrect syntax of the request.", - "Unauthorized": "Unauthorized:The requester is not authorized to access the resource. This is similar to 403 but is used in cases where authentication is expected but has failed or has not been provided.", - "Payment Required": "Payment required:Reserved for future use. Some web services use this as an indication that the client has sent an excessive number of requests.", - "Forbidden": "Forbidden:The request was formatted correctly but the server is refusing to supply the requested resource. Unlike 401, authenticating will not make a difference in the server's response.", - "Not Found": "Not found:The resource could not be found. This is often used as a catch-all for all invalid URIs requested of the server.", - "Method Not Allowed": "Method not allowed:The resource was requested using a method that is not allowed. For example, requesting a resource via a POST method when the resource only supports the GET method.", - "Not Acceptable": "Not acceptable:The resource is valid, but cannot be provided in a format specified in the Accept headers in the request.", - "Proxy Authentication Required": "Proxy authentication required:Authentication is required with the proxy before requests can be fulfilled.", - "Request Timeout": "Request timeout:The server timed out waiting for a request from the client. The client is allowed to repeat the request.", - "Conflict": "Conflict:The request cannot be completed due to a conflict in the request parameters.", - "Gone": "Gone:The resource is no longer available at the requested URI and no redirection will be given.", - "Length Required": "Length required:The request did not specify the length of its content as required by the resource.", - "Precondition Failed": "Precondition failed:The server does not meet one of the preconditions specified by the client.", - "Payload Too Large": "Request entity too large:The request is larger than what the server is able to process.", - "URI Too Long": "Request-URI too long:The URI provided in the request is too long for the server to process. This is often used when too much data has been encoded into the URI of a GET request and a POST request should be used instead.", - "Unsupported Media Type": "Unsupported media type:The client provided data with a media type that the server does not support.", - "Range Not Satisfiable": "Requested range not satisfiable:The client has asked for a portion of the resource but the server cannot supply that portion.", - "Expectation Failed": "Expectation failed:The server cannot meet the requirements of the Expect request-header field.", - "I'm a Teapot": "I'm a teapot:Any attempt to brew coffee with a teapot should result in the error code \"418 I'm a teapot\". The resulting entity body MAY be short and stout.", - "Misdirected Request": "Misdirected request:The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.", - "Unprocessable Entity": "Unprocessable entity:The request was formatted correctly but cannot be processed in its current form. Often used when the specified parameters fail validation errors.", - "Locked": "Locked:The requested resource was found but has been locked and will not be returned.", - "Failed Dependency": "Failed dependency:The request failed due to a failure of a previous request.", - "Upgrade Required": "Upgrade required:The client should repeat the request using an upgraded protocol such as TLS 1.0.", - "Precondition Required": "Precondition required:The origin server requires the request to be conditional.", - "Too Many Requests": "Too many requests:The user has sent too many requests in a given amount of time (\"rate limiting\").", - "Request Header Fields Too Large": "Request header fields too large:The server is unwilling to process the request because its header fields are too large.", - "Login Timeout (Microsoft)": "Login Timeout (Microsoft):A Microsoft extension. Indicates that your session has expired.", - "No Response (Nginx)": "No Response (Nginx):Used in Nginx logs to indicate that the server has returned no information to the client and closed the connection (useful as a deterrent for malware).", - "Retry With (Microsoft)": "Retry With (Microsoft):A Microsoft extension. The request should be retried after performing the appropriate action.", - "Blocked by Windows Parental Controls (Microsoft)": "Blocked by Windows Parental Controls (Microsoft):A Microsoft extension. This error is given when Windows Parental Controls are turned on and are blocking access to the given webpage.", - "Unavailable For Legal Reasons": "Redirect (Microsoft):Used in Exchange ActiveSync if there either is a more efficient server to use or the server cannot access the users' mailbox.", - "Request Header Too Large (Nginx)": "Request Header Too Large (Nginx):Nginx internal code similar to 431 but it was introduced earlier in version 0.9.4 (on January 21, 2011).", - "Cert Error (Nginx)": "Cert Error (Nginx):Nginx internal code used when SSL client certificate error occurred to distinguish it from 4XX in a log and an error page redirection.", - "No Cert (Nginx)": "No Cert (Nginx):Nginx internal code used when client didn't provide certificate to distinguish it from 4XX in a log and an error page redirection.", - "HTTP to HTTPS (Nginx)": "HTTP to HTTPS (Nginx):Nginx internal code used for the plain HTTP requests that are sent to HTTPS port to distinguish it from 4XX in a log and an error page redirection.", - "Token expired/invalid (Esri)": "Token expired/invalid (Esri):Returned by ArcGIS for Server. A code of 498 indicates an expired or otherwise invalid token.", - "Token required (Esri)": "Token required (Esri):Returned by ArcGIS for Server. A code of 499 indicates that a token is required (if no token was submitted).", - "Internal Server Error": "Internal server error:A generic status for an error in the server itself.", - "Not Implemented": "Not implemented:The server cannot respond to the request. This usually implies that the server could possibly support the request in the future — otherwise a 4xx status may be more appropriate.", - "Bad Gateway": "Bad gateway:The server is acting as a proxy and did not receive an acceptable response from the upstream server.", - "Service Unavailable": "Service unavailable:The server is down and is not accepting requests.", - "Gateway Timeout": "Gateway timeout:The server is acting as a proxy and did not receive a response from the upstream server.", - "HTTP Version Not Supported": "HTTP version not supported:The server does not support the HTTP protocol version specified in the request.", - "Variant Also Negotiates": "Variant also negotiates:Transparent content negotiation for the request results in a circular reference.", - "Insufficient Storage": "Insufficient storage:The user or server does not have sufficient storage quota to fulfill the request.", - "Loop Detected": "Loop detected:The server detected an infinite loop in the request.", - "Bandwidth Limit Exceeded": "Bandwidth Limit Exceeded (Apache bw/limited extension):This status code is not specified in any RFCs. Its use is unknown.", - "Not Extended": "Not extended:Further extensions to the request are necessary for it to be fulfilled.", - "Network Authentication Required": "Network authentication required:The client must authenticate with the network before sending requests.", - "Unknown Error (Microsoft / CloudFlare)": "Unknown Error (Microsoft / CloudFlare):This status code is not specified in any RFC and is returned by certain services, for instance Microsoft Azure and CloudFlare servers: \"The 520 error is essentially a \"catch-all\" response for when the origin server returns something unexpected or something that is not tolerated/interpreted (protocol violation or empty response).\"", - "Web Server Is Down (CloudFlare)": "Web Server Is Down (CloudFlare):The origin server has refused the connection from CloudFlare.", - "Connection Timed Out (CloudFlare)": "Connection Timed Out (CloudFlare):CloudFlare could not negotiate a TCP handshake with the origin server.", - "Origin Is Unreachable (CloudFlare)": "Origin Is Unreachable (CloudFlare):CloudFlare could not reach the origin server; for example, if the DNS records for the origin server are incorrect.", - "A Timeout Occurred (CloudFlare)": "A Timeout Occurred (CloudFlare):CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response.", - "SSL Handshake Failed (CloudFlare)": "SSL Handshake Failed (CloudFlare):CloudFlare could not negotiate a SSL/TLS handshake with the origin server.", - "Invalid SSL Certificate (CloudFlare)": "Invalid SSL Certificate (CloudFlare):CloudFlare could not validate the SSL/TLS certificate that the origin server presented.", - "Railgun Error (CloudFlare)": "Railgun Error (CloudFlare):The request timed out or failed after the WAN connection has been established." -}; +export const statusTextToStatusDescriptionMap: Record = Object.keys( + HttpStatusTextByCode +) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusTextByCode[cur as never]]: HttpStatusDescriptionByCode[cur as never], + }), + {} + ); -export type HTTPStatusCode = keyof typeof statusCodeToStatusTextMap; -export type HTTPStatusText = keyof typeof statusTextToStatusCodeMap; export type StatusInfo = { code: number, message: string, success: boolean }; /** @@ -356,10 +74,10 @@ export type StatusInfo = { code: number, message: string, success: boolean }; * @example isCodeOrTextValid(200) -> true * isCodeOrTextValid('OK') -> true * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns yesOrNo: boolean */ -export function isCodeOrTextValid(codeOrText: HTTPStatusCode | HTTPStatusText): boolean { +export function isCodeOrTextValid(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): boolean { return codeOrText in statusCodeToStatusTextMap || codeOrText in statusTextToStatusCodeMap; } @@ -368,10 +86,10 @@ export function isCodeOrTextValid(codeOrText: HTTPStatusCode | HTTPStatusText): * @example getStatusInfo(200) -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} * getStatusInfo('OK') -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns StatusInfo: { code: number, message: string, success: boolean} */ -export function getStatusInfo(codeOrText: HTTPStatusCode | HTTPStatusText): StatusInfo { +export function getStatusInfo(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): StatusInfo { if (!isCodeOrTextValid(codeOrText)) { throw new Error(`${codeOrText} is not a known HTTP status code or status text.`); @@ -396,10 +114,10 @@ export function getStatusInfo(codeOrText: HTTPStatusCode | HTTPStatusText): Stat * isStatusSuccessful(400) -> false * isStatusSuccessful('Bad request') -> false * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns successful: boolean */ -export function isStatusSuccessful(codeOrText: HTTPStatusCode | HTTPStatusText): boolean { +export function isStatusSuccessful(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): boolean { try { return getStatusInfo(codeOrText).success; @@ -413,10 +131,10 @@ export function isStatusSuccessful(codeOrText: HTTPStatusCode | HTTPStatusText): * @example getSimpleStatusMessage(200) -> 200 OK * getSimpleStatusMessage('OK') -> 200 OK * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns simpleStatusMessage: string */ -export function getSimpleStatusMessage(codeOrText: HTTPStatusCode | HTTPStatusText): string { +export function getSimpleStatusMessage(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): string { const statusInfo = getStatusInfo(codeOrText) return `${statusInfo.code} ${statusInfo.message.split(':')[0]}`; @@ -427,10 +145,10 @@ export function getSimpleStatusMessage(codeOrText: HTTPStatusCode | HTTPStatusTe * @example getStatusMessage(200) -> 200 OK:The standard response for successful HTTP requests. * getStatusMessage('OK') -> 200 OK:The standard response for successful HTTP requests. * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns statusMessage: string */ -export function getStatusMessage(codeOrText: HTTPStatusCode | HTTPStatusText): string { +export function getStatusMessage(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): string { const statusInfo = getStatusInfo(codeOrText) return `${statusInfo.code} ${statusInfo.message}`; @@ -440,10 +158,10 @@ export function getStatusMessage(codeOrText: HTTPStatusCode | HTTPStatusText): s * Returns the status code for the given http status text. * If the given http status text does not exist, undefined is returned. * @example getStatusCode('OK') -> 200 - * @param text: HTTPStatusText - * @returns statusCode: HTTPStatusCode + * @param text: HttpStatusText + * @returns statusCode: HttpStatusCode */ -export function getStatusCode(text: HTTPStatusText): HTTPStatusCode { +export function getStatusCode(text: HttpStatusText): HttpStatusCode { const code = statusTextToStatusCodeMap[`${text}`] if (!code) { throw new Error(`${text} is not a known HTTP status text.`); @@ -455,10 +173,10 @@ export function getStatusCode(text: HTTPStatusText): HTTPStatusCode { * Returns the status text for the given http status code. * If the given http status code does not exist, undefined is returned. * @example getStatusCode('200') -> OK - * @param code: HTTPStatusCode - * @returns statusText: HTTPStatusText + * @param code: HttpStatusCode + * @returns statusText: HttpStatusText */ -export function getStatusText(code: HTTPStatusCode): HTTPStatusText { +export function getStatusText(code: HttpStatusCode): string { const text = statusCodeToStatusTextMap[`${code}`] if (!text) { throw new Error(`${code} is not a known HTTP status code.`); diff --git a/packages/i18n-en/src/lib/status-code.ts b/packages/i18n-en/src/lib/status-code.ts index 6dc6b22..7899726 100644 --- a/packages/i18n-en/src/lib/status-code.ts +++ b/packages/i18n-en/src/lib/status-code.ts @@ -496,3 +496,486 @@ export enum HttpStatusCode { */ RAILGUN_ERROR_CLOUD_FLARE = 527 } + +export enum HttpStatusCodeByCode { + /** + * h100: RFC 7231 6.2.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.1 + * Continue:The server has received the request headers, and that the client should proceed to send the request body. + */ + h100 = 100, + /** + * h101: RFC 7231 6.2.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.2 + * Switching protocols:The requester has asked the server to switch protocols and the server is acknowledging that it will do so. + */ + h101 = 101, + /** + * h102: RFC 2518 10.1 (obsoleted by RFC 4918) + * https://datatracker.ietf.org/doc/html/rfc2518#section-10.1 + * Processing:The server has received and is processing the request, but no response is available yet. + */ + h102 = 102, + /** + * h200: RFC 7231 6.3.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1 + * OK:The standard response for successful HTTP requests. + */ + h200 = 200, + /** + * h201: RFC 7231 6.3.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2 + * Created:The request has been fulfilled and a new resource has been created. + */ + h201 = 201, + /** + * h202: RFC 7231 6.3.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3 + * Accepted:The request has been accepted but has not been processed yet. This code does not guarantee that the request will process successfully. + */ + h202 = 202, + /** + * h203: RFC 7231 6.3.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.4 + * Non-authoritative information:HTTP 1.1. The server successfully processed the request but is returning information from another source. + */ + h203 = 203, + /** + * h204: RFC 7231 6.3.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5 + * No content:The server accepted the request but is not returning any content. This is often used as a response to a DELETE request. + */ + h204 = 204, + /** + * h205: RFC 7231 6.3.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 + * Reset content:Similar to a 204 No Content response but this response requires the requester to reset the document view. + */ + h205 = 205, + /** + * h206: RFC 7233 4.1 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.1 + * Partial content:The server is delivering only a portion of the content, as requested by the client via a range header. + */ + h206 = 206, + /** + * h207: RFC 4918 11.1 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.1 + * Multi-status:The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made. + */ + h207 = 207, + /** + * h208: RFC 5842 7.1 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.1 + * Already reported:The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again. + */ + h208 = 208, + /** + * h226: RFC 3229 10.4.1 + * https://datatracker.ietf.org/doc/html/rfc3229#section-10.4.1 + * IM used:The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance. + */ + h226 = 226, + /** + * h300: RFC 7231 6.4.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.1 + * Multiple choices:There are multiple options that the client may follow. + */ + h300 = 300, + /** + * h301: RFC 7231 6.4.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2 + * Moved permanently:The resource has been moved and all further requests should reference its new URI. + */ + h301 = 301, + /** + * h302: RFC 7231 6.4.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3 + * Found:The HTTP 1.0 specification described this status as "Moved Temporarily", but popular browsers respond to this status similar to behavior intended for 303. The resource can be retrieved by referencing the returned URI. + */ + h302 = 302, + /** + * h303: RFC 7231 6.4.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4 + * See other:The resource can be retrieved by following other URI using the GET method. When received in response to a POST, PUT, or DELETE, it can usually be assumed that the server processed the request successfully and is sending the client to an informational endpoint. + */ + h303 = 303, + /** + * h304: RFC 7232 4.1 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 + * Not modified:The resource has not been modified since the version specified in If-Modified-Since or If-Match headers. The resource will not be returned in response body. + */ + h304 = 304, + /** + * h305: RFC 7231 6.4.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.5 + * Use proxy:HTTP 1.1. The resource is only available through a proxy and the address is provided in the response. + */ + h305 = 305, + /** + * h306: + * Empty + * Switch proxy:Deprecated in HTTP 1.1. Used to mean that subsequent requests should be sent using the specified proxy. + */ + h306 = 306, + /** + * h307: RFC 7231 6.4.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 + * Temporary redirect:HTTP 1.1. The request should be repeated with the URI provided in the response, but future requests should still call the original URI. + */ + h307 = 307, + /** + * h308: RFC 7238 3 + * https://datatracker.ietf.org/doc/html/rfc7238#section-3 + * Resume Incomplete (Google):This code is used in the Resumable HTTP Requests Proposal to resume aborted PUT or POST requests + */ + h308 = 308, + /** + * h400: RFC 7231 6.5.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1 + * Bad request:The request could not be fulfilled due to the incorrect syntax of the request. + */ + h400 = 400, + /** + * h401: RFC 7235 3.1 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 + * Unauthorized:The requester is not authorized to access the resource. This is similar to 403 but is used in cases where authentication is expected but has failed or has not been provided. + */ + h401 = 401, + /** + * h402: RFC 7231 6.5.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2 + * Payment required:Reserved for future use. Some web services use this as an indication that the client has sent an excessive number of requests. + */ + h402 = 402, + /** + * h403: RFC 7231 6.5.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3 + * Forbidden:The request was formatted correctly but the server is refusing to supply the requested resource. Unlike 401, authenticating will not make a difference in the server's response. + */ + h403 = 403, + /** + * h404: RFC 7231 6.5.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 + * Not found:The resource could not be found. This is often used as a catch-all for all invalid URIs requested of the server. + */ + h404 = 404, + /** + * h405: RFC 7231 6.5.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5 + * Method not allowed:The resource was requested using a method that is not allowed. For example, requesting a resource via a POST method when the resource only supports the GET method. + */ + h405 = 405, + /** + * h406: RFC 7231 6.5.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.6 + * Not acceptable:The resource is valid, but cannot be provided in a format specified in the Accept headers in the request. + */ + h406 = 406, + /** + * h407: RFC 7235 3.2 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.2 + * Proxy authentication required:Authentication is required with the proxy before requests can be fulfilled. + */ + h407 = 407, + /** + * h408: RFC 7231 6.5.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.7 + * Request timeout:The server timed out waiting for a request from the client. The client is allowed to repeat the request. + */ + h408 = 408, + /** + * h409: RFC 7231 6.5.8 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8 + * Conflict:The request cannot be completed due to a conflict in the request parameters. + */ + h409 = 409, + /** + * h410: RFC 7231 6.5.9 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.9 + * Gone:The resource is no longer available at the requested URI and no redirection will be given. + */ + h410 = 410, + /** + * h411: RFC 7231 6.5.10 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.10 + * Length required:The request did not specify the length of its content as required by the resource. + */ + h411 = 411, + /** + * h412: RFC 7232 4.2 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.2 + * Precondition failed:The server does not meet one of the preconditions specified by the client. + */ + h412 = 412, + /** + * h413: RFC 7231 6.5.11 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.11 + * Request entity too large:The request is larger than what the server is able to process. + */ + h413 = 413, + /** + * h414: RFC 7231 6.5.12 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.12 + * Request-URI too long:The URI provided in the request is too long for the server to process. This is often used when too much data has been encoded into the URI of a GET request and a POST request should be used instead. + */ + h414 = 414, + /** + * h415: RFC 7231 6.5.13 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.13 + * Unsupported media type:The client provided data with a media type that the server does not support. + */ + h415 = 415, + /** + * h416: RFC 7233 4.4 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.4 + * Requested range not satisfiable:The client has asked for a portion of the resource but the server cannot supply that portion. + */ + h416 = 416, + /** + * h417: RFC 7231 6.5.14 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.14 + * Expectation failed:The server cannot meet the requirements of the Expect request-header field. + */ + h417 = 417, + /** + * h418: + * Empty + * I'm a teapot:Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout. + */ + h418 = 418, + /** + * h421: RFC 7540 9.1.2 + * https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2 + * Misdirected request:The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI. + */ + h421 = 421, + /** + * h422: RFC 4918 11.2 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.2 + * Unprocessable entity:The request was formatted correctly but cannot be processed in its current form. Often used when the specified parameters fail validation errors. + */ + h422 = 422, + /** + * h423: RFC 4918 11.3 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.3 + * Locked:The requested resource was found but has been locked and will not be returned. + */ + h423 = 423, + /** + * h424: RFC 4918 11.4 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.4 + * Failed dependency:The request failed due to a failure of a previous request. + */ + h424 = 424, + /** + * h426: RFC 2817 and RFC 7231 6.5.15 + * https://datatracker.ietf.org/doc/html/rfc2817 and https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.15 + * Upgrade required:The client should repeat the request using an upgraded protocol such as TLS 1.0. + */ + h426 = 426, + /** + * h428: RFC 6585 3 + * https://datatracker.ietf.org/doc/html/rfc6585#section-3 + * Precondition required:The origin server requires the request to be conditional. + */ + h428 = 428, + /** + * h429: RFC 6585 4 + * https://datatracker.ietf.org/doc/html/rfc6585#section-4 + * Too many requests:The user has sent too many requests in a given amount of time ("rate limiting"). + */ + h429 = 429, + /** + * h431: RFC 6585 5 + * https://datatracker.ietf.org/doc/html/rfc6585#section-5 + * Request header fields too large:The server is unwilling to process the request because its header fields are too large. + */ + h431 = 431, + /** + * h440: + * Empty + * Login Timeout (Microsoft):A Microsoft extension. Indicates that your session has expired. + */ + h440 = 440, + /** + * h444: + * Empty + * No Response (Nginx):Used in Nginx logs to indicate that the server has returned no information to the client and closed the connection (useful as a deterrent for malware). + */ + h444 = 444, + /** + * h449: + * Empty + * Retry With (Microsoft):A Microsoft extension. The request should be retried after performing the appropriate action. + */ + h449 = 449, + /** + * h450: + * Empty + * Blocked by Windows Parental Controls (Microsoft):A Microsoft extension. This error is given when Windows Parental Controls are turned on and are blocking access to the given webpage. + */ + h450 = 450, + /** + * h451: RFC 7725 3 + * https://datatracker.ietf.org/doc/html/rfc7725#section-3 + * Redirect (Microsoft):Used in Exchange ActiveSync if there either is a more efficient server to use or the server cannot access the users' mailbox. + */ + h451 = 451, + /** + * h494: + * Empty + * Request Header Too Large (Nginx):Nginx internal code similar to 431 but it was introduced earlier in version 0.9.4 (on January 21, 2011). + */ + h494 = 494, + /** + * h495: + * Empty + * Cert Error (Nginx):Nginx internal code used when SSL client certificate error occurred to distinguish it from 4XX in a log and an error page redirection. + */ + h495 = 495, + /** + * h496: + * Empty + * No Cert (Nginx):Nginx internal code used when client didn't provide certificate to distinguish it from 4XX in a log and an error page redirection. + */ + h496 = 496, + /** + * h497: + * Empty + * HTTP to HTTPS (Nginx):Nginx internal code used for the plain HTTP requests that are sent to HTTPS port to distinguish it from 4XX in a log and an error page redirection. + */ + h497 = 497, + /** + * h498: + * Empty + * Token expired/invalid (Esri):Returned by ArcGIS for Server. A code of 498 indicates an expired or otherwise invalid token. + */ + h498 = 498, + /** + * h499: + * Empty + * Token required (Esri):Returned by ArcGIS for Server. A code of 499 indicates that a token is required (if no token was submitted). + */ + h499 = 499, + /** + * h500: RFC 7231 6.6.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1 + * Internal server error:A generic status for an error in the server itself. + */ + h500 = 500, + /** + * h501: RFC 7231 6.6.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2 + * Not implemented:The server cannot respond to the request. This usually implies that the server could possibly support the request in the future — otherwise a 4xx status may be more appropriate. + */ + h501 = 501, + /** + * h502: RFC 7231 6.6.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3 + * Bad gateway:The server is acting as a proxy and did not receive an acceptable response from the upstream server. + */ + h502 = 502, + /** + * h503: RFC 7231 6.6.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4 + * Service unavailable:The server is down and is not accepting requests. + */ + h503 = 503, + /** + * h504: RFC 7231 6.6.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5 + * Gateway timeout:The server is acting as a proxy and did not receive a response from the upstream server. + */ + h504 = 504, + /** + * h505: RFC 7231 6.6.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.6 + * HTTP version not supported:The server does not support the HTTP protocol version specified in the request. + */ + h505 = 505, + /** + * h506: RFC 2295 8.1 + * https://datatracker.ietf.org/doc/html/rfc2295#section-8.1 + * Variant also negotiates:Transparent content negotiation for the request results in a circular reference. + */ + h506 = 506, + /** + * h507: RFC 4918 11.5 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.5 + * Insufficient storage:The user or server does not have sufficient storage quota to fulfill the request. + */ + h507 = 507, + /** + * h508: RFC 5842 7.2 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.2 + * Loop detected:The server detected an infinite loop in the request. + */ + h508 = 508, + /** + * h509: + * Empty + * Bandwidth Limit Exceeded (Apache bw/limited extension):This status code is not specified in any RFCs. Its use is unknown. + */ + h509 = 509, + /** + * h510: RFC 2774 7 + * https://datatracker.ietf.org/doc/html/rfc2774#section-7 + * Not extended:Further extensions to the request are necessary for it to be fulfilled. + */ + h510 = 510, + /** + * h511: RFC 6585 6 + * https://datatracker.ietf.org/doc/html/rfc6585#section-6 + * Network authentication required:The client must authenticate with the network before sending requests. + */ + h511 = 511, + /** + * h520: + * Empty + * Unknown Error (Microsoft / CloudFlare):This status code is not specified in any RFC and is returned by certain services, for instance Microsoft Azure and CloudFlare servers: "The 520 error is essentially a "catch-all" response for when the origin server returns something unexpected or something that is not tolerated/interpreted (protocol violation or empty response)." + */ + h520 = 520, + /** + * h521: + * Empty + * Web Server Is Down (CloudFlare):The origin server has refused the connection from CloudFlare. + */ + h521 = 521, + /** + * h522: + * Empty + * Connection Timed Out (CloudFlare):CloudFlare could not negotiate a TCP handshake with the origin server. + */ + h522 = 522, + /** + * h523: + * Empty + * Origin Is Unreachable (CloudFlare):CloudFlare could not reach the origin server; for example, if the DNS records for the origin server are incorrect. + */ + h523 = 523, + /** + * h524: + * Empty + * A Timeout Occurred (CloudFlare):CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response. + */ + h524 = 524, + /** + * h525: + * Empty + * SSL Handshake Failed (CloudFlare):CloudFlare could not negotiate a SSL/TLS handshake with the origin server. + */ + h525 = 525, + /** + * h526: + * Empty + * Invalid SSL Certificate (CloudFlare):CloudFlare could not validate the SSL/TLS certificate that the origin server presented. + */ + h526 = 526, + /** + * h527: + * Empty + * Railgun Error (CloudFlare):The request timed out or failed after the WAN connection has been established. + */ + h527 = 527 +} diff --git a/packages/i18n-en/src/lib/status-description.ts b/packages/i18n-en/src/lib/status-description.ts index 620207f..51d51f2 100644 --- a/packages/i18n-en/src/lib/status-description.ts +++ b/packages/i18n-en/src/lib/status-description.ts @@ -496,3 +496,486 @@ export enum HttpStatusDescription { */ RAILGUN_ERROR_CLOUD_FLARE = 'Railgun Error (CloudFlare):The request timed out or failed after the WAN connection has been established.' } + +export enum HttpStatusDescriptionByCode { + /** + * h100: RFC 7231 6.2.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.1 + * Continue:The server has received the request headers, and that the client should proceed to send the request body. + */ + h100 = 'Continue:The server has received the request headers, and that the client should proceed to send the request body.', + /** + * h101: RFC 7231 6.2.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.2 + * Switching protocols:The requester has asked the server to switch protocols and the server is acknowledging that it will do so. + */ + h101 = 'Switching protocols:The requester has asked the server to switch protocols and the server is acknowledging that it will do so.', + /** + * h102: RFC 2518 10.1 (obsoleted by RFC 4918) + * https://datatracker.ietf.org/doc/html/rfc2518#section-10.1 + * Processing:The server has received and is processing the request, but no response is available yet. + */ + h102 = 'Processing:The server has received and is processing the request, but no response is available yet.', + /** + * h200: RFC 7231 6.3.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1 + * OK:The standard response for successful HTTP requests. + */ + h200 = 'OK:The standard response for successful HTTP requests.', + /** + * h201: RFC 7231 6.3.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2 + * Created:The request has been fulfilled and a new resource has been created. + */ + h201 = 'Created:The request has been fulfilled and a new resource has been created.', + /** + * h202: RFC 7231 6.3.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3 + * Accepted:The request has been accepted but has not been processed yet. This code does not guarantee that the request will process successfully. + */ + h202 = 'Accepted:The request has been accepted but has not been processed yet. This code does not guarantee that the request will process successfully.', + /** + * h203: RFC 7231 6.3.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.4 + * Non-authoritative information:HTTP 1.1. The server successfully processed the request but is returning information from another source. + */ + h203 = 'Non-authoritative information:HTTP 1.1. The server successfully processed the request but is returning information from another source.', + /** + * h204: RFC 7231 6.3.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5 + * No content:The server accepted the request but is not returning any content. This is often used as a response to a DELETE request. + */ + h204 = 'No content:The server accepted the request but is not returning any content. This is often used as a response to a DELETE request.', + /** + * h205: RFC 7231 6.3.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 + * Reset content:Similar to a 204 No Content response but this response requires the requester to reset the document view. + */ + h205 = 'Reset content:Similar to a 204 No Content response but this response requires the requester to reset the document view.', + /** + * h206: RFC 7233 4.1 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.1 + * Partial content:The server is delivering only a portion of the content, as requested by the client via a range header. + */ + h206 = 'Partial content:The server is delivering only a portion of the content, as requested by the client via a range header.', + /** + * h207: RFC 4918 11.1 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.1 + * Multi-status:The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made. + */ + h207 = 'Multi-status:The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.', + /** + * h208: RFC 5842 7.1 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.1 + * Already reported:The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again. + */ + h208 = 'Already reported:The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again.', + /** + * h226: RFC 3229 10.4.1 + * https://datatracker.ietf.org/doc/html/rfc3229#section-10.4.1 + * IM used:The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance. + */ + h226 = 'IM used:The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.', + /** + * h300: RFC 7231 6.4.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.1 + * Multiple choices:There are multiple options that the client may follow. + */ + h300 = 'Multiple choices:There are multiple options that the client may follow.', + /** + * h301: RFC 7231 6.4.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2 + * Moved permanently:The resource has been moved and all further requests should reference its new URI. + */ + h301 = 'Moved permanently:The resource has been moved and all further requests should reference its new URI.', + /** + * h302: RFC 7231 6.4.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3 + * Found:The HTTP 1.0 specification described this status as "Moved Temporarily", but popular browsers respond to this status similar to behavior intended for 303. The resource can be retrieved by referencing the returned URI. + */ + h302 = 'Found:The HTTP 1.0 specification described this status as "Moved Temporarily", but popular browsers respond to this status similar to behavior intended for 303. The resource can be retrieved by referencing the returned URI.', + /** + * h303: RFC 7231 6.4.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4 + * See other:The resource can be retrieved by following other URI using the GET method. When received in response to a POST, PUT, or DELETE, it can usually be assumed that the server processed the request successfully and is sending the client to an informational endpoint. + */ + h303 = 'See other:The resource can be retrieved by following other URI using the GET method. When received in response to a POST, PUT, or DELETE, it can usually be assumed that the server processed the request successfully and is sending the client to an informational endpoint.', + /** + * h304: RFC 7232 4.1 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 + * Not modified:The resource has not been modified since the version specified in If-Modified-Since or If-Match headers. The resource will not be returned in response body. + */ + h304 = 'Not modified:The resource has not been modified since the version specified in If-Modified-Since or If-Match headers. The resource will not be returned in response body.', + /** + * h305: RFC 7231 6.4.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.5 + * Use proxy:HTTP 1.1. The resource is only available through a proxy and the address is provided in the response. + */ + h305 = 'Use proxy:HTTP 1.1. The resource is only available through a proxy and the address is provided in the response.', + /** + * h306: + * Empty + * Switch proxy:Deprecated in HTTP 1.1. Used to mean that subsequent requests should be sent using the specified proxy. + */ + h306 = 'Switch proxy:Deprecated in HTTP 1.1. Used to mean that subsequent requests should be sent using the specified proxy.', + /** + * h307: RFC 7231 6.4.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 + * Temporary redirect:HTTP 1.1. The request should be repeated with the URI provided in the response, but future requests should still call the original URI. + */ + h307 = 'Temporary redirect:HTTP 1.1. The request should be repeated with the URI provided in the response, but future requests should still call the original URI.', + /** + * h308: RFC 7238 3 + * https://datatracker.ietf.org/doc/html/rfc7238#section-3 + * Resume Incomplete (Google):This code is used in the Resumable HTTP Requests Proposal to resume aborted PUT or POST requests + */ + h308 = 'Resume Incomplete (Google):This code is used in the Resumable HTTP Requests Proposal to resume aborted PUT or POST requests', + /** + * h400: RFC 7231 6.5.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1 + * Bad request:The request could not be fulfilled due to the incorrect syntax of the request. + */ + h400 = 'Bad request:The request could not be fulfilled due to the incorrect syntax of the request.', + /** + * h401: RFC 7235 3.1 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 + * Unauthorized:The requester is not authorized to access the resource. This is similar to 403 but is used in cases where authentication is expected but has failed or has not been provided. + */ + h401 = 'Unauthorized:The requester is not authorized to access the resource. This is similar to 403 but is used in cases where authentication is expected but has failed or has not been provided.', + /** + * h402: RFC 7231 6.5.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2 + * Payment required:Reserved for future use. Some web services use this as an indication that the client has sent an excessive number of requests. + */ + h402 = 'Payment required:Reserved for future use. Some web services use this as an indication that the client has sent an excessive number of requests.', + /** + * h403: RFC 7231 6.5.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3 + * Forbidden:The request was formatted correctly but the server is refusing to supply the requested resource. Unlike 401, authenticating will not make a difference in the server's response. + */ + h403 = 'Forbidden:The request was formatted correctly but the server is refusing to supply the requested resource. Unlike 401, authenticating will not make a difference in the server\'s response.', + /** + * h404: RFC 7231 6.5.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 + * Not found:The resource could not be found. This is often used as a catch-all for all invalid URIs requested of the server. + */ + h404 = 'Not found:The resource could not be found. This is often used as a catch-all for all invalid URIs requested of the server.', + /** + * h405: RFC 7231 6.5.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5 + * Method not allowed:The resource was requested using a method that is not allowed. For example, requesting a resource via a POST method when the resource only supports the GET method. + */ + h405 = 'Method not allowed:The resource was requested using a method that is not allowed. For example, requesting a resource via a POST method when the resource only supports the GET method.', + /** + * h406: RFC 7231 6.5.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.6 + * Not acceptable:The resource is valid, but cannot be provided in a format specified in the Accept headers in the request. + */ + h406 = 'Not acceptable:The resource is valid, but cannot be provided in a format specified in the Accept headers in the request.', + /** + * h407: RFC 7235 3.2 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.2 + * Proxy authentication required:Authentication is required with the proxy before requests can be fulfilled. + */ + h407 = 'Proxy authentication required:Authentication is required with the proxy before requests can be fulfilled.', + /** + * h408: RFC 7231 6.5.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.7 + * Request timeout:The server timed out waiting for a request from the client. The client is allowed to repeat the request. + */ + h408 = 'Request timeout:The server timed out waiting for a request from the client. The client is allowed to repeat the request.', + /** + * h409: RFC 7231 6.5.8 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8 + * Conflict:The request cannot be completed due to a conflict in the request parameters. + */ + h409 = 'Conflict:The request cannot be completed due to a conflict in the request parameters.', + /** + * h410: RFC 7231 6.5.9 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.9 + * Gone:The resource is no longer available at the requested URI and no redirection will be given. + */ + h410 = 'Gone:The resource is no longer available at the requested URI and no redirection will be given.', + /** + * h411: RFC 7231 6.5.10 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.10 + * Length required:The request did not specify the length of its content as required by the resource. + */ + h411 = 'Length required:The request did not specify the length of its content as required by the resource.', + /** + * h412: RFC 7232 4.2 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.2 + * Precondition failed:The server does not meet one of the preconditions specified by the client. + */ + h412 = 'Precondition failed:The server does not meet one of the preconditions specified by the client.', + /** + * h413: RFC 7231 6.5.11 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.11 + * Request entity too large:The request is larger than what the server is able to process. + */ + h413 = 'Request entity too large:The request is larger than what the server is able to process.', + /** + * h414: RFC 7231 6.5.12 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.12 + * Request-URI too long:The URI provided in the request is too long for the server to process. This is often used when too much data has been encoded into the URI of a GET request and a POST request should be used instead. + */ + h414 = 'Request-URI too long:The URI provided in the request is too long for the server to process. This is often used when too much data has been encoded into the URI of a GET request and a POST request should be used instead.', + /** + * h415: RFC 7231 6.5.13 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.13 + * Unsupported media type:The client provided data with a media type that the server does not support. + */ + h415 = 'Unsupported media type:The client provided data with a media type that the server does not support.', + /** + * h416: RFC 7233 4.4 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.4 + * Requested range not satisfiable:The client has asked for a portion of the resource but the server cannot supply that portion. + */ + h416 = 'Requested range not satisfiable:The client has asked for a portion of the resource but the server cannot supply that portion.', + /** + * h417: RFC 7231 6.5.14 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.14 + * Expectation failed:The server cannot meet the requirements of the Expect request-header field. + */ + h417 = 'Expectation failed:The server cannot meet the requirements of the Expect request-header field.', + /** + * h418: + * Empty + * I'm a teapot:Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout. + */ + h418 = 'I\'m a teapot:Any attempt to brew coffee with a teapot should result in the error code "418 I\'m a teapot". The resulting entity body MAY be short and stout.', + /** + * h421: RFC 7540 9.1.2 + * https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2 + * Misdirected request:The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI. + */ + h421 = 'Misdirected request:The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.', + /** + * h422: RFC 4918 11.2 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.2 + * Unprocessable entity:The request was formatted correctly but cannot be processed in its current form. Often used when the specified parameters fail validation errors. + */ + h422 = 'Unprocessable entity:The request was formatted correctly but cannot be processed in its current form. Often used when the specified parameters fail validation errors.', + /** + * h423: RFC 4918 11.3 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.3 + * Locked:The requested resource was found but has been locked and will not be returned. + */ + h423 = 'Locked:The requested resource was found but has been locked and will not be returned.', + /** + * h424: RFC 4918 11.4 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.4 + * Failed dependency:The request failed due to a failure of a previous request. + */ + h424 = 'Failed dependency:The request failed due to a failure of a previous request.', + /** + * h426: RFC 2817 and RFC 7231 6.5.15 + * https://datatracker.ietf.org/doc/html/rfc2817 and https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.15 + * Upgrade required:The client should repeat the request using an upgraded protocol such as TLS 1.0. + */ + h426 = 'Upgrade required:The client should repeat the request using an upgraded protocol such as TLS 1.0.', + /** + * h428: RFC 6585 3 + * https://datatracker.ietf.org/doc/html/rfc6585#section-3 + * Precondition required:The origin server requires the request to be conditional. + */ + h428 = 'Precondition required:The origin server requires the request to be conditional.', + /** + * h429: RFC 6585 4 + * https://datatracker.ietf.org/doc/html/rfc6585#section-4 + * Too many requests:The user has sent too many requests in a given amount of time ("rate limiting"). + */ + h429 = 'Too many requests:The user has sent too many requests in a given amount of time ("rate limiting").', + /** + * h431: RFC 6585 5 + * https://datatracker.ietf.org/doc/html/rfc6585#section-5 + * Request header fields too large:The server is unwilling to process the request because its header fields are too large. + */ + h431 = 'Request header fields too large:The server is unwilling to process the request because its header fields are too large.', + /** + * h440: + * Empty + * Login Timeout (Microsoft):A Microsoft extension. Indicates that your session has expired. + */ + h440 = 'Login Timeout (Microsoft):A Microsoft extension. Indicates that your session has expired.', + /** + * h444: + * Empty + * No Response (Nginx):Used in Nginx logs to indicate that the server has returned no information to the client and closed the connection (useful as a deterrent for malware). + */ + h444 = 'No Response (Nginx):Used in Nginx logs to indicate that the server has returned no information to the client and closed the connection (useful as a deterrent for malware).', + /** + * h449: + * Empty + * Retry With (Microsoft):A Microsoft extension. The request should be retried after performing the appropriate action. + */ + h449 = 'Retry With (Microsoft):A Microsoft extension. The request should be retried after performing the appropriate action.', + /** + * h450: + * Empty + * Blocked by Windows Parental Controls (Microsoft):A Microsoft extension. This error is given when Windows Parental Controls are turned on and are blocking access to the given webpage. + */ + h450 = 'Blocked by Windows Parental Controls (Microsoft):A Microsoft extension. This error is given when Windows Parental Controls are turned on and are blocking access to the given webpage.', + /** + * h451: RFC 7725 3 + * https://datatracker.ietf.org/doc/html/rfc7725#section-3 + * Redirect (Microsoft):Used in Exchange ActiveSync if there either is a more efficient server to use or the server cannot access the users' mailbox. + */ + h451 = 'Redirect (Microsoft):Used in Exchange ActiveSync if there either is a more efficient server to use or the server cannot access the users\' mailbox.', + /** + * h494: + * Empty + * Request Header Too Large (Nginx):Nginx internal code similar to 431 but it was introduced earlier in version 0.9.4 (on January 21, 2011). + */ + h494 = 'Request Header Too Large (Nginx):Nginx internal code similar to 431 but it was introduced earlier in version 0.9.4 (on January 21, 2011).', + /** + * h495: + * Empty + * Cert Error (Nginx):Nginx internal code used when SSL client certificate error occurred to distinguish it from 4XX in a log and an error page redirection. + */ + h495 = 'Cert Error (Nginx):Nginx internal code used when SSL client certificate error occurred to distinguish it from 4XX in a log and an error page redirection.', + /** + * h496: + * Empty + * No Cert (Nginx):Nginx internal code used when client didn't provide certificate to distinguish it from 4XX in a log and an error page redirection. + */ + h496 = 'No Cert (Nginx):Nginx internal code used when client didn\'t provide certificate to distinguish it from 4XX in a log and an error page redirection.', + /** + * h497: + * Empty + * HTTP to HTTPS (Nginx):Nginx internal code used for the plain HTTP requests that are sent to HTTPS port to distinguish it from 4XX in a log and an error page redirection. + */ + h497 = 'HTTP to HTTPS (Nginx):Nginx internal code used for the plain HTTP requests that are sent to HTTPS port to distinguish it from 4XX in a log and an error page redirection.', + /** + * h498: + * Empty + * Token expired/invalid (Esri):Returned by ArcGIS for Server. A code of 498 indicates an expired or otherwise invalid token. + */ + h498 = 'Token expired/invalid (Esri):Returned by ArcGIS for Server. A code of 498 indicates an expired or otherwise invalid token.', + /** + * h499: + * Empty + * Token required (Esri):Returned by ArcGIS for Server. A code of 499 indicates that a token is required (if no token was submitted). + */ + h499 = 'Token required (Esri):Returned by ArcGIS for Server. A code of 499 indicates that a token is required (if no token was submitted).', + /** + * h500: RFC 7231 6.6.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1 + * Internal server error:A generic status for an error in the server itself. + */ + h500 = 'Internal server error:A generic status for an error in the server itself.', + /** + * h501: RFC 7231 6.6.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2 + * Not implemented:The server cannot respond to the request. This usually implies that the server could possibly support the request in the future — otherwise a 4xx status may be more appropriate. + */ + h501 = 'Not implemented:The server cannot respond to the request. This usually implies that the server could possibly support the request in the future — otherwise a 4xx status may be more appropriate.', + /** + * h502: RFC 7231 6.6.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3 + * Bad gateway:The server is acting as a proxy and did not receive an acceptable response from the upstream server. + */ + h502 = 'Bad gateway:The server is acting as a proxy and did not receive an acceptable response from the upstream server.', + /** + * h503: RFC 7231 6.6.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4 + * Service unavailable:The server is down and is not accepting requests. + */ + h503 = 'Service unavailable:The server is down and is not accepting requests.', + /** + * h504: RFC 7231 6.6.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5 + * Gateway timeout:The server is acting as a proxy and did not receive a response from the upstream server. + */ + h504 = 'Gateway timeout:The server is acting as a proxy and did not receive a response from the upstream server.', + /** + * h505: RFC 7231 6.6.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.6 + * HTTP version not supported:The server does not support the HTTP protocol version specified in the request. + */ + h505 = 'HTTP version not supported:The server does not support the HTTP protocol version specified in the request.', + /** + * h506: RFC 2295 8.1 + * https://datatracker.ietf.org/doc/html/rfc2295#section-8.1 + * Variant also negotiates:Transparent content negotiation for the request results in a circular reference. + */ + h506 = 'Variant also negotiates:Transparent content negotiation for the request results in a circular reference.', + /** + * h507: RFC 4918 11.5 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.5 + * Insufficient storage:The user or server does not have sufficient storage quota to fulfill the request. + */ + h507 = 'Insufficient storage:The user or server does not have sufficient storage quota to fulfill the request.', + /** + * h508: RFC 5842 7.2 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.2 + * Loop detected:The server detected an infinite loop in the request. + */ + h508 = 'Loop detected:The server detected an infinite loop in the request.', + /** + * h509: + * Empty + * Bandwidth Limit Exceeded (Apache bw/limited extension):This status code is not specified in any RFCs. Its use is unknown. + */ + h509 = 'Bandwidth Limit Exceeded (Apache bw/limited extension):This status code is not specified in any RFCs. Its use is unknown.', + /** + * h510: RFC 2774 7 + * https://datatracker.ietf.org/doc/html/rfc2774#section-7 + * Not extended:Further extensions to the request are necessary for it to be fulfilled. + */ + h510 = 'Not extended:Further extensions to the request are necessary for it to be fulfilled.', + /** + * h511: RFC 6585 6 + * https://datatracker.ietf.org/doc/html/rfc6585#section-6 + * Network authentication required:The client must authenticate with the network before sending requests. + */ + h511 = 'Network authentication required:The client must authenticate with the network before sending requests.', + /** + * h520: + * Empty + * Unknown Error (Microsoft / CloudFlare):This status code is not specified in any RFC and is returned by certain services, for instance Microsoft Azure and CloudFlare servers: "The 520 error is essentially a "catch-all" response for when the origin server returns something unexpected or something that is not tolerated/interpreted (protocol violation or empty response)." + */ + h520 = 'Unknown Error (Microsoft / CloudFlare):This status code is not specified in any RFC and is returned by certain services, for instance Microsoft Azure and CloudFlare servers: "The 520 error is essentially a "catch-all" response for when the origin server returns something unexpected or something that is not tolerated/interpreted (protocol violation or empty response)."', + /** + * h521: + * Empty + * Web Server Is Down (CloudFlare):The origin server has refused the connection from CloudFlare. + */ + h521 = 'Web Server Is Down (CloudFlare):The origin server has refused the connection from CloudFlare.', + /** + * h522: + * Empty + * Connection Timed Out (CloudFlare):CloudFlare could not negotiate a TCP handshake with the origin server. + */ + h522 = 'Connection Timed Out (CloudFlare):CloudFlare could not negotiate a TCP handshake with the origin server.', + /** + * h523: + * Empty + * Origin Is Unreachable (CloudFlare):CloudFlare could not reach the origin server; for example, if the DNS records for the origin server are incorrect. + */ + h523 = 'Origin Is Unreachable (CloudFlare):CloudFlare could not reach the origin server; for example, if the DNS records for the origin server are incorrect.', + /** + * h524: + * Empty + * A Timeout Occurred (CloudFlare):CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response. + */ + h524 = 'A Timeout Occurred (CloudFlare):CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response.', + /** + * h525: + * Empty + * SSL Handshake Failed (CloudFlare):CloudFlare could not negotiate a SSL/TLS handshake with the origin server. + */ + h525 = 'SSL Handshake Failed (CloudFlare):CloudFlare could not negotiate a SSL/TLS handshake with the origin server.', + /** + * h526: + * Empty + * Invalid SSL Certificate (CloudFlare):CloudFlare could not validate the SSL/TLS certificate that the origin server presented. + */ + h526 = 'Invalid SSL Certificate (CloudFlare):CloudFlare could not validate the SSL/TLS certificate that the origin server presented.', + /** + * h527: + * Empty + * Railgun Error (CloudFlare):The request timed out or failed after the WAN connection has been established. + */ + h527 = 'Railgun Error (CloudFlare):The request timed out or failed after the WAN connection has been established.' +} diff --git a/packages/i18n-en/src/lib/status-text.ts b/packages/i18n-en/src/lib/status-text.ts index 84a2bf4..66cd354 100644 --- a/packages/i18n-en/src/lib/status-text.ts +++ b/packages/i18n-en/src/lib/status-text.ts @@ -16,483 +16,966 @@ export enum HttpStatusText { /** - * 100: RFC 7231 6.2.1 + * CONTINUE: RFC 7231 6.2.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.1 * Continue:The server has received the request headers, and that the client should proceed to send the request body. */ CONTINUE = 'Continue', /** - * 101: RFC 7231 6.2.2 + * SWITCHING_PROTOCOLS: RFC 7231 6.2.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.2 * Switching protocols:The requester has asked the server to switch protocols and the server is acknowledging that it will do so. */ SWITCHING_PROTOCOLS = 'Switching Protocols', /** - * 102: RFC 2518 10.1 (obsoleted by RFC 4918) + * PROCESSING: RFC 2518 10.1 (obsoleted by RFC 4918) * https://datatracker.ietf.org/doc/html/rfc2518#section-10.1 * Processing:The server has received and is processing the request, but no response is available yet. */ PROCESSING = 'Processing', /** - * 200: RFC 7231 6.3.1 + * OK: RFC 7231 6.3.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1 * OK:The standard response for successful HTTP requests. */ OK = 'OK', /** - * 201: RFC 7231 6.3.2 + * CREATED: RFC 7231 6.3.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2 * Created:The request has been fulfilled and a new resource has been created. */ CREATED = 'Created', /** - * 202: RFC 7231 6.3.3 + * ACCEPTED: RFC 7231 6.3.3 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3 * Accepted:The request has been accepted but has not been processed yet. This code does not guarantee that the request will process successfully. */ ACCEPTED = 'Accepted', /** - * 203: RFC 7231 6.3.4 + * NON_AUTHORITATIVE_INFORMATION: RFC 7231 6.3.4 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.4 * Non-authoritative information:HTTP 1.1. The server successfully processed the request but is returning information from another source. */ NON_AUTHORITATIVE_INFORMATION = 'Non-Authoritative Information', /** - * 204: RFC 7231 6.3.5 + * NO_CONTENT: RFC 7231 6.3.5 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5 * No content:The server accepted the request but is not returning any content. This is often used as a response to a DELETE request. */ NO_CONTENT = 'No Content', /** - * 205: RFC 7231 6.3.6 + * RESET_CONTENT: RFC 7231 6.3.6 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 * Reset content:Similar to a 204 No Content response but this response requires the requester to reset the document view. */ RESET_CONTENT = 'Reset Content', /** - * 206: RFC 7233 4.1 + * PARTIAL_CONTENT: RFC 7233 4.1 * https://datatracker.ietf.org/doc/html/rfc7233#section-4.1 * Partial content:The server is delivering only a portion of the content, as requested by the client via a range header. */ PARTIAL_CONTENT = 'Partial Content', /** - * 207: RFC 4918 11.1 + * MULTI_STATUS: RFC 4918 11.1 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.1 * Multi-status:The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made. */ MULTI_STATUS = 'Multi-Status', /** - * 208: RFC 5842 7.1 + * ALREADY_REPORTED: RFC 5842 7.1 * https://datatracker.ietf.org/doc/html/rfc5842#section-7.1 * Already reported:The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again. */ ALREADY_REPORTED = 'Already Reported', /** - * 226: RFC 3229 10.4.1 + * IM_USED: RFC 3229 10.4.1 * https://datatracker.ietf.org/doc/html/rfc3229#section-10.4.1 * IM used:The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance. */ IM_USED = 'IM Used', /** - * 300: RFC 7231 6.4.1 + * MULTIPLE_CHOICES: RFC 7231 6.4.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.1 * Multiple choices:There are multiple options that the client may follow. */ MULTIPLE_CHOICES = 'Multiple Choices', /** - * 301: RFC 7231 6.4.2 + * MOVED_PERMANENTLY: RFC 7231 6.4.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2 * Moved permanently:The resource has been moved and all further requests should reference its new URI. */ MOVED_PERMANENTLY = 'Moved Permanently', /** - * 302: RFC 7231 6.4.3 + * FOUND: RFC 7231 6.4.3 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3 * Found:The HTTP 1.0 specification described this status as "Moved Temporarily", but popular browsers respond to this status similar to behavior intended for 303. The resource can be retrieved by referencing the returned URI. */ FOUND = 'Found', /** - * 303: RFC 7231 6.4.4 + * SEE_OTHER: RFC 7231 6.4.4 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4 * See other:The resource can be retrieved by following other URI using the GET method. When received in response to a POST, PUT, or DELETE, it can usually be assumed that the server processed the request successfully and is sending the client to an informational endpoint. */ SEE_OTHER = 'See Other', /** - * 304: RFC 7232 4.1 + * NOT_MODIFIED: RFC 7232 4.1 * https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 * Not modified:The resource has not been modified since the version specified in If-Modified-Since or If-Match headers. The resource will not be returned in response body. */ NOT_MODIFIED = 'Not Modified', /** - * 305: RFC 7231 6.4.5 + * USE_PROXY: RFC 7231 6.4.5 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.5 * Use proxy:HTTP 1.1. The resource is only available through a proxy and the address is provided in the response. */ USE_PROXY = 'Use Proxy', /** - * 306: + * SWITCH_PROXY: * Empty * Switch proxy:Deprecated in HTTP 1.1. Used to mean that subsequent requests should be sent using the specified proxy. */ SWITCH_PROXY = 'Switch proxy', /** - * 307: RFC 7231 6.4.7 + * TEMPORARY_REDIRECT: RFC 7231 6.4.7 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 * Temporary redirect:HTTP 1.1. The request should be repeated with the URI provided in the response, but future requests should still call the original URI. */ TEMPORARY_REDIRECT = 'Temporary Redirect', /** - * 308: RFC 7238 3 + * PERMANENT_REDIRECT: RFC 7238 3 * https://datatracker.ietf.org/doc/html/rfc7238#section-3 * Resume Incomplete (Google):This code is used in the Resumable HTTP Requests Proposal to resume aborted PUT or POST requests */ PERMANENT_REDIRECT = 'Permanent Redirect', /** - * 400: RFC 7231 6.5.1 + * BAD_REQUEST: RFC 7231 6.5.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1 * Bad request:The request could not be fulfilled due to the incorrect syntax of the request. */ BAD_REQUEST = 'Bad Request', /** - * 401: RFC 7235 3.1 + * UNAUTHORIZED: RFC 7235 3.1 * https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 * Unauthorized:The requester is not authorized to access the resource. This is similar to 403 but is used in cases where authentication is expected but has failed or has not been provided. */ UNAUTHORIZED = 'Unauthorized', /** - * 402: RFC 7231 6.5.2 + * PAYMENT_REQUIRED: RFC 7231 6.5.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2 * Payment required:Reserved for future use. Some web services use this as an indication that the client has sent an excessive number of requests. */ PAYMENT_REQUIRED = 'Payment Required', /** - * 403: RFC 7231 6.5.3 + * FORBIDDEN: RFC 7231 6.5.3 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3 * Forbidden:The request was formatted correctly but the server is refusing to supply the requested resource. Unlike 401, authenticating will not make a difference in the server's response. */ FORBIDDEN = 'Forbidden', /** - * 404: RFC 7231 6.5.4 + * NOT_FOUND: RFC 7231 6.5.4 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 * Not found:The resource could not be found. This is often used as a catch-all for all invalid URIs requested of the server. */ NOT_FOUND = 'Not Found', /** - * 405: RFC 7231 6.5.5 + * METHOD_NOT_ALLOWED: RFC 7231 6.5.5 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5 * Method not allowed:The resource was requested using a method that is not allowed. For example, requesting a resource via a POST method when the resource only supports the GET method. */ METHOD_NOT_ALLOWED = 'Method Not Allowed', /** - * 406: RFC 7231 6.5.6 + * NOT_ACCEPTABLE: RFC 7231 6.5.6 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.6 * Not acceptable:The resource is valid, but cannot be provided in a format specified in the Accept headers in the request. */ NOT_ACCEPTABLE = 'Not Acceptable', /** - * 407: RFC 7235 3.2 + * PROXY_AUTHENTICATION_REQUIRED: RFC 7235 3.2 * https://datatracker.ietf.org/doc/html/rfc7235#section-3.2 * Proxy authentication required:Authentication is required with the proxy before requests can be fulfilled. */ PROXY_AUTHENTICATION_REQUIRED = 'Proxy Authentication Required', /** - * 408: RFC 7231 6.5.7 + * REQUEST_TIMEOUT: RFC 7231 6.5.7 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.7 * Request timeout:The server timed out waiting for a request from the client. The client is allowed to repeat the request. */ REQUEST_TIMEOUT = 'Request Timeout', /** - * 409: RFC 7231 6.5.8 + * CONFLICT: RFC 7231 6.5.8 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8 * Conflict:The request cannot be completed due to a conflict in the request parameters. */ CONFLICT = 'Conflict', /** - * 410: RFC 7231 6.5.9 + * GONE: RFC 7231 6.5.9 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.9 * Gone:The resource is no longer available at the requested URI and no redirection will be given. */ GONE = 'Gone', /** - * 411: RFC 7231 6.5.10 + * LENGTH_REQUIRED: RFC 7231 6.5.10 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.10 * Length required:The request did not specify the length of its content as required by the resource. */ LENGTH_REQUIRED = 'Length Required', /** - * 412: RFC 7232 4.2 + * PRECONDITION_FAILED: RFC 7232 4.2 * https://datatracker.ietf.org/doc/html/rfc7232#section-4.2 * Precondition failed:The server does not meet one of the preconditions specified by the client. */ PRECONDITION_FAILED = 'Precondition Failed', /** - * 413: RFC 7231 6.5.11 + * PAYLOAD_TOO_LARGE: RFC 7231 6.5.11 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.11 * Request entity too large:The request is larger than what the server is able to process. */ PAYLOAD_TOO_LARGE = 'Payload Too Large', /** - * 414: RFC 7231 6.5.12 + * URI_TOO_LONG: RFC 7231 6.5.12 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.12 * Request-URI too long:The URI provided in the request is too long for the server to process. This is often used when too much data has been encoded into the URI of a GET request and a POST request should be used instead. */ URI_TOO_LONG = 'URI Too Long', /** - * 415: RFC 7231 6.5.13 + * UNSUPPORTED_MEDIA_TYPE: RFC 7231 6.5.13 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.13 * Unsupported media type:The client provided data with a media type that the server does not support. */ UNSUPPORTED_MEDIA_TYPE = 'Unsupported Media Type', /** - * 416: RFC 7233 4.4 + * RANGE_NOT_SATISFIABLE: RFC 7233 4.4 * https://datatracker.ietf.org/doc/html/rfc7233#section-4.4 * Requested range not satisfiable:The client has asked for a portion of the resource but the server cannot supply that portion. */ RANGE_NOT_SATISFIABLE = 'Range Not Satisfiable', /** - * 417: RFC 7231 6.5.14 + * EXPECTATION_FAILED: RFC 7231 6.5.14 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.14 * Expectation failed:The server cannot meet the requirements of the Expect request-header field. */ EXPECTATION_FAILED = 'Expectation Failed', /** - * 418: + * I_M_A_TEAPOT: * Empty * I'm a teapot:Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout. */ I_M_A_TEAPOT = 'I\'m a Teapot', /** - * 421: RFC 7540 9.1.2 + * MISDIRECTED_REQUEST: RFC 7540 9.1.2 * https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2 * Misdirected request:The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI. */ MISDIRECTED_REQUEST = 'Misdirected Request', /** - * 422: RFC 4918 11.2 + * UNPROCESSABLE_ENTITY: RFC 4918 11.2 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.2 * Unprocessable entity:The request was formatted correctly but cannot be processed in its current form. Often used when the specified parameters fail validation errors. */ UNPROCESSABLE_ENTITY = 'Unprocessable Entity', /** - * 423: RFC 4918 11.3 + * LOCKED: RFC 4918 11.3 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.3 * Locked:The requested resource was found but has been locked and will not be returned. */ LOCKED = 'Locked', /** - * 424: RFC 4918 11.4 + * FAILED_DEPENDENCY: RFC 4918 11.4 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.4 * Failed dependency:The request failed due to a failure of a previous request. */ FAILED_DEPENDENCY = 'Failed Dependency', /** - * 426: RFC 2817 and RFC 7231 6.5.15 + * UPGRADE_REQUIRED: RFC 2817 and RFC 7231 6.5.15 * https://datatracker.ietf.org/doc/html/rfc2817 and https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.15 * Upgrade required:The client should repeat the request using an upgraded protocol such as TLS 1.0. */ UPGRADE_REQUIRED = 'Upgrade Required', /** - * 428: RFC 6585 3 + * PRECONDITION_REQUIRED: RFC 6585 3 * https://datatracker.ietf.org/doc/html/rfc6585#section-3 * Precondition required:The origin server requires the request to be conditional. */ PRECONDITION_REQUIRED = 'Precondition Required', /** - * 429: RFC 6585 4 + * TOO_MANY_REQUESTS: RFC 6585 4 * https://datatracker.ietf.org/doc/html/rfc6585#section-4 * Too many requests:The user has sent too many requests in a given amount of time ("rate limiting"). */ TOO_MANY_REQUESTS = 'Too Many Requests', /** - * 431: RFC 6585 5 + * REQUEST_HEADER_FIELDS_TOO_LARGE: RFC 6585 5 * https://datatracker.ietf.org/doc/html/rfc6585#section-5 * Request header fields too large:The server is unwilling to process the request because its header fields are too large. */ REQUEST_HEADER_FIELDS_TOO_LARGE = 'Request Header Fields Too Large', /** - * 440: + * LOGIN_TIMEOUT_MICROSOFT: * Empty * Login Timeout (Microsoft):A Microsoft extension. Indicates that your session has expired. */ LOGIN_TIMEOUT_MICROSOFT = 'Login Timeout (Microsoft)', /** - * 444: + * NO_RESPONSE_NGINX: * Empty * No Response (Nginx):Used in Nginx logs to indicate that the server has returned no information to the client and closed the connection (useful as a deterrent for malware). */ NO_RESPONSE_NGINX = 'No Response (Nginx)', /** - * 449: + * RETRY_WITH_MICROSOFT: * Empty * Retry With (Microsoft):A Microsoft extension. The request should be retried after performing the appropriate action. */ RETRY_WITH_MICROSOFT = 'Retry With (Microsoft)', /** - * 450: + * BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS_MICROSOFT: * Empty * Blocked by Windows Parental Controls (Microsoft):A Microsoft extension. This error is given when Windows Parental Controls are turned on and are blocking access to the given webpage. */ BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS_MICROSOFT = 'Blocked by Windows Parental Controls (Microsoft)', /** - * 451: RFC 7725 3 + * UNAVAILABLE_FOR_LEGAL_REASONS: RFC 7725 3 * https://datatracker.ietf.org/doc/html/rfc7725#section-3 * Redirect (Microsoft):Used in Exchange ActiveSync if there either is a more efficient server to use or the server cannot access the users' mailbox. */ UNAVAILABLE_FOR_LEGAL_REASONS = 'Unavailable For Legal Reasons', /** - * 494: + * REQUEST_HEADER_TOO_LARGE_NGINX: * Empty * Request Header Too Large (Nginx):Nginx internal code similar to 431 but it was introduced earlier in version 0.9.4 (on January 21, 2011). */ REQUEST_HEADER_TOO_LARGE_NGINX = 'Request Header Too Large (Nginx)', /** - * 495: + * CERT_ERROR_NGINX: * Empty * Cert Error (Nginx):Nginx internal code used when SSL client certificate error occurred to distinguish it from 4XX in a log and an error page redirection. */ CERT_ERROR_NGINX = 'Cert Error (Nginx)', /** - * 496: + * NO_CERT_NGINX: * Empty * No Cert (Nginx):Nginx internal code used when client didn't provide certificate to distinguish it from 4XX in a log and an error page redirection. */ NO_CERT_NGINX = 'No Cert (Nginx)', /** - * 497: + * HTTP_TO_HTTPS_NGINX: * Empty * HTTP to HTTPS (Nginx):Nginx internal code used for the plain HTTP requests that are sent to HTTPS port to distinguish it from 4XX in a log and an error page redirection. */ HTTP_TO_HTTPS_NGINX = 'HTTP to HTTPS (Nginx)', /** - * 498: + * TOKEN_EXPIRED_INVALID_ESRI: * Empty * Token expired/invalid (Esri):Returned by ArcGIS for Server. A code of 498 indicates an expired or otherwise invalid token. */ TOKEN_EXPIRED_INVALID_ESRI = 'Token expired/invalid (Esri)', /** - * 499: + * TOKEN_REQUIRED_ESRI: * Empty * Token required (Esri):Returned by ArcGIS for Server. A code of 499 indicates that a token is required (if no token was submitted). */ TOKEN_REQUIRED_ESRI = 'Token required (Esri)', /** - * 500: RFC 7231 6.6.1 + * INTERNAL_SERVER_ERROR: RFC 7231 6.6.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1 * Internal server error:A generic status for an error in the server itself. */ INTERNAL_SERVER_ERROR = 'Internal Server Error', /** - * 501: RFC 7231 6.6.2 + * NOT_IMPLEMENTED: RFC 7231 6.6.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2 * Not implemented:The server cannot respond to the request. This usually implies that the server could possibly support the request in the future — otherwise a 4xx status may be more appropriate. */ NOT_IMPLEMENTED = 'Not Implemented', /** - * 502: RFC 7231 6.6.3 + * BAD_GATEWAY: RFC 7231 6.6.3 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3 * Bad gateway:The server is acting as a proxy and did not receive an acceptable response from the upstream server. */ BAD_GATEWAY = 'Bad Gateway', /** - * 503: RFC 7231 6.6.4 + * SERVICE_UNAVAILABLE: RFC 7231 6.6.4 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4 * Service unavailable:The server is down and is not accepting requests. */ SERVICE_UNAVAILABLE = 'Service Unavailable', /** - * 504: RFC 7231 6.6.5 + * GATEWAY_TIMEOUT: RFC 7231 6.6.5 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5 * Gateway timeout:The server is acting as a proxy and did not receive a response from the upstream server. */ GATEWAY_TIMEOUT = 'Gateway Timeout', /** - * 505: RFC 7231 6.6.6 + * HTTP_VERSION_NOT_SUPPORTED: RFC 7231 6.6.6 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.6 * HTTP version not supported:The server does not support the HTTP protocol version specified in the request. */ HTTP_VERSION_NOT_SUPPORTED = 'HTTP Version Not Supported', /** - * 506: RFC 2295 8.1 + * VARIANT_ALSO_NEGOTIATES: RFC 2295 8.1 * https://datatracker.ietf.org/doc/html/rfc2295#section-8.1 * Variant also negotiates:Transparent content negotiation for the request results in a circular reference. */ VARIANT_ALSO_NEGOTIATES = 'Variant Also Negotiates', /** - * 507: RFC 4918 11.5 + * INSUFFICIENT_STORAGE: RFC 4918 11.5 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.5 * Insufficient storage:The user or server does not have sufficient storage quota to fulfill the request. */ INSUFFICIENT_STORAGE = 'Insufficient Storage', /** - * 508: RFC 5842 7.2 + * LOOP_DETECTED: RFC 5842 7.2 * https://datatracker.ietf.org/doc/html/rfc5842#section-7.2 * Loop detected:The server detected an infinite loop in the request. */ LOOP_DETECTED = 'Loop Detected', /** - * 509: + * BANDWIDTH_LIMIT_EXCEEDED: * Empty * Bandwidth Limit Exceeded (Apache bw/limited extension):This status code is not specified in any RFCs. Its use is unknown. */ BANDWIDTH_LIMIT_EXCEEDED = 'Bandwidth Limit Exceeded', /** - * 510: RFC 2774 7 + * NOT_EXTENDED: RFC 2774 7 * https://datatracker.ietf.org/doc/html/rfc2774#section-7 * Not extended:Further extensions to the request are necessary for it to be fulfilled. */ NOT_EXTENDED = 'Not Extended', /** - * 511: RFC 6585 6 + * NETWORK_AUTHENTICATION_REQUIRED: RFC 6585 6 * https://datatracker.ietf.org/doc/html/rfc6585#section-6 * Network authentication required:The client must authenticate with the network before sending requests. */ NETWORK_AUTHENTICATION_REQUIRED = 'Network Authentication Required', /** - * 520: + * UNKNOWN_ERROR_MICROSOFT_CLOUD_FLARE: * Empty * Unknown Error (Microsoft / CloudFlare):This status code is not specified in any RFC and is returned by certain services, for instance Microsoft Azure and CloudFlare servers: "The 520 error is essentially a "catch-all" response for when the origin server returns something unexpected or something that is not tolerated/interpreted (protocol violation or empty response)." */ UNKNOWN_ERROR_MICROSOFT_CLOUD_FLARE = 'Unknown Error (Microsoft / CloudFlare)', /** - * 521: + * WEB_SERVER_IS_DOWN_CLOUD_FLARE: * Empty * Web Server Is Down (CloudFlare):The origin server has refused the connection from CloudFlare. */ WEB_SERVER_IS_DOWN_CLOUD_FLARE = 'Web Server Is Down (CloudFlare)', /** - * 522: + * CONNECTION_TIMED_OUT_CLOUD_FLARE: * Empty * Connection Timed Out (CloudFlare):CloudFlare could not negotiate a TCP handshake with the origin server. */ CONNECTION_TIMED_OUT_CLOUD_FLARE = 'Connection Timed Out (CloudFlare)', /** - * 523: + * ORIGIN_IS_UNREACHABLE_CLOUD_FLARE: * Empty * Origin Is Unreachable (CloudFlare):CloudFlare could not reach the origin server; for example, if the DNS records for the origin server are incorrect. */ ORIGIN_IS_UNREACHABLE_CLOUD_FLARE = 'Origin Is Unreachable (CloudFlare)', /** - * 524: + * A_TIMEOUT_OCCURRED_CLOUD_FLARE: * Empty * A Timeout Occurred (CloudFlare):CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response. */ A_TIMEOUT_OCCURRED_CLOUD_FLARE = 'A Timeout Occurred (CloudFlare)', /** - * 525: + * SSL_HANDSHAKE_FAILED_CLOUD_FLARE: * Empty * SSL Handshake Failed (CloudFlare):CloudFlare could not negotiate a SSL/TLS handshake with the origin server. */ SSL_HANDSHAKE_FAILED_CLOUD_FLARE = 'SSL Handshake Failed (CloudFlare)', /** - * 526: + * INVALID_SSL_CERTIFICATE_CLOUD_FLARE: * Empty * Invalid SSL Certificate (CloudFlare):CloudFlare could not validate the SSL/TLS certificate that the origin server presented. */ INVALID_SSL_CERTIFICATE_CLOUD_FLARE = 'Invalid SSL Certificate (CloudFlare)', /** - * 527: + * RAILGUN_ERROR_CLOUD_FLARE: * Empty * Railgun Error (CloudFlare):The request timed out or failed after the WAN connection has been established. */ RAILGUN_ERROR_CLOUD_FLARE = 'Railgun Error (CloudFlare)' } + +export enum HttpStatusTextByCode { + /** + * h100: RFC 7231 6.2.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.1 + * Continue:The server has received the request headers, and that the client should proceed to send the request body. + */ + h100 = 'Continue', + /** + * h101: RFC 7231 6.2.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.2 + * Switching protocols:The requester has asked the server to switch protocols and the server is acknowledging that it will do so. + */ + h101 = 'Switching Protocols', + /** + * h102: RFC 2518 10.1 (obsoleted by RFC 4918) + * https://datatracker.ietf.org/doc/html/rfc2518#section-10.1 + * Processing:The server has received and is processing the request, but no response is available yet. + */ + h102 = 'Processing', + /** + * h200: RFC 7231 6.3.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1 + * OK:The standard response for successful HTTP requests. + */ + h200 = 'OK', + /** + * h201: RFC 7231 6.3.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2 + * Created:The request has been fulfilled and a new resource has been created. + */ + h201 = 'Created', + /** + * h202: RFC 7231 6.3.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3 + * Accepted:The request has been accepted but has not been processed yet. This code does not guarantee that the request will process successfully. + */ + h202 = 'Accepted', + /** + * h203: RFC 7231 6.3.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.4 + * Non-authoritative information:HTTP 1.1. The server successfully processed the request but is returning information from another source. + */ + h203 = 'Non-Authoritative Information', + /** + * h204: RFC 7231 6.3.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5 + * No content:The server accepted the request but is not returning any content. This is often used as a response to a DELETE request. + */ + h204 = 'No Content', + /** + * h205: RFC 7231 6.3.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 + * Reset content:Similar to a 204 No Content response but this response requires the requester to reset the document view. + */ + h205 = 'Reset Content', + /** + * h206: RFC 7233 4.1 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.1 + * Partial content:The server is delivering only a portion of the content, as requested by the client via a range header. + */ + h206 = 'Partial Content', + /** + * h207: RFC 4918 11.1 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.1 + * Multi-status:The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made. + */ + h207 = 'Multi-Status', + /** + * h208: RFC 5842 7.1 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.1 + * Already reported:The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again. + */ + h208 = 'Already Reported', + /** + * h226: RFC 3229 10.4.1 + * https://datatracker.ietf.org/doc/html/rfc3229#section-10.4.1 + * IM used:The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance. + */ + h226 = 'IM Used', + /** + * h300: RFC 7231 6.4.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.1 + * Multiple choices:There are multiple options that the client may follow. + */ + h300 = 'Multiple Choices', + /** + * h301: RFC 7231 6.4.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2 + * Moved permanently:The resource has been moved and all further requests should reference its new URI. + */ + h301 = 'Moved Permanently', + /** + * h302: RFC 7231 6.4.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3 + * Found:The HTTP 1.0 specification described this status as "Moved Temporarily", but popular browsers respond to this status similar to behavior intended for 303. The resource can be retrieved by referencing the returned URI. + */ + h302 = 'Found', + /** + * h303: RFC 7231 6.4.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4 + * See other:The resource can be retrieved by following other URI using the GET method. When received in response to a POST, PUT, or DELETE, it can usually be assumed that the server processed the request successfully and is sending the client to an informational endpoint. + */ + h303 = 'See Other', + /** + * h304: RFC 7232 4.1 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 + * Not modified:The resource has not been modified since the version specified in If-Modified-Since or If-Match headers. The resource will not be returned in response body. + */ + h304 = 'Not Modified', + /** + * h305: RFC 7231 6.4.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.5 + * Use proxy:HTTP 1.1. The resource is only available through a proxy and the address is provided in the response. + */ + h305 = 'Use Proxy', + /** + * h306: + * Empty + * Switch proxy:Deprecated in HTTP 1.1. Used to mean that subsequent requests should be sent using the specified proxy. + */ + h306 = 'Switch proxy', + /** + * h307: RFC 7231 6.4.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 + * Temporary redirect:HTTP 1.1. The request should be repeated with the URI provided in the response, but future requests should still call the original URI. + */ + h307 = 'Temporary Redirect', + /** + * h308: RFC 7238 3 + * https://datatracker.ietf.org/doc/html/rfc7238#section-3 + * Resume Incomplete (Google):This code is used in the Resumable HTTP Requests Proposal to resume aborted PUT or POST requests + */ + h308 = 'Permanent Redirect', + /** + * h400: RFC 7231 6.5.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1 + * Bad request:The request could not be fulfilled due to the incorrect syntax of the request. + */ + h400 = 'Bad Request', + /** + * h401: RFC 7235 3.1 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 + * Unauthorized:The requester is not authorized to access the resource. This is similar to 403 but is used in cases where authentication is expected but has failed or has not been provided. + */ + h401 = 'Unauthorized', + /** + * h402: RFC 7231 6.5.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2 + * Payment required:Reserved for future use. Some web services use this as an indication that the client has sent an excessive number of requests. + */ + h402 = 'Payment Required', + /** + * h403: RFC 7231 6.5.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3 + * Forbidden:The request was formatted correctly but the server is refusing to supply the requested resource. Unlike 401, authenticating will not make a difference in the server's response. + */ + h403 = 'Forbidden', + /** + * h404: RFC 7231 6.5.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 + * Not found:The resource could not be found. This is often used as a catch-all for all invalid URIs requested of the server. + */ + h404 = 'Not Found', + /** + * h405: RFC 7231 6.5.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5 + * Method not allowed:The resource was requested using a method that is not allowed. For example, requesting a resource via a POST method when the resource only supports the GET method. + */ + h405 = 'Method Not Allowed', + /** + * h406: RFC 7231 6.5.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.6 + * Not acceptable:The resource is valid, but cannot be provided in a format specified in the Accept headers in the request. + */ + h406 = 'Not Acceptable', + /** + * h407: RFC 7235 3.2 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.2 + * Proxy authentication required:Authentication is required with the proxy before requests can be fulfilled. + */ + h407 = 'Proxy Authentication Required', + /** + * h408: RFC 7231 6.5.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.7 + * Request timeout:The server timed out waiting for a request from the client. The client is allowed to repeat the request. + */ + h408 = 'Request Timeout', + /** + * h409: RFC 7231 6.5.8 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8 + * Conflict:The request cannot be completed due to a conflict in the request parameters. + */ + h409 = 'Conflict', + /** + * h410: RFC 7231 6.5.9 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.9 + * Gone:The resource is no longer available at the requested URI and no redirection will be given. + */ + h410 = 'Gone', + /** + * h411: RFC 7231 6.5.10 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.10 + * Length required:The request did not specify the length of its content as required by the resource. + */ + h411 = 'Length Required', + /** + * h412: RFC 7232 4.2 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.2 + * Precondition failed:The server does not meet one of the preconditions specified by the client. + */ + h412 = 'Precondition Failed', + /** + * h413: RFC 7231 6.5.11 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.11 + * Request entity too large:The request is larger than what the server is able to process. + */ + h413 = 'Payload Too Large', + /** + * h414: RFC 7231 6.5.12 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.12 + * Request-URI too long:The URI provided in the request is too long for the server to process. This is often used when too much data has been encoded into the URI of a GET request and a POST request should be used instead. + */ + h414 = 'URI Too Long', + /** + * h415: RFC 7231 6.5.13 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.13 + * Unsupported media type:The client provided data with a media type that the server does not support. + */ + h415 = 'Unsupported Media Type', + /** + * h416: RFC 7233 4.4 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.4 + * Requested range not satisfiable:The client has asked for a portion of the resource but the server cannot supply that portion. + */ + h416 = 'Range Not Satisfiable', + /** + * h417: RFC 7231 6.5.14 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.14 + * Expectation failed:The server cannot meet the requirements of the Expect request-header field. + */ + h417 = 'Expectation Failed', + /** + * h418: + * Empty + * I'm a teapot:Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout. + */ + h418 = 'I\'m a Teapot', + /** + * h421: RFC 7540 9.1.2 + * https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2 + * Misdirected request:The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI. + */ + h421 = 'Misdirected Request', + /** + * h422: RFC 4918 11.2 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.2 + * Unprocessable entity:The request was formatted correctly but cannot be processed in its current form. Often used when the specified parameters fail validation errors. + */ + h422 = 'Unprocessable Entity', + /** + * h423: RFC 4918 11.3 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.3 + * Locked:The requested resource was found but has been locked and will not be returned. + */ + h423 = 'Locked', + /** + * h424: RFC 4918 11.4 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.4 + * Failed dependency:The request failed due to a failure of a previous request. + */ + h424 = 'Failed Dependency', + /** + * h426: RFC 2817 and RFC 7231 6.5.15 + * https://datatracker.ietf.org/doc/html/rfc2817 and https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.15 + * Upgrade required:The client should repeat the request using an upgraded protocol such as TLS 1.0. + */ + h426 = 'Upgrade Required', + /** + * h428: RFC 6585 3 + * https://datatracker.ietf.org/doc/html/rfc6585#section-3 + * Precondition required:The origin server requires the request to be conditional. + */ + h428 = 'Precondition Required', + /** + * h429: RFC 6585 4 + * https://datatracker.ietf.org/doc/html/rfc6585#section-4 + * Too many requests:The user has sent too many requests in a given amount of time ("rate limiting"). + */ + h429 = 'Too Many Requests', + /** + * h431: RFC 6585 5 + * https://datatracker.ietf.org/doc/html/rfc6585#section-5 + * Request header fields too large:The server is unwilling to process the request because its header fields are too large. + */ + h431 = 'Request Header Fields Too Large', + /** + * h440: + * Empty + * Login Timeout (Microsoft):A Microsoft extension. Indicates that your session has expired. + */ + h440 = 'Login Timeout (Microsoft)', + /** + * h444: + * Empty + * No Response (Nginx):Used in Nginx logs to indicate that the server has returned no information to the client and closed the connection (useful as a deterrent for malware). + */ + h444 = 'No Response (Nginx)', + /** + * h449: + * Empty + * Retry With (Microsoft):A Microsoft extension. The request should be retried after performing the appropriate action. + */ + h449 = 'Retry With (Microsoft)', + /** + * h450: + * Empty + * Blocked by Windows Parental Controls (Microsoft):A Microsoft extension. This error is given when Windows Parental Controls are turned on and are blocking access to the given webpage. + */ + h450 = 'Blocked by Windows Parental Controls (Microsoft)', + /** + * h451: RFC 7725 3 + * https://datatracker.ietf.org/doc/html/rfc7725#section-3 + * Redirect (Microsoft):Used in Exchange ActiveSync if there either is a more efficient server to use or the server cannot access the users' mailbox. + */ + h451 = 'Unavailable For Legal Reasons', + /** + * h494: + * Empty + * Request Header Too Large (Nginx):Nginx internal code similar to 431 but it was introduced earlier in version 0.9.4 (on January 21, 2011). + */ + h494 = 'Request Header Too Large (Nginx)', + /** + * h495: + * Empty + * Cert Error (Nginx):Nginx internal code used when SSL client certificate error occurred to distinguish it from 4XX in a log and an error page redirection. + */ + h495 = 'Cert Error (Nginx)', + /** + * h496: + * Empty + * No Cert (Nginx):Nginx internal code used when client didn't provide certificate to distinguish it from 4XX in a log and an error page redirection. + */ + h496 = 'No Cert (Nginx)', + /** + * h497: + * Empty + * HTTP to HTTPS (Nginx):Nginx internal code used for the plain HTTP requests that are sent to HTTPS port to distinguish it from 4XX in a log and an error page redirection. + */ + h497 = 'HTTP to HTTPS (Nginx)', + /** + * h498: + * Empty + * Token expired/invalid (Esri):Returned by ArcGIS for Server. A code of 498 indicates an expired or otherwise invalid token. + */ + h498 = 'Token expired/invalid (Esri)', + /** + * h499: + * Empty + * Token required (Esri):Returned by ArcGIS for Server. A code of 499 indicates that a token is required (if no token was submitted). + */ + h499 = 'Token required (Esri)', + /** + * h500: RFC 7231 6.6.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1 + * Internal server error:A generic status for an error in the server itself. + */ + h500 = 'Internal Server Error', + /** + * h501: RFC 7231 6.6.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2 + * Not implemented:The server cannot respond to the request. This usually implies that the server could possibly support the request in the future — otherwise a 4xx status may be more appropriate. + */ + h501 = 'Not Implemented', + /** + * h502: RFC 7231 6.6.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3 + * Bad gateway:The server is acting as a proxy and did not receive an acceptable response from the upstream server. + */ + h502 = 'Bad Gateway', + /** + * h503: RFC 7231 6.6.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4 + * Service unavailable:The server is down and is not accepting requests. + */ + h503 = 'Service Unavailable', + /** + * h504: RFC 7231 6.6.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5 + * Gateway timeout:The server is acting as a proxy and did not receive a response from the upstream server. + */ + h504 = 'Gateway Timeout', + /** + * h505: RFC 7231 6.6.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.6 + * HTTP version not supported:The server does not support the HTTP protocol version specified in the request. + */ + h505 = 'HTTP Version Not Supported', + /** + * h506: RFC 2295 8.1 + * https://datatracker.ietf.org/doc/html/rfc2295#section-8.1 + * Variant also negotiates:Transparent content negotiation for the request results in a circular reference. + */ + h506 = 'Variant Also Negotiates', + /** + * h507: RFC 4918 11.5 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.5 + * Insufficient storage:The user or server does not have sufficient storage quota to fulfill the request. + */ + h507 = 'Insufficient Storage', + /** + * h508: RFC 5842 7.2 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.2 + * Loop detected:The server detected an infinite loop in the request. + */ + h508 = 'Loop Detected', + /** + * h509: + * Empty + * Bandwidth Limit Exceeded (Apache bw/limited extension):This status code is not specified in any RFCs. Its use is unknown. + */ + h509 = 'Bandwidth Limit Exceeded', + /** + * h510: RFC 2774 7 + * https://datatracker.ietf.org/doc/html/rfc2774#section-7 + * Not extended:Further extensions to the request are necessary for it to be fulfilled. + */ + h510 = 'Not Extended', + /** + * h511: RFC 6585 6 + * https://datatracker.ietf.org/doc/html/rfc6585#section-6 + * Network authentication required:The client must authenticate with the network before sending requests. + */ + h511 = 'Network Authentication Required', + /** + * h520: + * Empty + * Unknown Error (Microsoft / CloudFlare):This status code is not specified in any RFC and is returned by certain services, for instance Microsoft Azure and CloudFlare servers: "The 520 error is essentially a "catch-all" response for when the origin server returns something unexpected or something that is not tolerated/interpreted (protocol violation or empty response)." + */ + h520 = 'Unknown Error (Microsoft / CloudFlare)', + /** + * h521: + * Empty + * Web Server Is Down (CloudFlare):The origin server has refused the connection from CloudFlare. + */ + h521 = 'Web Server Is Down (CloudFlare)', + /** + * h522: + * Empty + * Connection Timed Out (CloudFlare):CloudFlare could not negotiate a TCP handshake with the origin server. + */ + h522 = 'Connection Timed Out (CloudFlare)', + /** + * h523: + * Empty + * Origin Is Unreachable (CloudFlare):CloudFlare could not reach the origin server; for example, if the DNS records for the origin server are incorrect. + */ + h523 = 'Origin Is Unreachable (CloudFlare)', + /** + * h524: + * Empty + * A Timeout Occurred (CloudFlare):CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response. + */ + h524 = 'A Timeout Occurred (CloudFlare)', + /** + * h525: + * Empty + * SSL Handshake Failed (CloudFlare):CloudFlare could not negotiate a SSL/TLS handshake with the origin server. + */ + h525 = 'SSL Handshake Failed (CloudFlare)', + /** + * h526: + * Empty + * Invalid SSL Certificate (CloudFlare):CloudFlare could not validate the SSL/TLS certificate that the origin server presented. + */ + h526 = 'Invalid SSL Certificate (CloudFlare)', + /** + * h527: + * Empty + * Railgun Error (CloudFlare):The request timed out or failed after the WAN connection has been established. + */ + h527 = 'Railgun Error (CloudFlare)' +} diff --git a/packages/i18n-zh/src/lib/helpers.ts b/packages/i18n-zh/src/lib/helpers.ts index 943b80a..be73aa5 100644 --- a/packages/i18n-zh/src/lib/helpers.ts +++ b/packages/i18n-zh/src/lib/helpers.ts @@ -14,341 +14,59 @@ * 祝你编程愉快!记住,代码是诗歌,前端是艺术。 ツ */ +import { HttpStatusCode, HttpStatusCodeByCode } from './status-code'; +import { HttpStatusText, HttpStatusTextByCode } from './status-text'; +import { HttpStatusDescriptionByCode } from './status-description'; + /** Key-value mapping of HTTP status codes and HTTP status texts. */ -export const statusCodeToStatusTextMap: Record = { - 100: "Continue", - 101: "Switching Protocols", - 102: "Processing", - 200: "OK", - 201: "Created", - 202: "Accepted", - 203: "Non-Authoritative Information", - 204: "No Content", - 205: "Reset Content", - 206: "Partial Content", - 207: "Multi-Status", - 208: "Already Reported", - 226: "IM Used", - 300: "Multiple Choices", - 301: "Moved Permanently", - 302: "Found", - 303: "See Other", - 304: "Not Modified", - 305: "Use Proxy", - 306: "Switch proxy", - 307: "Temporary Redirect", - 308: "Permanent Redirect", - 400: "Bad Request", - 401: "Unauthorized", - 402: "Payment Required", - 403: "Forbidden", - 404: "Not Found", - 405: "Method Not Allowed", - 406: "Not Acceptable", - 407: "Proxy Authentication Required", - 408: "Request Timeout", - 409: "Conflict", - 410: "Gone", - 411: "Length Required", - 412: "Precondition Failed", - 413: "Payload Too Large", - 414: "URI Too Long", - 415: "Unsupported Media Type", - 416: "Range Not Satisfiable", - 417: "Expectation Failed", - 418: "I'm a Teapot", - 421: "Misdirected Request", - 422: "Unprocessable Entity", - 423: "Locked", - 424: "Failed Dependency", - 426: "Upgrade Required", - 428: "Precondition Required", - 429: "Too Many Requests", - 431: "Request Header Fields Too Large", - 440: "Login Time-out", - 444: "No Response", - 449: "Retry With", - 450: "Blocked by Windows Parental Controls", - 451: "Unavailable For Legal Reasons", - 494: "Request Header Too Large", - 495: "Cert Error", - 496: "No Cert", - 497: "HTTP to HTTPS", - 498: "Token expired/invalid", - 499: "Token required", - 500: "Internal Server Error", - 501: "Not Implemented", - 502: "Bad Gateway", - 503: "Service Unavailable", - 504: "Gateway Timeout", - 505: "HTTP Version Not Supported", - 506: "Variant Also Negotiates", - 507: "Insufficient Storage", - 508: "Loop Detected", - 509: "Bandwidth Limit Exceeded", - 510: "Not Extended", - 511: "Network Authentication Required", - 520: "Unknown Error (Microsoft / CloudFlare)", - 521: "Web Server Is Down (CloudFlare)", - 522: "Connection Timed Out (CloudFlare)", - 523: "Origin Is Unreachable (CloudFlare)", - 524: "A Timeout Occurred (CloudFlare)", - 525: "SSL Handshake Failed (CloudFlare)", - 526: "Invalid SSL Certificate (CloudFlare)", - 527: "Railgun Error (CloudFlare)" -}; +export const statusCodeToStatusTextMap: Record = Object.keys( + HttpStatusCodeByCode +) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusCodeByCode[cur as never]]: HttpStatusTextByCode[cur as never], + }), + {} + ); /** Key-value mapping of HTTP status codes and HTTP status descriptions. */ -export const statusCodeToStatusDescriptionMap: Record = { - 100: "继续:服务器已经收到请求头,客户端应继续发送请求主体。", - 101: "切换协议:请求者已要求服务器切换协议,服务器确认它将进行切换。", - 102: "处理中:服务器已收到请求并正在处理,但尚无可用的响应。", - 200: "成功:标准的成功 HTTP 请求响应。", - 201: "已创建:请求已完成并且新资源已创建。", - 202: "已接受:请求已被接受但尚未处理完毕。此代码不保证请求会成功处理。", - 203: "非权威信息:服务器成功处理了请求,但返回的是来自另一来源的信息。", - 204: "无内容:服务器接受了请求,但没有返回任何内容。通常作为 DELETE 请求的响应。", - 205: "重置内容:类似于 204 无内容响应,但此响应要求请求者重置文档视图。", - 206: "部分内容:服务器仅提供了客户端通过 Range 头请求的部分内容。", - 207: "多状态:后续的消息体是一个 XML 消息,可能包含多个响应代码,具体取决于有多少子请求被发出。", - 208: "已报告:DAV 绑定的成员已经在对此请求的先前回复中被枚举,不再重复包含。", - 226: "IM 使用:服务器已完成资源的 GET 请求,并且响应表示对当前实例应用了一个或多个实例操作的结果。", - 300: "多重选择:客户端可以选择多个选项中的一个进行操作。", - 301: "永久移动:资源已被移动,所有后续请求应参考其新的 URI。", - 302: "找到:HTTP 1.0 规范将此状态描述为“临时移动”,但流行的浏览器对此状态的响应类似于 303 的行为。资源可以通过参考返回的 URI 来获取。", - 303: "参见其他:资源可以通过使用 GET 方法来获取其他 URI。当在响应 POST、PUT 或 DELETE 请求时收到此状态码,通常可以认为服务器已成功处理请求并将客户端指向一个信息性端点。", - 304: "未修改:自 If-Modified-Since 或 If-Match 头中指定的版本以来,资源未被修改。响应主体中将不会返回资源。", - 305: "使用代理:HTTP 1.1。资源只能通过代理访问,地址在响应中提供。", - 306: "切换代理:在 HTTP 1.1 中已废弃。曾用于表示后续请求应使用指定的代理发送。", - 307: "临时重定向:HTTP 1.1。请求应使用响应中提供的 URI 重新发送,但未来的请求仍应调用原始 URI。", - 308: "永久重定向:请求和所有未来的请求应使用响应中提供的 URI 重新发送。", - 400: "错误请求:由于请求的语法不正确,无法满足请求。", - 401: "未授权:请求者未被授权访问该资源。与 403 类似,但用于身份验证失败或未提供身份验证的情况。", - 402: "需要付款:保留以供将来使用。某些网络服务使用此状态码表示客户端发送的请求次数过多。", - 403: "禁止:请求格式正确,但服务器拒绝提供请求的资源。与 401 不同,身份验证不会改变服务器的响应。", - 404: "未找到:找不到请求的资源。通常用于服务器上所有无效的 URI 请求。", - 405: "方法不允许:资源请求使用了不允许的方法。例如,使用 POST 方法请求资源,但该资源仅支持 GET 方法。", - 406: "不可接受:资源有效,但无法以请求中 Accept 头字段指定的格式提供。", - 407: "需要代理身份验证:在满足请求之前,需要对代理进行身份验证。", - 408: "请求超时:服务器等待客户端的请求超时。允许客户端重新发送请求。", - 409: "冲突:由于请求参数中的冲突,无法完成请求。", - 410: "已删除:请求的资源在请求的 URI 不再可用,且不会提供重定向。", - 411: "需要内容长度:请求未指定资源所需的内容长度。", - 412: "前提条件失败:服务器不满足客户端指定的一个前提条件。", - 413: "请求实体过大:请求的内容比服务器能够处理的要大。", - 414: "请求 URI 过长:请求中提供的 URI 过长,服务器无法处理。通常在 GET 请求的 URI 中编码了过多数据时会使用此状态码,此时应改用 POST 请求。", - 415: "不支持的媒体类型:客户端提供的数据类型不受服务器支持。", - 416: "请求的范围无法满足:客户端请求了资源的一部分,但服务器无法提供该部分。", - 417: "期望失败:服务器无法满足 Expect 请求头字段的要求。", - 418: "我是茶壶:任何尝试用茶壶煮咖啡的行为都应该导致错误代码 \"418 我是茶壶\"。生成的实体内容可能会又短又粗。", - 421: "请求错误定向:请求被定向到无法提供响应的服务器。该状态码可以由未配置为响应请求 URI 中包含的方案和授权组合的服务器发送。", - 422: "无法处理的实体:请求格式正确,但在当前表单中无法处理。通常在指定的参数未通过验证错误时使用。", - 423: "已锁定:请求的资源已找到,但由于其被锁定而无法访问。", - 424: "依赖失败:由于前一个请求失败,导致当前请求也失败。", - 426: "需要升级:客户端应切换到升级后的协议(如 TLS/1.0),然后再发送请求。", - 428: "需要前提条件:源服务器要求请求是有条件的。", - 429: "请求过多:用户在给定的时间内发送了过多的请求(\"速率限制\")。", - 431: "请求头字段过大:服务器不愿意处理请求,因为其头字段过大。", - 440: "登录超时:Microsoft 扩展。表示由于用户登录超时而导致的失败。", - 444: "无响应:Nginx 内部状态码,用于指示服务器未返回任何信息并关闭连接。", - 449: "重试:Microsoft 扩展。用于指示客户端应在执行适当操作后重新发送请求。", - 450: "被 Windows 家长控制阻止:Microsoft 扩展。当 Windows 家长控制阻止访问特定网页时出现。", - 451: "因法律原因不可用:服务器由于接到法律约束请求而无法操作。", - 494: "请求头字段过大:Nginx 内部代码,类似于 431,但在更早版本中实现。", - 495: "证书错误:Nginx 内部代码,用于 SSL 客户端证书错误,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。", - 496: "无证书:Nginx 内部代码,当客户端未提供证书时使用,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。", - 497: "HTTP 到 HTTPS:Nginx 内部代码,用于发送到 HTTPS 端口的纯 HTTP 请求,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。", - 498: "令牌过期/无效:由 ArcGIS for Server 返回。代码 498 表示令牌已过期或无效。", - 499: "需要令牌:由 ArcGIS for Server 返回。代码 499 表示需要令牌(如果未提交令牌)。", - 500: "服务器内部错误:服务器自身的通用错误状态。", - 501: "未实现:服务器无法响应请求,通常表示服务器可能在未来支持此请求,否则使用 4xx 状态码可能更为适当。", - 502: "错误网关:服务器作为代理时,从上游服务器接收到的响应无效。", - 503: "服务不可用:服务器停机,不接受请求。", - 504: "网关超时:服务器作为代理时,从上游服务器未能及时接收到响应。", - 505: "不支持的 HTTP 版本:服务器不支持请求中所用的 HTTP 协议版本。", - 506: "变体也在协商:请求的透明内容协商导致循环引用。", - 507: "存储空间不足:用户或服务器没有足够的存储配额来完成请求。", - 508: "检测到循环:服务器在请求中检测到无限循环。", - 509: "超出带宽限制(Apache bw/limited 扩展):此状态码未在任何 RFC 中规定,其使用方式未知。", - 510: "未扩展:需要进一步扩展请求才能完成。", - 511: "需要网络认证:客户端必须先通过网络认证,才能发送请求。", - 520: "未知错误(Microsoft / CloudFlare):此状态码未在任何 RFC 中规定,由某些服务返回,如 Microsoft Azure 和 CloudFlare 服务器:520 错误本质上是对源服务器返回意外响应或不可解释/不允许(协议违规或空响应)的 \"兜底\" 响应。", - 521: "Web 服务器宕机(CloudFlare):源服务器拒绝了来自 CloudFlare 的连接。", - 522: "连接超时(CloudFlare):CloudFlare 无法与源服务器完成 TCP 握手。", - 523: "源不可达(CloudFlare):CloudFlare 无法到达源服务器;例如,源服务器的 DNS 记录不正确。", - 524: "发生超时(CloudFlare):CloudFlare 能够与源服务器建立 TCP 连接,但未能及时收到 HTTP 响应。", - 525: "SSL 握手失败(CloudFlare):CloudFlare 无法与源服务器完成 SSL/TLS 握手。", - 526: "无效的 SSL 证书(CloudFlare):CloudFlare 无法验证源服务器提供的 SSL/TLS 证书。", - 527: "Railgun 错误(CloudFlare):在建立 WAN 连接后,请求超时或失败。" -}; +export const statusCodeToStatusDescriptionMap: Record = Object.keys( + HttpStatusCodeByCode +) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusCodeByCode[cur as never]]: HttpStatusDescriptionByCode[cur as never], + }), + {} + ); /** Key-value mapping of HTTP status texts and HTTP status codes. */ -export const statusTextToStatusCodeMap: Record = { - "Continue": 100, - "Switching Protocols": 101, - "Processing": 102, - "OK": 200, - "Created": 201, - "Accepted": 202, - "Non-Authoritative Information": 203, - "No Content": 204, - "Reset Content": 205, - "Partial Content": 206, - "Multi-Status": 207, - "Already Reported": 208, - "IM Used": 226, - "Multiple Choices": 300, - "Moved Permanently": 301, - "Found": 302, - "See Other": 303, - "Not Modified": 304, - "Use Proxy": 305, - "Switch proxy": 306, - "Temporary Redirect": 307, - "Permanent Redirect": 308, - "Bad Request": 400, - "Unauthorized": 401, - "Payment Required": 402, - "Forbidden": 403, - "Not Found": 404, - "Method Not Allowed": 405, - "Not Acceptable": 406, - "Proxy Authentication Required": 407, - "Request Timeout": 408, - "Conflict": 409, - "Gone": 410, - "Length Required": 411, - "Precondition Failed": 412, - "Payload Too Large": 413, - "URI Too Long": 414, - "Unsupported Media Type": 415, - "Range Not Satisfiable": 416, - "Expectation Failed": 417, - "I'm a Teapot": 418, - "Misdirected Request": 421, - "Unprocessable Entity": 422, - "Locked": 423, - "Failed Dependency": 424, - "Upgrade Required": 426, - "Precondition Required": 428, - "Too Many Requests": 429, - "Request Header Fields Too Large": 431, - "Login Time-out": 440, - "No Response": 444, - "Retry With": 449, - "Blocked by Windows Parental Controls": 450, - "Unavailable For Legal Reasons": 451, - "Request Header Too Large": 494, - "Cert Error": 495, - "No Cert": 496, - "HTTP to HTTPS": 497, - "Token expired/invalid": 498, - "Token required": 499, - "Internal Server Error": 500, - "Not Implemented": 501, - "Bad Gateway": 502, - "Service Unavailable": 503, - "Gateway Timeout": 504, - "HTTP Version Not Supported": 505, - "Variant Also Negotiates": 506, - "Insufficient Storage": 507, - "Loop Detected": 508, - "Bandwidth Limit Exceeded": 509, - "Not Extended": 510, - "Network Authentication Required": 511, - "Unknown Error (Microsoft / CloudFlare)": 520, - "Web Server Is Down (CloudFlare)": 521, - "Connection Timed Out (CloudFlare)": 522, - "Origin Is Unreachable (CloudFlare)": 523, - "A Timeout Occurred (CloudFlare)": 524, - "SSL Handshake Failed (CloudFlare)": 525, - "Invalid SSL Certificate (CloudFlare)": 526, - "Railgun Error (CloudFlare)": 527 -}; +export const statusTextToStatusCodeMap: Record = Object.keys( + HttpStatusTextByCode +) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusTextByCode[cur as never]]: HttpStatusCodeByCode[cur as never], + }), + {} + ); /** Key-value mapping of HTTP status texts and HTTP status descriptions. */ -export const statusTextToStatusDescriptionMap: Record = { - "Continue": "继续:服务器已经收到请求头,客户端应继续发送请求主体。", - "Switching Protocols": "切换协议:请求者已要求服务器切换协议,服务器确认它将进行切换。", - "Processing": "处理中:服务器已收到请求并正在处理,但尚无可用的响应。", - "OK": "成功:标准的成功 HTTP 请求响应。", - "Created": "已创建:请求已完成并且新资源已创建。", - "Accepted": "已接受:请求已被接受但尚未处理完毕。此代码不保证请求会成功处理。", - "Non-Authoritative Information": "非权威信息:服务器成功处理了请求,但返回的是来自另一来源的信息。", - "No Content": "无内容:服务器接受了请求,但没有返回任何内容。通常作为 DELETE 请求的响应。", - "Reset Content": "重置内容:类似于 204 无内容响应,但此响应要求请求者重置文档视图。", - "Partial Content": "部分内容:服务器仅提供了客户端通过 Range 头请求的部分内容。", - "Multi-Status": "多状态:后续的消息体是一个 XML 消息,可能包含多个响应代码,具体取决于有多少子请求被发出。", - "Already Reported": "已报告:DAV 绑定的成员已经在对此请求的先前回复中被枚举,不再重复包含。", - "IM Used": "IM 使用:服务器已完成资源的 GET 请求,并且响应表示对当前实例应用了一个或多个实例操作的结果。", - "Multiple Choices": "多重选择:客户端可以选择多个选项中的一个进行操作。", - "Moved Permanently": "永久移动:资源已被移动,所有后续请求应参考其新的 URI。", - "Found": "找到:HTTP 1.0 规范将此状态描述为“临时移动”,但流行的浏览器对此状态的响应类似于 303 的行为。资源可以通过参考返回的 URI 来获取。", - "See Other": "参见其他:资源可以通过使用 GET 方法来获取其他 URI。当在响应 POST、PUT 或 DELETE 请求时收到此状态码,通常可以认为服务器已成功处理请求并将客户端指向一个信息性端点。", - "Not Modified": "未修改:自 If-Modified-Since 或 If-Match 头中指定的版本以来,资源未被修改。响应主体中将不会返回资源。", - "Use Proxy": "使用代理:HTTP 1.1。资源只能通过代理访问,地址在响应中提供。", - "Switch proxy": "切换代理:在 HTTP 1.1 中已废弃。曾用于表示后续请求应使用指定的代理发送。", - "Temporary Redirect": "临时重定向:HTTP 1.1。请求应使用响应中提供的 URI 重新发送,但未来的请求仍应调用原始 URI。", - "Permanent Redirect": "永久重定向:请求和所有未来的请求应使用响应中提供的 URI 重新发送。", - "Bad Request": "错误请求:由于请求的语法不正确,无法满足请求。", - "Unauthorized": "未授权:请求者未被授权访问该资源。与 403 类似,但用于身份验证失败或未提供身份验证的情况。", - "Payment Required": "需要付款:保留以供将来使用。某些网络服务使用此状态码表示客户端发送的请求次数过多。", - "Forbidden": "禁止:请求格式正确,但服务器拒绝提供请求的资源。与 401 不同,身份验证不会改变服务器的响应。", - "Not Found": "未找到:找不到请求的资源。通常用于服务器上所有无效的 URI 请求。", - "Method Not Allowed": "方法不允许:资源请求使用了不允许的方法。例如,使用 POST 方法请求资源,但该资源仅支持 GET 方法。", - "Not Acceptable": "不可接受:资源有效,但无法以请求中 Accept 头字段指定的格式提供。", - "Proxy Authentication Required": "需要代理身份验证:在满足请求之前,需要对代理进行身份验证。", - "Request Timeout": "请求超时:服务器等待客户端的请求超时。允许客户端重新发送请求。", - "Conflict": "冲突:由于请求参数中的冲突,无法完成请求。", - "Gone": "已删除:请求的资源在请求的 URI 不再可用,且不会提供重定向。", - "Length Required": "需要内容长度:请求未指定资源所需的内容长度。", - "Precondition Failed": "前提条件失败:服务器不满足客户端指定的一个前提条件。", - "Payload Too Large": "请求实体过大:请求的内容比服务器能够处理的要大。", - "URI Too Long": "请求 URI 过长:请求中提供的 URI 过长,服务器无法处理。通常在 GET 请求的 URI 中编码了过多数据时会使用此状态码,此时应改用 POST 请求。", - "Unsupported Media Type": "不支持的媒体类型:客户端提供的数据类型不受服务器支持。", - "Range Not Satisfiable": "请求的范围无法满足:客户端请求了资源的一部分,但服务器无法提供该部分。", - "Expectation Failed": "期望失败:服务器无法满足 Expect 请求头字段的要求。", - "I'm a Teapot": "我是茶壶:任何尝试用茶壶煮咖啡的行为都应该导致错误代码 \"418 我是茶壶\"。生成的实体内容可能会又短又粗。", - "Misdirected Request": "请求错误定向:请求被定向到无法提供响应的服务器。该状态码可以由未配置为响应请求 URI 中包含的方案和授权组合的服务器发送。", - "Unprocessable Entity": "无法处理的实体:请求格式正确,但在当前表单中无法处理。通常在指定的参数未通过验证错误时使用。", - "Locked": "已锁定:请求的资源已找到,但由于其被锁定而无法访问。", - "Failed Dependency": "依赖失败:由于前一个请求失败,导致当前请求也失败。", - "Upgrade Required": "需要升级:客户端应切换到升级后的协议(如 TLS/1.0),然后再发送请求。", - "Precondition Required": "需要前提条件:源服务器要求请求是有条件的。", - "Too Many Requests": "请求过多:用户在给定的时间内发送了过多的请求(\"速率限制\")。", - "Request Header Fields Too Large": "请求头字段过大:服务器不愿意处理请求,因为其头字段过大。", - "Login Time-out": "登录超时:Microsoft 扩展。表示由于用户登录超时而导致的失败。", - "No Response": "无响应:Nginx 内部状态码,用于指示服务器未返回任何信息并关闭连接。", - "Retry With": "重试:Microsoft 扩展。用于指示客户端应在执行适当操作后重新发送请求。", - "Blocked by Windows Parental Controls": "被 Windows 家长控制阻止:Microsoft 扩展。当 Windows 家长控制阻止访问特定网页时出现。", - "Unavailable For Legal Reasons": "因法律原因不可用:服务器由于接到法律约束请求而无法操作。", - "Request Header Too Large": "请求头字段过大:Nginx 内部代码,类似于 431,但在更早版本中实现。", - "Cert Error": "证书错误:Nginx 内部代码,用于 SSL 客户端证书错误,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。", - "No Cert": "无证书:Nginx 内部代码,当客户端未提供证书时使用,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。", - "HTTP to HTTPS": "HTTP 到 HTTPS:Nginx 内部代码,用于发送到 HTTPS 端口的纯 HTTP 请求,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。", - "Token expired/invalid": "令牌过期/无效:由 ArcGIS for Server 返回。代码 498 表示令牌已过期或无效。", - "Token required": "需要令牌:由 ArcGIS for Server 返回。代码 499 表示需要令牌(如果未提交令牌)。", - "Internal Server Error": "服务器内部错误:服务器自身的通用错误状态。", - "Not Implemented": "未实现:服务器无法响应请求,通常表示服务器可能在未来支持此请求,否则使用 4xx 状态码可能更为适当。", - "Bad Gateway": "错误网关:服务器作为代理时,从上游服务器接收到的响应无效。", - "Service Unavailable": "服务不可用:服务器停机,不接受请求。", - "Gateway Timeout": "网关超时:服务器作为代理时,从上游服务器未能及时接收到响应。", - "HTTP Version Not Supported": "不支持的 HTTP 版本:服务器不支持请求中所用的 HTTP 协议版本。", - "Variant Also Negotiates": "变体也在协商:请求的透明内容协商导致循环引用。", - "Insufficient Storage": "存储空间不足:用户或服务器没有足够的存储配额来完成请求。", - "Loop Detected": "检测到循环:服务器在请求中检测到无限循环。", - "Bandwidth Limit Exceeded": "超出带宽限制(Apache bw/limited 扩展):此状态码未在任何 RFC 中规定,其使用方式未知。", - "Not Extended": "未扩展:需要进一步扩展请求才能完成。", - "Network Authentication Required": "需要网络认证:客户端必须先通过网络认证,才能发送请求。", - "Unknown Error (Microsoft / CloudFlare)": "未知错误(Microsoft / CloudFlare):此状态码未在任何 RFC 中规定,由某些服务返回,如 Microsoft Azure 和 CloudFlare 服务器:520 错误本质上是对源服务器返回意外响应或不可解释/不允许(协议违规或空响应)的 \"兜底\" 响应。", - "Web Server Is Down (CloudFlare)": "Web 服务器宕机(CloudFlare):源服务器拒绝了来自 CloudFlare 的连接。", - "Connection Timed Out (CloudFlare)": "连接超时(CloudFlare):CloudFlare 无法与源服务器完成 TCP 握手。", - "Origin Is Unreachable (CloudFlare)": "源不可达(CloudFlare):CloudFlare 无法到达源服务器;例如,源服务器的 DNS 记录不正确。", - "A Timeout Occurred (CloudFlare)": "发生超时(CloudFlare):CloudFlare 能够与源服务器建立 TCP 连接,但未能及时收到 HTTP 响应。", - "SSL Handshake Failed (CloudFlare)": "SSL 握手失败(CloudFlare):CloudFlare 无法与源服务器完成 SSL/TLS 握手。", - "Invalid SSL Certificate (CloudFlare)": "无效的 SSL 证书(CloudFlare):CloudFlare 无法验证源服务器提供的 SSL/TLS 证书。", - "Railgun Error (CloudFlare)": "Railgun 错误(CloudFlare):在建立 WAN 连接后,请求超时或失败。" -}; +export const statusTextToStatusDescriptionMap: Record = Object.keys( + HttpStatusTextByCode +) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusTextByCode[cur as never]]: HttpStatusDescriptionByCode[cur as never], + }), + {} + ); -export type HTTPStatusCode = keyof typeof statusCodeToStatusTextMap; -export type HTTPStatusText = keyof typeof statusTextToStatusCodeMap; export type StatusInfo = { code: number, message: string, success: boolean }; /** @@ -356,10 +74,10 @@ export type StatusInfo = { code: number, message: string, success: boolean }; * @example isCodeOrTextValid(200) -> true * isCodeOrTextValid('OK') -> true * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns yesOrNo: boolean */ -export function isCodeOrTextValid(codeOrText: HTTPStatusCode | HTTPStatusText): boolean { +export function isCodeOrTextValid(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): boolean { return codeOrText in statusCodeToStatusTextMap || codeOrText in statusTextToStatusCodeMap; } @@ -368,10 +86,10 @@ export function isCodeOrTextValid(codeOrText: HTTPStatusCode | HTTPStatusText): * @example getStatusInfo(200) -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} * getStatusInfo('OK') -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns StatusInfo: { code: number, message: string, success: boolean} */ -export function getStatusInfo(codeOrText: HTTPStatusCode | HTTPStatusText): StatusInfo { +export function getStatusInfo(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): StatusInfo { if (!isCodeOrTextValid(codeOrText)) { throw new Error(`${codeOrText} is not a known HTTP status code or status text.`); @@ -396,10 +114,10 @@ export function getStatusInfo(codeOrText: HTTPStatusCode | HTTPStatusText): Stat * isStatusSuccessful(400) -> false * isStatusSuccessful('Bad request') -> false * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns successful: boolean */ -export function isStatusSuccessful(codeOrText: HTTPStatusCode | HTTPStatusText): boolean { +export function isStatusSuccessful(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): boolean { try { return getStatusInfo(codeOrText).success; @@ -413,10 +131,10 @@ export function isStatusSuccessful(codeOrText: HTTPStatusCode | HTTPStatusText): * @example getSimpleStatusMessage(200) -> 200 OK * getSimpleStatusMessage('OK') -> 200 OK * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns simpleStatusMessage: string */ -export function getSimpleStatusMessage(codeOrText: HTTPStatusCode | HTTPStatusText): string { +export function getSimpleStatusMessage(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): string { const statusInfo = getStatusInfo(codeOrText) return `${statusInfo.code} ${statusInfo.message.split(':')[0]}`; @@ -427,10 +145,10 @@ export function getSimpleStatusMessage(codeOrText: HTTPStatusCode | HTTPStatusTe * @example getStatusMessage(200) -> 200 OK:The standard response for successful HTTP requests. * getStatusMessage('OK') -> 200 OK:The standard response for successful HTTP requests. * - * @param codeOrText: HTTPStatusCode | HTTPStatusText + * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns statusMessage: string */ -export function getStatusMessage(codeOrText: HTTPStatusCode | HTTPStatusText): string { +export function getStatusMessage(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): string { const statusInfo = getStatusInfo(codeOrText) return `${statusInfo.code} ${statusInfo.message}`; @@ -440,10 +158,10 @@ export function getStatusMessage(codeOrText: HTTPStatusCode | HTTPStatusText): s * Returns the status code for the given http status text. * If the given http status text does not exist, undefined is returned. * @example getStatusCode('OK') -> 200 - * @param text: HTTPStatusText - * @returns statusCode: HTTPStatusCode + * @param text: HttpStatusText + * @returns statusCode: HttpStatusCode */ -export function getStatusCode(text: HTTPStatusText): HTTPStatusCode { +export function getStatusCode(text: HttpStatusText): HttpStatusCode { const code = statusTextToStatusCodeMap[`${text}`] if (!code) { throw new Error(`${text} is not a known HTTP status text.`); @@ -455,10 +173,10 @@ export function getStatusCode(text: HTTPStatusText): HTTPStatusCode { * Returns the status text for the given http status code. * If the given http status code does not exist, undefined is returned. * @example getStatusCode('200') -> OK - * @param code: HTTPStatusCode - * @returns statusText: HTTPStatusText + * @param code: HttpStatusCode + * @returns statusText: HttpStatusText */ -export function getStatusText(code: HTTPStatusCode): HTTPStatusText { +export function getStatusText(code: HttpStatusCode): string { const text = statusCodeToStatusTextMap[`${code}`] if (!text) { throw new Error(`${code} is not a known HTTP status code.`); diff --git a/packages/i18n-zh/src/lib/status-code.ts b/packages/i18n-zh/src/lib/status-code.ts index 59c1b5c..7bd0604 100644 --- a/packages/i18n-zh/src/lib/status-code.ts +++ b/packages/i18n-zh/src/lib/status-code.ts @@ -496,3 +496,486 @@ export enum HttpStatusCode { */ RAILGUN_ERROR_CLOUD_FLARE = 527 } + +export enum HttpStatusCodeByCode { + /** + * h100: RFC 7231 6.2.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.1 + * 继续:服务器已经收到请求头,客户端应继续发送请求主体。 + */ + h100 = 100, + /** + * h101: RFC 7231 6.2.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.2 + * 切换协议:请求者已要求服务器切换协议,服务器确认它将进行切换。 + */ + h101 = 101, + /** + * h102: RFC 2518 10.1 (已被 RFC 4918 废弃) + * https://datatracker.ietf.org/doc/html/rfc2518#section-10.1 + * 处理中:服务器已收到请求并正在处理,但尚无可用的响应。 + */ + h102 = 102, + /** + * h200: RFC 7231 6.3.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1 + * 成功:标准的成功 HTTP 请求响应。 + */ + h200 = 200, + /** + * h201: RFC 7231 6.3.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2 + * 已创建:请求已完成并且新资源已创建。 + */ + h201 = 201, + /** + * h202: RFC 7231 6.3.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3 + * 已接受:请求已被接受但尚未处理完毕。此代码不保证请求会成功处理。 + */ + h202 = 202, + /** + * h203: RFC 7231 6.3.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.4 + * 非权威信息:服务器成功处理了请求,但返回的是来自另一来源的信息。 + */ + h203 = 203, + /** + * h204: RFC 7231 6.3.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5 + * 无内容:服务器接受了请求,但没有返回任何内容。通常作为 DELETE 请求的响应。 + */ + h204 = 204, + /** + * h205: RFC 7231 6.3.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 + * 重置内容:类似于 204 无内容响应,但此响应要求请求者重置文档视图。 + */ + h205 = 205, + /** + * h206: RFC 7233 4.1 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.1 + * 部分内容:服务器仅提供了客户端通过 Range 头请求的部分内容。 + */ + h206 = 206, + /** + * h207: RFC 4918 11.1 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.1 + * 多状态:后续的消息体是一个 XML 消息,可能包含多个响应代码,具体取决于有多少子请求被发出。 + */ + h207 = 207, + /** + * h208: RFC 5842 7.1 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.1 + * 已报告:DAV 绑定的成员已经在对此请求的先前回复中被枚举,不再重复包含。 + */ + h208 = 208, + /** + * h226: RFC 3229 10.4.1 + * https://datatracker.ietf.org/doc/html/rfc3229#section-10.4.1 + * IM 使用:服务器已完成资源的 GET 请求,并且响应表示对当前实例应用了一个或多个实例操作的结果。 + */ + h226 = 226, + /** + * h300: RFC 7231 6.4.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.1 + * 多重选择:客户端可以选择多个选项中的一个进行操作。 + */ + h300 = 300, + /** + * h301: RFC 7231 6.4.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2 + * 永久移动:资源已被移动,所有后续请求应参考其新的 URI。 + */ + h301 = 301, + /** + * h302: RFC 7231 6.4.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3 + * 找到:HTTP 1.0 规范将此状态描述为“临时移动”,但流行的浏览器对此状态的响应类似于 303 的行为。资源可以通过参考返回的 URI 来获取。 + */ + h302 = 302, + /** + * h303: RFC 7231 6.4.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4 + * 参见其他:资源可以通过使用 GET 方法来获取其他 URI。当在响应 POST、PUT 或 DELETE 请求时收到此状态码,通常可以认为服务器已成功处理请求并将客户端指向一个信息性端点。 + */ + h303 = 303, + /** + * h304: RFC 7232 4.1 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 + * 未修改:自 If-Modified-Since 或 If-Match 头中指定的版本以来,资源未被修改。响应主体中将不会返回资源。 + */ + h304 = 304, + /** + * h305: RFC 7231 6.4.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.5 + * 使用代理:HTTP 1.1。资源只能通过代理访问,地址在响应中提供。 + */ + h305 = 305, + /** + * h306: + * + * 切换代理:在 HTTP 1.1 中已废弃。曾用于表示后续请求应使用指定的代理发送。 + */ + h306 = 306, + /** + * h307: RFC 7231 6.4.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 + * 临时重定向:HTTP 1.1。请求应使用响应中提供的 URI 重新发送,但未来的请求仍应调用原始 URI。 + */ + h307 = 307, + /** + * h308: RFC 7538 3 + * https://datatracker.ietf.org/doc/html/rfc7538#section-3 + * 永久重定向:请求和所有未来的请求应使用响应中提供的 URI 重新发送。 + */ + h308 = 308, + /** + * h400: RFC 7231 6.5.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1 + * 错误请求:由于请求的语法不正确,无法满足请求。 + */ + h400 = 400, + /** + * h401: RFC 7235 3.1 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 + * 未授权:请求者未被授权访问该资源。与 403 类似,但用于身份验证失败或未提供身份验证的情况。 + */ + h401 = 401, + /** + * h402: RFC 7231 6.5.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2 + * 需要付款:保留以供将来使用。某些网络服务使用此状态码表示客户端发送的请求次数过多。 + */ + h402 = 402, + /** + * h403: RFC 7231 6.5.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3 + * 禁止:请求格式正确,但服务器拒绝提供请求的资源。与 401 不同,身份验证不会改变服务器的响应。 + */ + h403 = 403, + /** + * h404: RFC 7231 6.5.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 + * 未找到:找不到请求的资源。通常用于服务器上所有无效的 URI 请求。 + */ + h404 = 404, + /** + * h405: RFC 7231 6.5.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5 + * 方法不允许:资源请求使用了不允许的方法。例如,使用 POST 方法请求资源,但该资源仅支持 GET 方法。 + */ + h405 = 405, + /** + * h406: RFC 7231 6.5.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.6 + * 不可接受:资源有效,但无法以请求中 Accept 头字段指定的格式提供。 + */ + h406 = 406, + /** + * h407: RFC 7235 3.2 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.2 + * 需要代理身份验证:在满足请求之前,需要对代理进行身份验证。 + */ + h407 = 407, + /** + * h408: RFC 7231 6.5.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.7 + * 请求超时:服务器等待客户端的请求超时。允许客户端重新发送请求。 + */ + h408 = 408, + /** + * h409: RFC 7231 6.5.8 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8 + * 冲突:由于请求参数中的冲突,无法完成请求。 + */ + h409 = 409, + /** + * h410: RFC 7231 6.5.9 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.9 + * 已删除:请求的资源在请求的 URI 不再可用,且不会提供重定向。 + */ + h410 = 410, + /** + * h411: RFC 7231 6.5.10 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.10 + * 需要内容长度:请求未指定资源所需的内容长度。 + */ + h411 = 411, + /** + * h412: RFC 7232 4.2 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.2 + * 前提条件失败:服务器不满足客户端指定的一个前提条件。 + */ + h412 = 412, + /** + * h413: RFC 7231 6.5.11 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.11 + * 请求实体过大:请求的内容比服务器能够处理的要大。 + */ + h413 = 413, + /** + * h414: RFC 7231 6.5.12 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.12 + * 请求 URI 过长:请求中提供的 URI 过长,服务器无法处理。通常在 GET 请求的 URI 中编码了过多数据时会使用此状态码,此时应改用 POST 请求。 + */ + h414 = 414, + /** + * h415: RFC 7231 6.5.13 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.13 + * 不支持的媒体类型:客户端提供的数据类型不受服务器支持。 + */ + h415 = 415, + /** + * h416: RFC 7233 4.4 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.4 + * 请求的范围无法满足:客户端请求了资源的一部分,但服务器无法提供该部分。 + */ + h416 = 416, + /** + * h417: RFC 7231 6.5.14 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.14 + * 期望失败:服务器无法满足 Expect 请求头字段的要求。 + */ + h417 = 417, + /** + * h418: + * Empty + * 我是茶壶:任何尝试用茶壶煮咖啡的行为都应该导致错误代码 "418 我是茶壶"。生成的实体内容可能会又短又粗。 + */ + h418 = 418, + /** + * h421: RFC 7540 9.1.2 + * https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2 + * 请求错误定向:请求被定向到无法提供响应的服务器。该状态码可以由未配置为响应请求 URI 中包含的方案和授权组合的服务器发送。 + */ + h421 = 421, + /** + * h422: RFC 4918 11.2 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.2 + * 无法处理的实体:请求格式正确,但在当前表单中无法处理。通常在指定的参数未通过验证错误时使用。 + */ + h422 = 422, + /** + * h423: RFC 4918 11.3 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.3 + * 已锁定:请求的资源已找到,但由于其被锁定而无法访问。 + */ + h423 = 423, + /** + * h424: RFC 4918 11.4 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.4 + * 依赖失败:由于前一个请求失败,导致当前请求也失败。 + */ + h424 = 424, + /** + * h426: RFC 2817 and RFC 7231 6.5.15 + * https://datatracker.ietf.org/doc/html/rfc2817 and https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.15 + * 需要升级:客户端应切换到升级后的协议(如 TLS/1.0),然后再发送请求。 + */ + h426 = 426, + /** + * h428: RFC 6585 3 + * https://datatracker.ietf.org/doc/html/rfc6585#section-3 + * 需要前提条件:源服务器要求请求是有条件的。 + */ + h428 = 428, + /** + * h429: RFC 6585 4 + * https://datatracker.ietf.org/doc/html/rfc6585#section-4 + * 请求过多:用户在给定的时间内发送了过多的请求("速率限制")。 + */ + h429 = 429, + /** + * h431: RFC 6585 5 + * https://datatracker.ietf.org/doc/html/rfc6585#section-5 + * 请求头字段过大:服务器不愿意处理请求,因为其头字段过大。 + */ + h431 = 431, + /** + * h440: + * Empty + * 登录超时:Microsoft 扩展。表示由于用户登录超时而导致的失败。 + */ + h440 = 440, + /** + * h444: + * Empty + * 无响应:Nginx 内部状态码,用于指示服务器未返回任何信息并关闭连接。 + */ + h444 = 444, + /** + * h449: + * Empty + * 重试:Microsoft 扩展。用于指示客户端应在执行适当操作后重新发送请求。 + */ + h449 = 449, + /** + * h450: + * Empty + * 被 Windows 家长控制阻止:Microsoft 扩展。当 Windows 家长控制阻止访问特定网页时出现。 + */ + h450 = 450, + /** + * h451: RFC 7725 + * https://datatracker.ietf.org/doc/html/rfc7725 + * 因法律原因不可用:服务器由于接到法律约束请求而无法操作。 + */ + h451 = 451, + /** + * h494: + * Empty + * 请求头字段过大:Nginx 内部代码,类似于 431,但在更早版本中实现。 + */ + h494 = 494, + /** + * h495: + * Empty + * 证书错误:Nginx 内部代码,用于 SSL 客户端证书错误,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h495 = 495, + /** + * h496: + * Empty + * 无证书:Nginx 内部代码,当客户端未提供证书时使用,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h496 = 496, + /** + * h497: + * Empty + * HTTP 到 HTTPS:Nginx 内部代码,用于发送到 HTTPS 端口的纯 HTTP 请求,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h497 = 497, + /** + * h498: + * Empty + * 令牌过期/无效:由 ArcGIS for Server 返回。代码 498 表示令牌已过期或无效。 + */ + h498 = 498, + /** + * h499: + * Empty + * 需要令牌:由 ArcGIS for Server 返回。代码 499 表示需要令牌(如果未提交令牌)。 + */ + h499 = 499, + /** + * h500: RFC 7231 6.6.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1 + * 服务器内部错误:服务器自身的通用错误状态。 + */ + h500 = 500, + /** + * h501: RFC 7231 6.6.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2 + * 未实现:服务器无法响应请求,通常表示服务器可能在未来支持此请求,否则使用 4xx 状态码可能更为适当。 + */ + h501 = 501, + /** + * h502: RFC 7231 6.6.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3 + * 错误网关:服务器作为代理时,从上游服务器接收到的响应无效。 + */ + h502 = 502, + /** + * h503: RFC 7231 6.6.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4 + * 服务不可用:服务器停机,不接受请求。 + */ + h503 = 503, + /** + * h504: RFC 7231 6.6.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5 + * 网关超时:服务器作为代理时,从上游服务器未能及时接收到响应。 + */ + h504 = 504, + /** + * h505: RFC 7231 6.6.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.6 + * 不支持的 HTTP 版本:服务器不支持请求中所用的 HTTP 协议版本。 + */ + h505 = 505, + /** + * h506: RFC 2295 8.1 + * https://datatracker.ietf.org/doc/html/rfc2295#section-8.1 + * 变体也在协商:请求的透明内容协商导致循环引用。 + */ + h506 = 506, + /** + * h507: RFC 4918 11.5 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.5 + * 存储空间不足:用户或服务器没有足够的存储配额来完成请求。 + */ + h507 = 507, + /** + * h508: RFC 5842 7.2 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.2 + * 检测到循环:服务器在请求中检测到无限循环。 + */ + h508 = 508, + /** + * h509: + * Empty + * 超出带宽限制(Apache bw/limited 扩展):此状态码未在任何 RFC 中规定,其使用方式未知。 + */ + h509 = 509, + /** + * h510: RFC 2774 7 + * https://datatracker.ietf.org/doc/html/rfc2774#section-7 + * 未扩展:需要进一步扩展请求才能完成。 + */ + h510 = 510, + /** + * h511: RFC 6585 6 + * https://datatracker.ietf.org/doc/html/rfc6585#section-6 + * 需要网络认证:客户端必须先通过网络认证,才能发送请求。 + */ + h511 = 511, + /** + * h520: + * Empty + * 未知错误(Microsoft / CloudFlare):此状态码未在任何 RFC 中规定,由某些服务返回,如 Microsoft Azure 和 CloudFlare 服务器:520 错误本质上是对源服务器返回意外响应或不可解释/不允许(协议违规或空响应)的 "兜底" 响应。 + */ + h520 = 520, + /** + * h521: + * Empty + * Web 服务器宕机(CloudFlare):源服务器拒绝了来自 CloudFlare 的连接。 + */ + h521 = 521, + /** + * h522: + * Empty + * 连接超时(CloudFlare):CloudFlare 无法与源服务器完成 TCP 握手。 + */ + h522 = 522, + /** + * h523: + * Empty + * 源不可达(CloudFlare):CloudFlare 无法到达源服务器;例如,源服务器的 DNS 记录不正确。 + */ + h523 = 523, + /** + * h524: + * Empty + * 发生超时(CloudFlare):CloudFlare 能够与源服务器建立 TCP 连接,但未能及时收到 HTTP 响应。 + */ + h524 = 524, + /** + * h525: + * Empty + * SSL 握手失败(CloudFlare):CloudFlare 无法与源服务器完成 SSL/TLS 握手。 + */ + h525 = 525, + /** + * h526: + * Empty + * 无效的 SSL 证书(CloudFlare):CloudFlare 无法验证源服务器提供的 SSL/TLS 证书。 + */ + h526 = 526, + /** + * h527: + * Empty + * Railgun 错误(CloudFlare):在建立 WAN 连接后,请求超时或失败。 + */ + h527 = 527 +} diff --git a/packages/i18n-zh/src/lib/status-description.ts b/packages/i18n-zh/src/lib/status-description.ts index fdd0c4f..7b427cb 100644 --- a/packages/i18n-zh/src/lib/status-description.ts +++ b/packages/i18n-zh/src/lib/status-description.ts @@ -496,3 +496,486 @@ export enum HttpStatusDescription { */ RAILGUN_ERROR_CLOUD_FLARE = 'Railgun 错误(CloudFlare):在建立 WAN 连接后,请求超时或失败。' } + +export enum HttpStatusDescriptionByCode { + /** + * h100: RFC 7231 6.2.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.1 + * 继续:服务器已经收到请求头,客户端应继续发送请求主体。 + */ + h100 = '继续:服务器已经收到请求头,客户端应继续发送请求主体。', + /** + * h101: RFC 7231 6.2.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.2 + * 切换协议:请求者已要求服务器切换协议,服务器确认它将进行切换。 + */ + h101 = '切换协议:请求者已要求服务器切换协议,服务器确认它将进行切换。', + /** + * h102: RFC 2518 10.1 (已被 RFC 4918 废弃) + * https://datatracker.ietf.org/doc/html/rfc2518#section-10.1 + * 处理中:服务器已收到请求并正在处理,但尚无可用的响应。 + */ + h102 = '处理中:服务器已收到请求并正在处理,但尚无可用的响应。', + /** + * h200: RFC 7231 6.3.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1 + * 成功:标准的成功 HTTP 请求响应。 + */ + h200 = '成功:标准的成功 HTTP 请求响应。', + /** + * h201: RFC 7231 6.3.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2 + * 已创建:请求已完成并且新资源已创建。 + */ + h201 = '已创建:请求已完成并且新资源已创建。', + /** + * h202: RFC 7231 6.3.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3 + * 已接受:请求已被接受但尚未处理完毕。此代码不保证请求会成功处理。 + */ + h202 = '已接受:请求已被接受但尚未处理完毕。此代码不保证请求会成功处理。', + /** + * h203: RFC 7231 6.3.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.4 + * 非权威信息:服务器成功处理了请求,但返回的是来自另一来源的信息。 + */ + h203 = '非权威信息:服务器成功处理了请求,但返回的是来自另一来源的信息。', + /** + * h204: RFC 7231 6.3.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5 + * 无内容:服务器接受了请求,但没有返回任何内容。通常作为 DELETE 请求的响应。 + */ + h204 = '无内容:服务器接受了请求,但没有返回任何内容。通常作为 DELETE 请求的响应。', + /** + * h205: RFC 7231 6.3.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 + * 重置内容:类似于 204 无内容响应,但此响应要求请求者重置文档视图。 + */ + h205 = '重置内容:类似于 204 无内容响应,但此响应要求请求者重置文档视图。', + /** + * h206: RFC 7233 4.1 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.1 + * 部分内容:服务器仅提供了客户端通过 Range 头请求的部分内容。 + */ + h206 = '部分内容:服务器仅提供了客户端通过 Range 头请求的部分内容。', + /** + * h207: RFC 4918 11.1 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.1 + * 多状态:后续的消息体是一个 XML 消息,可能包含多个响应代码,具体取决于有多少子请求被发出。 + */ + h207 = '多状态:后续的消息体是一个 XML 消息,可能包含多个响应代码,具体取决于有多少子请求被发出。', + /** + * h208: RFC 5842 7.1 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.1 + * 已报告:DAV 绑定的成员已经在对此请求的先前回复中被枚举,不再重复包含。 + */ + h208 = '已报告:DAV 绑定的成员已经在对此请求的先前回复中被枚举,不再重复包含。', + /** + * h226: RFC 3229 10.4.1 + * https://datatracker.ietf.org/doc/html/rfc3229#section-10.4.1 + * IM 使用:服务器已完成资源的 GET 请求,并且响应表示对当前实例应用了一个或多个实例操作的结果。 + */ + h226 = 'IM 使用:服务器已完成资源的 GET 请求,并且响应表示对当前实例应用了一个或多个实例操作的结果。', + /** + * h300: RFC 7231 6.4.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.1 + * 多重选择:客户端可以选择多个选项中的一个进行操作。 + */ + h300 = '多重选择:客户端可以选择多个选项中的一个进行操作。', + /** + * h301: RFC 7231 6.4.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2 + * 永久移动:资源已被移动,所有后续请求应参考其新的 URI。 + */ + h301 = '永久移动:资源已被移动,所有后续请求应参考其新的 URI。', + /** + * h302: RFC 7231 6.4.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3 + * 找到:HTTP 1.0 规范将此状态描述为“临时移动”,但流行的浏览器对此状态的响应类似于 303 的行为。资源可以通过参考返回的 URI 来获取。 + */ + h302 = '找到:HTTP 1.0 规范将此状态描述为“临时移动”,但流行的浏览器对此状态的响应类似于 303 的行为。资源可以通过参考返回的 URI 来获取。', + /** + * h303: RFC 7231 6.4.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4 + * 参见其他:资源可以通过使用 GET 方法来获取其他 URI。当在响应 POST、PUT 或 DELETE 请求时收到此状态码,通常可以认为服务器已成功处理请求并将客户端指向一个信息性端点。 + */ + h303 = '参见其他:资源可以通过使用 GET 方法来获取其他 URI。当在响应 POST、PUT 或 DELETE 请求时收到此状态码,通常可以认为服务器已成功处理请求并将客户端指向一个信息性端点。', + /** + * h304: RFC 7232 4.1 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 + * 未修改:自 If-Modified-Since 或 If-Match 头中指定的版本以来,资源未被修改。响应主体中将不会返回资源。 + */ + h304 = '未修改:自 If-Modified-Since 或 If-Match 头中指定的版本以来,资源未被修改。响应主体中将不会返回资源。', + /** + * h305: RFC 7231 6.4.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.5 + * 使用代理:HTTP 1.1。资源只能通过代理访问,地址在响应中提供。 + */ + h305 = '使用代理:HTTP 1.1。资源只能通过代理访问,地址在响应中提供。', + /** + * h306: + * + * 切换代理:在 HTTP 1.1 中已废弃。曾用于表示后续请求应使用指定的代理发送。 + */ + h306 = '切换代理:在 HTTP 1.1 中已废弃。曾用于表示后续请求应使用指定的代理发送。', + /** + * h307: RFC 7231 6.4.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 + * 临时重定向:HTTP 1.1。请求应使用响应中提供的 URI 重新发送,但未来的请求仍应调用原始 URI。 + */ + h307 = '临时重定向:HTTP 1.1。请求应使用响应中提供的 URI 重新发送,但未来的请求仍应调用原始 URI。', + /** + * h308: RFC 7538 3 + * https://datatracker.ietf.org/doc/html/rfc7538#section-3 + * 永久重定向:请求和所有未来的请求应使用响应中提供的 URI 重新发送。 + */ + h308 = '永久重定向:请求和所有未来的请求应使用响应中提供的 URI 重新发送。', + /** + * h400: RFC 7231 6.5.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1 + * 错误请求:由于请求的语法不正确,无法满足请求。 + */ + h400 = '错误请求:由于请求的语法不正确,无法满足请求。', + /** + * h401: RFC 7235 3.1 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 + * 未授权:请求者未被授权访问该资源。与 403 类似,但用于身份验证失败或未提供身份验证的情况。 + */ + h401 = '未授权:请求者未被授权访问该资源。与 403 类似,但用于身份验证失败或未提供身份验证的情况。', + /** + * h402: RFC 7231 6.5.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2 + * 需要付款:保留以供将来使用。某些网络服务使用此状态码表示客户端发送的请求次数过多。 + */ + h402 = '需要付款:保留以供将来使用。某些网络服务使用此状态码表示客户端发送的请求次数过多。', + /** + * h403: RFC 7231 6.5.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3 + * 禁止:请求格式正确,但服务器拒绝提供请求的资源。与 401 不同,身份验证不会改变服务器的响应。 + */ + h403 = '禁止:请求格式正确,但服务器拒绝提供请求的资源。与 401 不同,身份验证不会改变服务器的响应。', + /** + * h404: RFC 7231 6.5.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 + * 未找到:找不到请求的资源。通常用于服务器上所有无效的 URI 请求。 + */ + h404 = '未找到:找不到请求的资源。通常用于服务器上所有无效的 URI 请求。', + /** + * h405: RFC 7231 6.5.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5 + * 方法不允许:资源请求使用了不允许的方法。例如,使用 POST 方法请求资源,但该资源仅支持 GET 方法。 + */ + h405 = '方法不允许:资源请求使用了不允许的方法。例如,使用 POST 方法请求资源,但该资源仅支持 GET 方法。', + /** + * h406: RFC 7231 6.5.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.6 + * 不可接受:资源有效,但无法以请求中 Accept 头字段指定的格式提供。 + */ + h406 = '不可接受:资源有效,但无法以请求中 Accept 头字段指定的格式提供。', + /** + * h407: RFC 7235 3.2 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.2 + * 需要代理身份验证:在满足请求之前,需要对代理进行身份验证。 + */ + h407 = '需要代理身份验证:在满足请求之前,需要对代理进行身份验证。', + /** + * h408: RFC 7231 6.5.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.7 + * 请求超时:服务器等待客户端的请求超时。允许客户端重新发送请求。 + */ + h408 = '请求超时:服务器等待客户端的请求超时。允许客户端重新发送请求。', + /** + * h409: RFC 7231 6.5.8 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8 + * 冲突:由于请求参数中的冲突,无法完成请求。 + */ + h409 = '冲突:由于请求参数中的冲突,无法完成请求。', + /** + * h410: RFC 7231 6.5.9 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.9 + * 已删除:请求的资源在请求的 URI 不再可用,且不会提供重定向。 + */ + h410 = '已删除:请求的资源在请求的 URI 不再可用,且不会提供重定向。', + /** + * h411: RFC 7231 6.5.10 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.10 + * 需要内容长度:请求未指定资源所需的内容长度。 + */ + h411 = '需要内容长度:请求未指定资源所需的内容长度。', + /** + * h412: RFC 7232 4.2 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.2 + * 前提条件失败:服务器不满足客户端指定的一个前提条件。 + */ + h412 = '前提条件失败:服务器不满足客户端指定的一个前提条件。', + /** + * h413: RFC 7231 6.5.11 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.11 + * 请求实体过大:请求的内容比服务器能够处理的要大。 + */ + h413 = '请求实体过大:请求的内容比服务器能够处理的要大。', + /** + * h414: RFC 7231 6.5.12 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.12 + * 请求 URI 过长:请求中提供的 URI 过长,服务器无法处理。通常在 GET 请求的 URI 中编码了过多数据时会使用此状态码,此时应改用 POST 请求。 + */ + h414 = '请求 URI 过长:请求中提供的 URI 过长,服务器无法处理。通常在 GET 请求的 URI 中编码了过多数据时会使用此状态码,此时应改用 POST 请求。', + /** + * h415: RFC 7231 6.5.13 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.13 + * 不支持的媒体类型:客户端提供的数据类型不受服务器支持。 + */ + h415 = '不支持的媒体类型:客户端提供的数据类型不受服务器支持。', + /** + * h416: RFC 7233 4.4 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.4 + * 请求的范围无法满足:客户端请求了资源的一部分,但服务器无法提供该部分。 + */ + h416 = '请求的范围无法满足:客户端请求了资源的一部分,但服务器无法提供该部分。', + /** + * h417: RFC 7231 6.5.14 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.14 + * 期望失败:服务器无法满足 Expect 请求头字段的要求。 + */ + h417 = '期望失败:服务器无法满足 Expect 请求头字段的要求。', + /** + * h418: + * Empty + * 我是茶壶:任何尝试用茶壶煮咖啡的行为都应该导致错误代码 "418 我是茶壶"。生成的实体内容可能会又短又粗。 + */ + h418 = '我是茶壶:任何尝试用茶壶煮咖啡的行为都应该导致错误代码 "418 我是茶壶"。生成的实体内容可能会又短又粗。', + /** + * h421: RFC 7540 9.1.2 + * https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2 + * 请求错误定向:请求被定向到无法提供响应的服务器。该状态码可以由未配置为响应请求 URI 中包含的方案和授权组合的服务器发送。 + */ + h421 = '请求错误定向:请求被定向到无法提供响应的服务器。该状态码可以由未配置为响应请求 URI 中包含的方案和授权组合的服务器发送。', + /** + * h422: RFC 4918 11.2 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.2 + * 无法处理的实体:请求格式正确,但在当前表单中无法处理。通常在指定的参数未通过验证错误时使用。 + */ + h422 = '无法处理的实体:请求格式正确,但在当前表单中无法处理。通常在指定的参数未通过验证错误时使用。', + /** + * h423: RFC 4918 11.3 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.3 + * 已锁定:请求的资源已找到,但由于其被锁定而无法访问。 + */ + h423 = '已锁定:请求的资源已找到,但由于其被锁定而无法访问。', + /** + * h424: RFC 4918 11.4 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.4 + * 依赖失败:由于前一个请求失败,导致当前请求也失败。 + */ + h424 = '依赖失败:由于前一个请求失败,导致当前请求也失败。', + /** + * h426: RFC 2817 and RFC 7231 6.5.15 + * https://datatracker.ietf.org/doc/html/rfc2817 and https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.15 + * 需要升级:客户端应切换到升级后的协议(如 TLS/1.0),然后再发送请求。 + */ + h426 = '需要升级:客户端应切换到升级后的协议(如 TLS/1.0),然后再发送请求。', + /** + * h428: RFC 6585 3 + * https://datatracker.ietf.org/doc/html/rfc6585#section-3 + * 需要前提条件:源服务器要求请求是有条件的。 + */ + h428 = '需要前提条件:源服务器要求请求是有条件的。', + /** + * h429: RFC 6585 4 + * https://datatracker.ietf.org/doc/html/rfc6585#section-4 + * 请求过多:用户在给定的时间内发送了过多的请求("速率限制")。 + */ + h429 = '请求过多:用户在给定的时间内发送了过多的请求("速率限制")。', + /** + * h431: RFC 6585 5 + * https://datatracker.ietf.org/doc/html/rfc6585#section-5 + * 请求头字段过大:服务器不愿意处理请求,因为其头字段过大。 + */ + h431 = '请求头字段过大:服务器不愿意处理请求,因为其头字段过大。', + /** + * h440: + * Empty + * 登录超时:Microsoft 扩展。表示由于用户登录超时而导致的失败。 + */ + h440 = '登录超时:Microsoft 扩展。表示由于用户登录超时而导致的失败。', + /** + * h444: + * Empty + * 无响应:Nginx 内部状态码,用于指示服务器未返回任何信息并关闭连接。 + */ + h444 = '无响应:Nginx 内部状态码,用于指示服务器未返回任何信息并关闭连接。', + /** + * h449: + * Empty + * 重试:Microsoft 扩展。用于指示客户端应在执行适当操作后重新发送请求。 + */ + h449 = '重试:Microsoft 扩展。用于指示客户端应在执行适当操作后重新发送请求。', + /** + * h450: + * Empty + * 被 Windows 家长控制阻止:Microsoft 扩展。当 Windows 家长控制阻止访问特定网页时出现。 + */ + h450 = '被 Windows 家长控制阻止:Microsoft 扩展。当 Windows 家长控制阻止访问特定网页时出现。', + /** + * h451: RFC 7725 + * https://datatracker.ietf.org/doc/html/rfc7725 + * 因法律原因不可用:服务器由于接到法律约束请求而无法操作。 + */ + h451 = '因法律原因不可用:服务器由于接到法律约束请求而无法操作。', + /** + * h494: + * Empty + * 请求头字段过大:Nginx 内部代码,类似于 431,但在更早版本中实现。 + */ + h494 = '请求头字段过大:Nginx 内部代码,类似于 431,但在更早版本中实现。', + /** + * h495: + * Empty + * 证书错误:Nginx 内部代码,用于 SSL 客户端证书错误,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h495 = '证书错误:Nginx 内部代码,用于 SSL 客户端证书错误,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。', + /** + * h496: + * Empty + * 无证书:Nginx 内部代码,当客户端未提供证书时使用,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h496 = '无证书:Nginx 内部代码,当客户端未提供证书时使用,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。', + /** + * h497: + * Empty + * HTTP 到 HTTPS:Nginx 内部代码,用于发送到 HTTPS 端口的纯 HTTP 请求,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h497 = 'HTTP 到 HTTPS:Nginx 内部代码,用于发送到 HTTPS 端口的纯 HTTP 请求,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。', + /** + * h498: + * Empty + * 令牌过期/无效:由 ArcGIS for Server 返回。代码 498 表示令牌已过期或无效。 + */ + h498 = '令牌过期/无效:由 ArcGIS for Server 返回。代码 498 表示令牌已过期或无效。', + /** + * h499: + * Empty + * 需要令牌:由 ArcGIS for Server 返回。代码 499 表示需要令牌(如果未提交令牌)。 + */ + h499 = '需要令牌:由 ArcGIS for Server 返回。代码 499 表示需要令牌(如果未提交令牌)。', + /** + * h500: RFC 7231 6.6.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1 + * 服务器内部错误:服务器自身的通用错误状态。 + */ + h500 = '服务器内部错误:服务器自身的通用错误状态。', + /** + * h501: RFC 7231 6.6.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2 + * 未实现:服务器无法响应请求,通常表示服务器可能在未来支持此请求,否则使用 4xx 状态码可能更为适当。 + */ + h501 = '未实现:服务器无法响应请求,通常表示服务器可能在未来支持此请求,否则使用 4xx 状态码可能更为适当。', + /** + * h502: RFC 7231 6.6.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3 + * 错误网关:服务器作为代理时,从上游服务器接收到的响应无效。 + */ + h502 = '错误网关:服务器作为代理时,从上游服务器接收到的响应无效。', + /** + * h503: RFC 7231 6.6.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4 + * 服务不可用:服务器停机,不接受请求。 + */ + h503 = '服务不可用:服务器停机,不接受请求。', + /** + * h504: RFC 7231 6.6.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5 + * 网关超时:服务器作为代理时,从上游服务器未能及时接收到响应。 + */ + h504 = '网关超时:服务器作为代理时,从上游服务器未能及时接收到响应。', + /** + * h505: RFC 7231 6.6.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.6 + * 不支持的 HTTP 版本:服务器不支持请求中所用的 HTTP 协议版本。 + */ + h505 = '不支持的 HTTP 版本:服务器不支持请求中所用的 HTTP 协议版本。', + /** + * h506: RFC 2295 8.1 + * https://datatracker.ietf.org/doc/html/rfc2295#section-8.1 + * 变体也在协商:请求的透明内容协商导致循环引用。 + */ + h506 = '变体也在协商:请求的透明内容协商导致循环引用。', + /** + * h507: RFC 4918 11.5 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.5 + * 存储空间不足:用户或服务器没有足够的存储配额来完成请求。 + */ + h507 = '存储空间不足:用户或服务器没有足够的存储配额来完成请求。', + /** + * h508: RFC 5842 7.2 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.2 + * 检测到循环:服务器在请求中检测到无限循环。 + */ + h508 = '检测到循环:服务器在请求中检测到无限循环。', + /** + * h509: + * Empty + * 超出带宽限制(Apache bw/limited 扩展):此状态码未在任何 RFC 中规定,其使用方式未知。 + */ + h509 = '超出带宽限制(Apache bw/limited 扩展):此状态码未在任何 RFC 中规定,其使用方式未知。', + /** + * h510: RFC 2774 7 + * https://datatracker.ietf.org/doc/html/rfc2774#section-7 + * 未扩展:需要进一步扩展请求才能完成。 + */ + h510 = '未扩展:需要进一步扩展请求才能完成。', + /** + * h511: RFC 6585 6 + * https://datatracker.ietf.org/doc/html/rfc6585#section-6 + * 需要网络认证:客户端必须先通过网络认证,才能发送请求。 + */ + h511 = '需要网络认证:客户端必须先通过网络认证,才能发送请求。', + /** + * h520: + * Empty + * 未知错误(Microsoft / CloudFlare):此状态码未在任何 RFC 中规定,由某些服务返回,如 Microsoft Azure 和 CloudFlare 服务器:520 错误本质上是对源服务器返回意外响应或不可解释/不允许(协议违规或空响应)的 "兜底" 响应。 + */ + h520 = '未知错误(Microsoft / CloudFlare):此状态码未在任何 RFC 中规定,由某些服务返回,如 Microsoft Azure 和 CloudFlare 服务器:520 错误本质上是对源服务器返回意外响应或不可解释/不允许(协议违规或空响应)的 "兜底" 响应。', + /** + * h521: + * Empty + * Web 服务器宕机(CloudFlare):源服务器拒绝了来自 CloudFlare 的连接。 + */ + h521 = 'Web 服务器宕机(CloudFlare):源服务器拒绝了来自 CloudFlare 的连接。', + /** + * h522: + * Empty + * 连接超时(CloudFlare):CloudFlare 无法与源服务器完成 TCP 握手。 + */ + h522 = '连接超时(CloudFlare):CloudFlare 无法与源服务器完成 TCP 握手。', + /** + * h523: + * Empty + * 源不可达(CloudFlare):CloudFlare 无法到达源服务器;例如,源服务器的 DNS 记录不正确。 + */ + h523 = '源不可达(CloudFlare):CloudFlare 无法到达源服务器;例如,源服务器的 DNS 记录不正确。', + /** + * h524: + * Empty + * 发生超时(CloudFlare):CloudFlare 能够与源服务器建立 TCP 连接,但未能及时收到 HTTP 响应。 + */ + h524 = '发生超时(CloudFlare):CloudFlare 能够与源服务器建立 TCP 连接,但未能及时收到 HTTP 响应。', + /** + * h525: + * Empty + * SSL 握手失败(CloudFlare):CloudFlare 无法与源服务器完成 SSL/TLS 握手。 + */ + h525 = 'SSL 握手失败(CloudFlare):CloudFlare 无法与源服务器完成 SSL/TLS 握手。', + /** + * h526: + * Empty + * 无效的 SSL 证书(CloudFlare):CloudFlare 无法验证源服务器提供的 SSL/TLS 证书。 + */ + h526 = '无效的 SSL 证书(CloudFlare):CloudFlare 无法验证源服务器提供的 SSL/TLS 证书。', + /** + * h527: + * Empty + * Railgun 错误(CloudFlare):在建立 WAN 连接后,请求超时或失败。 + */ + h527 = 'Railgun 错误(CloudFlare):在建立 WAN 连接后,请求超时或失败。' +} diff --git a/packages/i18n-zh/src/lib/status-text.ts b/packages/i18n-zh/src/lib/status-text.ts index c745991..78e5e37 100644 --- a/packages/i18n-zh/src/lib/status-text.ts +++ b/packages/i18n-zh/src/lib/status-text.ts @@ -16,483 +16,966 @@ export enum HttpStatusText { /** - * 100: RFC 7231 6.2.1 + * CONTINUE: RFC 7231 6.2.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.1 * 继续:服务器已经收到请求头,客户端应继续发送请求主体。 */ CONTINUE = 'Continue', /** - * 101: RFC 7231 6.2.2 + * SWITCHING_PROTOCOLS: RFC 7231 6.2.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.2 * 切换协议:请求者已要求服务器切换协议,服务器确认它将进行切换。 */ SWITCHING_PROTOCOLS = 'Switching Protocols', /** - * 102: RFC 2518 10.1 (已被 RFC 4918 废弃) + * PROCESSING: RFC 2518 10.1 (已被 RFC 4918 废弃) * https://datatracker.ietf.org/doc/html/rfc2518#section-10.1 * 处理中:服务器已收到请求并正在处理,但尚无可用的响应。 */ PROCESSING = 'Processing', /** - * 200: RFC 7231 6.3.1 + * OK: RFC 7231 6.3.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1 * 成功:标准的成功 HTTP 请求响应。 */ OK = 'OK', /** - * 201: RFC 7231 6.3.2 + * CREATED: RFC 7231 6.3.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2 * 已创建:请求已完成并且新资源已创建。 */ CREATED = 'Created', /** - * 202: RFC 7231 6.3.3 + * ACCEPTED: RFC 7231 6.3.3 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3 * 已接受:请求已被接受但尚未处理完毕。此代码不保证请求会成功处理。 */ ACCEPTED = 'Accepted', /** - * 203: RFC 7231 6.3.4 + * NON_AUTHORITATIVE_INFORMATION: RFC 7231 6.3.4 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.4 * 非权威信息:服务器成功处理了请求,但返回的是来自另一来源的信息。 */ NON_AUTHORITATIVE_INFORMATION = 'Non-Authoritative Information', /** - * 204: RFC 7231 6.3.5 + * NO_CONTENT: RFC 7231 6.3.5 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5 * 无内容:服务器接受了请求,但没有返回任何内容。通常作为 DELETE 请求的响应。 */ NO_CONTENT = 'No Content', /** - * 205: RFC 7231 6.3.6 + * RESET_CONTENT: RFC 7231 6.3.6 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 * 重置内容:类似于 204 无内容响应,但此响应要求请求者重置文档视图。 */ RESET_CONTENT = 'Reset Content', /** - * 206: RFC 7233 4.1 + * PARTIAL_CONTENT: RFC 7233 4.1 * https://datatracker.ietf.org/doc/html/rfc7233#section-4.1 * 部分内容:服务器仅提供了客户端通过 Range 头请求的部分内容。 */ PARTIAL_CONTENT = 'Partial Content', /** - * 207: RFC 4918 11.1 + * MULTI_STATUS: RFC 4918 11.1 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.1 * 多状态:后续的消息体是一个 XML 消息,可能包含多个响应代码,具体取决于有多少子请求被发出。 */ MULTI_STATUS = 'Multi-Status', /** - * 208: RFC 5842 7.1 + * ALREADY_REPORTED: RFC 5842 7.1 * https://datatracker.ietf.org/doc/html/rfc5842#section-7.1 * 已报告:DAV 绑定的成员已经在对此请求的先前回复中被枚举,不再重复包含。 */ ALREADY_REPORTED = 'Already Reported', /** - * 226: RFC 3229 10.4.1 + * IM_USED: RFC 3229 10.4.1 * https://datatracker.ietf.org/doc/html/rfc3229#section-10.4.1 * IM 使用:服务器已完成资源的 GET 请求,并且响应表示对当前实例应用了一个或多个实例操作的结果。 */ IM_USED = 'IM Used', /** - * 300: RFC 7231 6.4.1 + * MULTIPLE_CHOICES: RFC 7231 6.4.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.1 * 多重选择:客户端可以选择多个选项中的一个进行操作。 */ MULTIPLE_CHOICES = 'Multiple Choices', /** - * 301: RFC 7231 6.4.2 + * MOVED_PERMANENTLY: RFC 7231 6.4.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2 * 永久移动:资源已被移动,所有后续请求应参考其新的 URI。 */ MOVED_PERMANENTLY = 'Moved Permanently', /** - * 302: RFC 7231 6.4.3 + * FOUND: RFC 7231 6.4.3 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3 * 找到:HTTP 1.0 规范将此状态描述为“临时移动”,但流行的浏览器对此状态的响应类似于 303 的行为。资源可以通过参考返回的 URI 来获取。 */ FOUND = 'Found', /** - * 303: RFC 7231 6.4.4 + * SEE_OTHER: RFC 7231 6.4.4 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4 * 参见其他:资源可以通过使用 GET 方法来获取其他 URI。当在响应 POST、PUT 或 DELETE 请求时收到此状态码,通常可以认为服务器已成功处理请求并将客户端指向一个信息性端点。 */ SEE_OTHER = 'See Other', /** - * 304: RFC 7232 4.1 + * NOT_MODIFIED: RFC 7232 4.1 * https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 * 未修改:自 If-Modified-Since 或 If-Match 头中指定的版本以来,资源未被修改。响应主体中将不会返回资源。 */ NOT_MODIFIED = 'Not Modified', /** - * 305: RFC 7231 6.4.5 + * USE_PROXY: RFC 7231 6.4.5 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.5 * 使用代理:HTTP 1.1。资源只能通过代理访问,地址在响应中提供。 */ USE_PROXY = 'Use Proxy', /** - * 306: + * SWITCH_PROXY: * * 切换代理:在 HTTP 1.1 中已废弃。曾用于表示后续请求应使用指定的代理发送。 */ SWITCH_PROXY = 'Switch proxy', /** - * 307: RFC 7231 6.4.7 + * TEMPORARY_REDIRECT: RFC 7231 6.4.7 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 * 临时重定向:HTTP 1.1。请求应使用响应中提供的 URI 重新发送,但未来的请求仍应调用原始 URI。 */ TEMPORARY_REDIRECT = 'Temporary Redirect', /** - * 308: RFC 7538 3 + * PERMANENT_REDIRECT: RFC 7538 3 * https://datatracker.ietf.org/doc/html/rfc7538#section-3 * 永久重定向:请求和所有未来的请求应使用响应中提供的 URI 重新发送。 */ PERMANENT_REDIRECT = 'Permanent Redirect', /** - * 400: RFC 7231 6.5.1 + * BAD_REQUEST: RFC 7231 6.5.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1 * 错误请求:由于请求的语法不正确,无法满足请求。 */ BAD_REQUEST = 'Bad Request', /** - * 401: RFC 7235 3.1 + * UNAUTHORIZED: RFC 7235 3.1 * https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 * 未授权:请求者未被授权访问该资源。与 403 类似,但用于身份验证失败或未提供身份验证的情况。 */ UNAUTHORIZED = 'Unauthorized', /** - * 402: RFC 7231 6.5.2 + * PAYMENT_REQUIRED: RFC 7231 6.5.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2 * 需要付款:保留以供将来使用。某些网络服务使用此状态码表示客户端发送的请求次数过多。 */ PAYMENT_REQUIRED = 'Payment Required', /** - * 403: RFC 7231 6.5.3 + * FORBIDDEN: RFC 7231 6.5.3 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3 * 禁止:请求格式正确,但服务器拒绝提供请求的资源。与 401 不同,身份验证不会改变服务器的响应。 */ FORBIDDEN = 'Forbidden', /** - * 404: RFC 7231 6.5.4 + * NOT_FOUND: RFC 7231 6.5.4 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 * 未找到:找不到请求的资源。通常用于服务器上所有无效的 URI 请求。 */ NOT_FOUND = 'Not Found', /** - * 405: RFC 7231 6.5.5 + * METHOD_NOT_ALLOWED: RFC 7231 6.5.5 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5 * 方法不允许:资源请求使用了不允许的方法。例如,使用 POST 方法请求资源,但该资源仅支持 GET 方法。 */ METHOD_NOT_ALLOWED = 'Method Not Allowed', /** - * 406: RFC 7231 6.5.6 + * NOT_ACCEPTABLE: RFC 7231 6.5.6 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.6 * 不可接受:资源有效,但无法以请求中 Accept 头字段指定的格式提供。 */ NOT_ACCEPTABLE = 'Not Acceptable', /** - * 407: RFC 7235 3.2 + * PROXY_AUTHENTICATION_REQUIRED: RFC 7235 3.2 * https://datatracker.ietf.org/doc/html/rfc7235#section-3.2 * 需要代理身份验证:在满足请求之前,需要对代理进行身份验证。 */ PROXY_AUTHENTICATION_REQUIRED = 'Proxy Authentication Required', /** - * 408: RFC 7231 6.5.7 + * REQUEST_TIMEOUT: RFC 7231 6.5.7 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.7 * 请求超时:服务器等待客户端的请求超时。允许客户端重新发送请求。 */ REQUEST_TIMEOUT = 'Request Timeout', /** - * 409: RFC 7231 6.5.8 + * CONFLICT: RFC 7231 6.5.8 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8 * 冲突:由于请求参数中的冲突,无法完成请求。 */ CONFLICT = 'Conflict', /** - * 410: RFC 7231 6.5.9 + * GONE: RFC 7231 6.5.9 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.9 * 已删除:请求的资源在请求的 URI 不再可用,且不会提供重定向。 */ GONE = 'Gone', /** - * 411: RFC 7231 6.5.10 + * LENGTH_REQUIRED: RFC 7231 6.5.10 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.10 * 需要内容长度:请求未指定资源所需的内容长度。 */ LENGTH_REQUIRED = 'Length Required', /** - * 412: RFC 7232 4.2 + * PRECONDITION_FAILED: RFC 7232 4.2 * https://datatracker.ietf.org/doc/html/rfc7232#section-4.2 * 前提条件失败:服务器不满足客户端指定的一个前提条件。 */ PRECONDITION_FAILED = 'Precondition Failed', /** - * 413: RFC 7231 6.5.11 + * PAYLOAD_TOO_LARGE: RFC 7231 6.5.11 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.11 * 请求实体过大:请求的内容比服务器能够处理的要大。 */ PAYLOAD_TOO_LARGE = 'Payload Too Large', /** - * 414: RFC 7231 6.5.12 + * URI_TOO_LONG: RFC 7231 6.5.12 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.12 * 请求 URI 过长:请求中提供的 URI 过长,服务器无法处理。通常在 GET 请求的 URI 中编码了过多数据时会使用此状态码,此时应改用 POST 请求。 */ URI_TOO_LONG = 'URI Too Long', /** - * 415: RFC 7231 6.5.13 + * UNSUPPORTED_MEDIA_TYPE: RFC 7231 6.5.13 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.13 * 不支持的媒体类型:客户端提供的数据类型不受服务器支持。 */ UNSUPPORTED_MEDIA_TYPE = 'Unsupported Media Type', /** - * 416: RFC 7233 4.4 + * RANGE_NOT_SATISFIABLE: RFC 7233 4.4 * https://datatracker.ietf.org/doc/html/rfc7233#section-4.4 * 请求的范围无法满足:客户端请求了资源的一部分,但服务器无法提供该部分。 */ RANGE_NOT_SATISFIABLE = 'Range Not Satisfiable', /** - * 417: RFC 7231 6.5.14 + * EXPECTATION_FAILED: RFC 7231 6.5.14 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.14 * 期望失败:服务器无法满足 Expect 请求头字段的要求。 */ EXPECTATION_FAILED = 'Expectation Failed', /** - * 418: + * I_M_A_TEAPOT: * Empty * 我是茶壶:任何尝试用茶壶煮咖啡的行为都应该导致错误代码 "418 我是茶壶"。生成的实体内容可能会又短又粗。 */ I_M_A_TEAPOT = 'I\'m a Teapot', /** - * 421: RFC 7540 9.1.2 + * MISDIRECTED_REQUEST: RFC 7540 9.1.2 * https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2 * 请求错误定向:请求被定向到无法提供响应的服务器。该状态码可以由未配置为响应请求 URI 中包含的方案和授权组合的服务器发送。 */ MISDIRECTED_REQUEST = 'Misdirected Request', /** - * 422: RFC 4918 11.2 + * UNPROCESSABLE_ENTITY: RFC 4918 11.2 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.2 * 无法处理的实体:请求格式正确,但在当前表单中无法处理。通常在指定的参数未通过验证错误时使用。 */ UNPROCESSABLE_ENTITY = 'Unprocessable Entity', /** - * 423: RFC 4918 11.3 + * LOCKED: RFC 4918 11.3 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.3 * 已锁定:请求的资源已找到,但由于其被锁定而无法访问。 */ LOCKED = 'Locked', /** - * 424: RFC 4918 11.4 + * FAILED_DEPENDENCY: RFC 4918 11.4 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.4 * 依赖失败:由于前一个请求失败,导致当前请求也失败。 */ FAILED_DEPENDENCY = 'Failed Dependency', /** - * 426: RFC 2817 and RFC 7231 6.5.15 + * UPGRADE_REQUIRED: RFC 2817 and RFC 7231 6.5.15 * https://datatracker.ietf.org/doc/html/rfc2817 and https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.15 * 需要升级:客户端应切换到升级后的协议(如 TLS/1.0),然后再发送请求。 */ UPGRADE_REQUIRED = 'Upgrade Required', /** - * 428: RFC 6585 3 + * PRECONDITION_REQUIRED: RFC 6585 3 * https://datatracker.ietf.org/doc/html/rfc6585#section-3 * 需要前提条件:源服务器要求请求是有条件的。 */ PRECONDITION_REQUIRED = 'Precondition Required', /** - * 429: RFC 6585 4 + * TOO_MANY_REQUESTS: RFC 6585 4 * https://datatracker.ietf.org/doc/html/rfc6585#section-4 * 请求过多:用户在给定的时间内发送了过多的请求("速率限制")。 */ TOO_MANY_REQUESTS = 'Too Many Requests', /** - * 431: RFC 6585 5 + * REQUEST_HEADER_FIELDS_TOO_LARGE: RFC 6585 5 * https://datatracker.ietf.org/doc/html/rfc6585#section-5 * 请求头字段过大:服务器不愿意处理请求,因为其头字段过大。 */ REQUEST_HEADER_FIELDS_TOO_LARGE = 'Request Header Fields Too Large', /** - * 440: + * LOGIN_TIME_OUT: * Empty * 登录超时:Microsoft 扩展。表示由于用户登录超时而导致的失败。 */ LOGIN_TIME_OUT = 'Login Time-out', /** - * 444: + * NO_RESPONSE: * Empty * 无响应:Nginx 内部状态码,用于指示服务器未返回任何信息并关闭连接。 */ NO_RESPONSE = 'No Response', /** - * 449: + * RETRY_WITH: * Empty * 重试:Microsoft 扩展。用于指示客户端应在执行适当操作后重新发送请求。 */ RETRY_WITH = 'Retry With', /** - * 450: + * BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS: * Empty * 被 Windows 家长控制阻止:Microsoft 扩展。当 Windows 家长控制阻止访问特定网页时出现。 */ BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS = 'Blocked by Windows Parental Controls', /** - * 451: RFC 7725 + * UNAVAILABLE_FOR_LEGAL_REASONS: RFC 7725 * https://datatracker.ietf.org/doc/html/rfc7725 * 因法律原因不可用:服务器由于接到法律约束请求而无法操作。 */ UNAVAILABLE_FOR_LEGAL_REASONS = 'Unavailable For Legal Reasons', /** - * 494: + * REQUEST_HEADER_TOO_LARGE: * Empty * 请求头字段过大:Nginx 内部代码,类似于 431,但在更早版本中实现。 */ REQUEST_HEADER_TOO_LARGE = 'Request Header Too Large', /** - * 495: + * CERT_ERROR: * Empty * 证书错误:Nginx 内部代码,用于 SSL 客户端证书错误,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 */ CERT_ERROR = 'Cert Error', /** - * 496: + * NO_CERT: * Empty * 无证书:Nginx 内部代码,当客户端未提供证书时使用,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 */ NO_CERT = 'No Cert', /** - * 497: + * HTTP_TO_HTTPS: * Empty * HTTP 到 HTTPS:Nginx 内部代码,用于发送到 HTTPS 端口的纯 HTTP 请求,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 */ HTTP_TO_HTTPS = 'HTTP to HTTPS', /** - * 498: + * TOKEN_EXPIRED_INVALID: * Empty * 令牌过期/无效:由 ArcGIS for Server 返回。代码 498 表示令牌已过期或无效。 */ TOKEN_EXPIRED_INVALID = 'Token expired/invalid', /** - * 499: + * TOKEN_REQUIRED: * Empty * 需要令牌:由 ArcGIS for Server 返回。代码 499 表示需要令牌(如果未提交令牌)。 */ TOKEN_REQUIRED = 'Token required', /** - * 500: RFC 7231 6.6.1 + * INTERNAL_SERVER_ERROR: RFC 7231 6.6.1 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1 * 服务器内部错误:服务器自身的通用错误状态。 */ INTERNAL_SERVER_ERROR = 'Internal Server Error', /** - * 501: RFC 7231 6.6.2 + * NOT_IMPLEMENTED: RFC 7231 6.6.2 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2 * 未实现:服务器无法响应请求,通常表示服务器可能在未来支持此请求,否则使用 4xx 状态码可能更为适当。 */ NOT_IMPLEMENTED = 'Not Implemented', /** - * 502: RFC 7231 6.6.3 + * BAD_GATEWAY: RFC 7231 6.6.3 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3 * 错误网关:服务器作为代理时,从上游服务器接收到的响应无效。 */ BAD_GATEWAY = 'Bad Gateway', /** - * 503: RFC 7231 6.6.4 + * SERVICE_UNAVAILABLE: RFC 7231 6.6.4 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4 * 服务不可用:服务器停机,不接受请求。 */ SERVICE_UNAVAILABLE = 'Service Unavailable', /** - * 504: RFC 7231 6.6.5 + * GATEWAY_TIMEOUT: RFC 7231 6.6.5 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5 * 网关超时:服务器作为代理时,从上游服务器未能及时接收到响应。 */ GATEWAY_TIMEOUT = 'Gateway Timeout', /** - * 505: RFC 7231 6.6.6 + * HTTP_VERSION_NOT_SUPPORTED: RFC 7231 6.6.6 * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.6 * 不支持的 HTTP 版本:服务器不支持请求中所用的 HTTP 协议版本。 */ HTTP_VERSION_NOT_SUPPORTED = 'HTTP Version Not Supported', /** - * 506: RFC 2295 8.1 + * VARIANT_ALSO_NEGOTIATES: RFC 2295 8.1 * https://datatracker.ietf.org/doc/html/rfc2295#section-8.1 * 变体也在协商:请求的透明内容协商导致循环引用。 */ VARIANT_ALSO_NEGOTIATES = 'Variant Also Negotiates', /** - * 507: RFC 4918 11.5 + * INSUFFICIENT_STORAGE: RFC 4918 11.5 * https://datatracker.ietf.org/doc/html/rfc4918#section-11.5 * 存储空间不足:用户或服务器没有足够的存储配额来完成请求。 */ INSUFFICIENT_STORAGE = 'Insufficient Storage', /** - * 508: RFC 5842 7.2 + * LOOP_DETECTED: RFC 5842 7.2 * https://datatracker.ietf.org/doc/html/rfc5842#section-7.2 * 检测到循环:服务器在请求中检测到无限循环。 */ LOOP_DETECTED = 'Loop Detected', /** - * 509: + * BANDWIDTH_LIMIT_EXCEEDED: * Empty * 超出带宽限制(Apache bw/limited 扩展):此状态码未在任何 RFC 中规定,其使用方式未知。 */ BANDWIDTH_LIMIT_EXCEEDED = 'Bandwidth Limit Exceeded', /** - * 510: RFC 2774 7 + * NOT_EXTENDED: RFC 2774 7 * https://datatracker.ietf.org/doc/html/rfc2774#section-7 * 未扩展:需要进一步扩展请求才能完成。 */ NOT_EXTENDED = 'Not Extended', /** - * 511: RFC 6585 6 + * NETWORK_AUTHENTICATION_REQUIRED: RFC 6585 6 * https://datatracker.ietf.org/doc/html/rfc6585#section-6 * 需要网络认证:客户端必须先通过网络认证,才能发送请求。 */ NETWORK_AUTHENTICATION_REQUIRED = 'Network Authentication Required', /** - * 520: + * UNKNOWN_ERROR_MICROSOFT_CLOUD_FLARE: * Empty * 未知错误(Microsoft / CloudFlare):此状态码未在任何 RFC 中规定,由某些服务返回,如 Microsoft Azure 和 CloudFlare 服务器:520 错误本质上是对源服务器返回意外响应或不可解释/不允许(协议违规或空响应)的 "兜底" 响应。 */ UNKNOWN_ERROR_MICROSOFT_CLOUD_FLARE = 'Unknown Error (Microsoft / CloudFlare)', /** - * 521: + * WEB_SERVER_IS_DOWN_CLOUD_FLARE: * Empty * Web 服务器宕机(CloudFlare):源服务器拒绝了来自 CloudFlare 的连接。 */ WEB_SERVER_IS_DOWN_CLOUD_FLARE = 'Web Server Is Down (CloudFlare)', /** - * 522: + * CONNECTION_TIMED_OUT_CLOUD_FLARE: * Empty * 连接超时(CloudFlare):CloudFlare 无法与源服务器完成 TCP 握手。 */ CONNECTION_TIMED_OUT_CLOUD_FLARE = 'Connection Timed Out (CloudFlare)', /** - * 523: + * ORIGIN_IS_UNREACHABLE_CLOUD_FLARE: * Empty * 源不可达(CloudFlare):CloudFlare 无法到达源服务器;例如,源服务器的 DNS 记录不正确。 */ ORIGIN_IS_UNREACHABLE_CLOUD_FLARE = 'Origin Is Unreachable (CloudFlare)', /** - * 524: + * A_TIMEOUT_OCCURRED_CLOUD_FLARE: * Empty * 发生超时(CloudFlare):CloudFlare 能够与源服务器建立 TCP 连接,但未能及时收到 HTTP 响应。 */ A_TIMEOUT_OCCURRED_CLOUD_FLARE = 'A Timeout Occurred (CloudFlare)', /** - * 525: + * SSL_HANDSHAKE_FAILED_CLOUD_FLARE: * Empty * SSL 握手失败(CloudFlare):CloudFlare 无法与源服务器完成 SSL/TLS 握手。 */ SSL_HANDSHAKE_FAILED_CLOUD_FLARE = 'SSL Handshake Failed (CloudFlare)', /** - * 526: + * INVALID_SSL_CERTIFICATE_CLOUD_FLARE: * Empty * 无效的 SSL 证书(CloudFlare):CloudFlare 无法验证源服务器提供的 SSL/TLS 证书。 */ INVALID_SSL_CERTIFICATE_CLOUD_FLARE = 'Invalid SSL Certificate (CloudFlare)', /** - * 527: + * RAILGUN_ERROR_CLOUD_FLARE: * Empty * Railgun 错误(CloudFlare):在建立 WAN 连接后,请求超时或失败。 */ RAILGUN_ERROR_CLOUD_FLARE = 'Railgun Error (CloudFlare)' } + +export enum HttpStatusTextByCode { + /** + * h100: RFC 7231 6.2.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.1 + * 继续:服务器已经收到请求头,客户端应继续发送请求主体。 + */ + h100 = 'Continue', + /** + * h101: RFC 7231 6.2.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.2.2 + * 切换协议:请求者已要求服务器切换协议,服务器确认它将进行切换。 + */ + h101 = 'Switching Protocols', + /** + * h102: RFC 2518 10.1 (已被 RFC 4918 废弃) + * https://datatracker.ietf.org/doc/html/rfc2518#section-10.1 + * 处理中:服务器已收到请求并正在处理,但尚无可用的响应。 + */ + h102 = 'Processing', + /** + * h200: RFC 7231 6.3.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1 + * 成功:标准的成功 HTTP 请求响应。 + */ + h200 = 'OK', + /** + * h201: RFC 7231 6.3.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2 + * 已创建:请求已完成并且新资源已创建。 + */ + h201 = 'Created', + /** + * h202: RFC 7231 6.3.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.3 + * 已接受:请求已被接受但尚未处理完毕。此代码不保证请求会成功处理。 + */ + h202 = 'Accepted', + /** + * h203: RFC 7231 6.3.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.4 + * 非权威信息:服务器成功处理了请求,但返回的是来自另一来源的信息。 + */ + h203 = 'Non-Authoritative Information', + /** + * h204: RFC 7231 6.3.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5 + * 无内容:服务器接受了请求,但没有返回任何内容。通常作为 DELETE 请求的响应。 + */ + h204 = 'No Content', + /** + * h205: RFC 7231 6.3.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.6 + * 重置内容:类似于 204 无内容响应,但此响应要求请求者重置文档视图。 + */ + h205 = 'Reset Content', + /** + * h206: RFC 7233 4.1 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.1 + * 部分内容:服务器仅提供了客户端通过 Range 头请求的部分内容。 + */ + h206 = 'Partial Content', + /** + * h207: RFC 4918 11.1 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.1 + * 多状态:后续的消息体是一个 XML 消息,可能包含多个响应代码,具体取决于有多少子请求被发出。 + */ + h207 = 'Multi-Status', + /** + * h208: RFC 5842 7.1 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.1 + * 已报告:DAV 绑定的成员已经在对此请求的先前回复中被枚举,不再重复包含。 + */ + h208 = 'Already Reported', + /** + * h226: RFC 3229 10.4.1 + * https://datatracker.ietf.org/doc/html/rfc3229#section-10.4.1 + * IM 使用:服务器已完成资源的 GET 请求,并且响应表示对当前实例应用了一个或多个实例操作的结果。 + */ + h226 = 'IM Used', + /** + * h300: RFC 7231 6.4.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.1 + * 多重选择:客户端可以选择多个选项中的一个进行操作。 + */ + h300 = 'Multiple Choices', + /** + * h301: RFC 7231 6.4.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2 + * 永久移动:资源已被移动,所有后续请求应参考其新的 URI。 + */ + h301 = 'Moved Permanently', + /** + * h302: RFC 7231 6.4.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3 + * 找到:HTTP 1.0 规范将此状态描述为“临时移动”,但流行的浏览器对此状态的响应类似于 303 的行为。资源可以通过参考返回的 URI 来获取。 + */ + h302 = 'Found', + /** + * h303: RFC 7231 6.4.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4 + * 参见其他:资源可以通过使用 GET 方法来获取其他 URI。当在响应 POST、PUT 或 DELETE 请求时收到此状态码,通常可以认为服务器已成功处理请求并将客户端指向一个信息性端点。 + */ + h303 = 'See Other', + /** + * h304: RFC 7232 4.1 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 + * 未修改:自 If-Modified-Since 或 If-Match 头中指定的版本以来,资源未被修改。响应主体中将不会返回资源。 + */ + h304 = 'Not Modified', + /** + * h305: RFC 7231 6.4.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.5 + * 使用代理:HTTP 1.1。资源只能通过代理访问,地址在响应中提供。 + */ + h305 = 'Use Proxy', + /** + * h306: + * + * 切换代理:在 HTTP 1.1 中已废弃。曾用于表示后续请求应使用指定的代理发送。 + */ + h306 = 'Switch proxy', + /** + * h307: RFC 7231 6.4.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 + * 临时重定向:HTTP 1.1。请求应使用响应中提供的 URI 重新发送,但未来的请求仍应调用原始 URI。 + */ + h307 = 'Temporary Redirect', + /** + * h308: RFC 7538 3 + * https://datatracker.ietf.org/doc/html/rfc7538#section-3 + * 永久重定向:请求和所有未来的请求应使用响应中提供的 URI 重新发送。 + */ + h308 = 'Permanent Redirect', + /** + * h400: RFC 7231 6.5.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1 + * 错误请求:由于请求的语法不正确,无法满足请求。 + */ + h400 = 'Bad Request', + /** + * h401: RFC 7235 3.1 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 + * 未授权:请求者未被授权访问该资源。与 403 类似,但用于身份验证失败或未提供身份验证的情况。 + */ + h401 = 'Unauthorized', + /** + * h402: RFC 7231 6.5.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.2 + * 需要付款:保留以供将来使用。某些网络服务使用此状态码表示客户端发送的请求次数过多。 + */ + h402 = 'Payment Required', + /** + * h403: RFC 7231 6.5.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3 + * 禁止:请求格式正确,但服务器拒绝提供请求的资源。与 401 不同,身份验证不会改变服务器的响应。 + */ + h403 = 'Forbidden', + /** + * h404: RFC 7231 6.5.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 + * 未找到:找不到请求的资源。通常用于服务器上所有无效的 URI 请求。 + */ + h404 = 'Not Found', + /** + * h405: RFC 7231 6.5.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5 + * 方法不允许:资源请求使用了不允许的方法。例如,使用 POST 方法请求资源,但该资源仅支持 GET 方法。 + */ + h405 = 'Method Not Allowed', + /** + * h406: RFC 7231 6.5.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.6 + * 不可接受:资源有效,但无法以请求中 Accept 头字段指定的格式提供。 + */ + h406 = 'Not Acceptable', + /** + * h407: RFC 7235 3.2 + * https://datatracker.ietf.org/doc/html/rfc7235#section-3.2 + * 需要代理身份验证:在满足请求之前,需要对代理进行身份验证。 + */ + h407 = 'Proxy Authentication Required', + /** + * h408: RFC 7231 6.5.7 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.7 + * 请求超时:服务器等待客户端的请求超时。允许客户端重新发送请求。 + */ + h408 = 'Request Timeout', + /** + * h409: RFC 7231 6.5.8 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8 + * 冲突:由于请求参数中的冲突,无法完成请求。 + */ + h409 = 'Conflict', + /** + * h410: RFC 7231 6.5.9 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.9 + * 已删除:请求的资源在请求的 URI 不再可用,且不会提供重定向。 + */ + h410 = 'Gone', + /** + * h411: RFC 7231 6.5.10 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.10 + * 需要内容长度:请求未指定资源所需的内容长度。 + */ + h411 = 'Length Required', + /** + * h412: RFC 7232 4.2 + * https://datatracker.ietf.org/doc/html/rfc7232#section-4.2 + * 前提条件失败:服务器不满足客户端指定的一个前提条件。 + */ + h412 = 'Precondition Failed', + /** + * h413: RFC 7231 6.5.11 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.11 + * 请求实体过大:请求的内容比服务器能够处理的要大。 + */ + h413 = 'Payload Too Large', + /** + * h414: RFC 7231 6.5.12 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.12 + * 请求 URI 过长:请求中提供的 URI 过长,服务器无法处理。通常在 GET 请求的 URI 中编码了过多数据时会使用此状态码,此时应改用 POST 请求。 + */ + h414 = 'URI Too Long', + /** + * h415: RFC 7231 6.5.13 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.13 + * 不支持的媒体类型:客户端提供的数据类型不受服务器支持。 + */ + h415 = 'Unsupported Media Type', + /** + * h416: RFC 7233 4.4 + * https://datatracker.ietf.org/doc/html/rfc7233#section-4.4 + * 请求的范围无法满足:客户端请求了资源的一部分,但服务器无法提供该部分。 + */ + h416 = 'Range Not Satisfiable', + /** + * h417: RFC 7231 6.5.14 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.14 + * 期望失败:服务器无法满足 Expect 请求头字段的要求。 + */ + h417 = 'Expectation Failed', + /** + * h418: + * Empty + * 我是茶壶:任何尝试用茶壶煮咖啡的行为都应该导致错误代码 "418 我是茶壶"。生成的实体内容可能会又短又粗。 + */ + h418 = 'I\'m a Teapot', + /** + * h421: RFC 7540 9.1.2 + * https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2 + * 请求错误定向:请求被定向到无法提供响应的服务器。该状态码可以由未配置为响应请求 URI 中包含的方案和授权组合的服务器发送。 + */ + h421 = 'Misdirected Request', + /** + * h422: RFC 4918 11.2 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.2 + * 无法处理的实体:请求格式正确,但在当前表单中无法处理。通常在指定的参数未通过验证错误时使用。 + */ + h422 = 'Unprocessable Entity', + /** + * h423: RFC 4918 11.3 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.3 + * 已锁定:请求的资源已找到,但由于其被锁定而无法访问。 + */ + h423 = 'Locked', + /** + * h424: RFC 4918 11.4 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.4 + * 依赖失败:由于前一个请求失败,导致当前请求也失败。 + */ + h424 = 'Failed Dependency', + /** + * h426: RFC 2817 and RFC 7231 6.5.15 + * https://datatracker.ietf.org/doc/html/rfc2817 and https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.15 + * 需要升级:客户端应切换到升级后的协议(如 TLS/1.0),然后再发送请求。 + */ + h426 = 'Upgrade Required', + /** + * h428: RFC 6585 3 + * https://datatracker.ietf.org/doc/html/rfc6585#section-3 + * 需要前提条件:源服务器要求请求是有条件的。 + */ + h428 = 'Precondition Required', + /** + * h429: RFC 6585 4 + * https://datatracker.ietf.org/doc/html/rfc6585#section-4 + * 请求过多:用户在给定的时间内发送了过多的请求("速率限制")。 + */ + h429 = 'Too Many Requests', + /** + * h431: RFC 6585 5 + * https://datatracker.ietf.org/doc/html/rfc6585#section-5 + * 请求头字段过大:服务器不愿意处理请求,因为其头字段过大。 + */ + h431 = 'Request Header Fields Too Large', + /** + * h440: + * Empty + * 登录超时:Microsoft 扩展。表示由于用户登录超时而导致的失败。 + */ + h440 = 'Login Time-out', + /** + * h444: + * Empty + * 无响应:Nginx 内部状态码,用于指示服务器未返回任何信息并关闭连接。 + */ + h444 = 'No Response', + /** + * h449: + * Empty + * 重试:Microsoft 扩展。用于指示客户端应在执行适当操作后重新发送请求。 + */ + h449 = 'Retry With', + /** + * h450: + * Empty + * 被 Windows 家长控制阻止:Microsoft 扩展。当 Windows 家长控制阻止访问特定网页时出现。 + */ + h450 = 'Blocked by Windows Parental Controls', + /** + * h451: RFC 7725 + * https://datatracker.ietf.org/doc/html/rfc7725 + * 因法律原因不可用:服务器由于接到法律约束请求而无法操作。 + */ + h451 = 'Unavailable For Legal Reasons', + /** + * h494: + * Empty + * 请求头字段过大:Nginx 内部代码,类似于 431,但在更早版本中实现。 + */ + h494 = 'Request Header Too Large', + /** + * h495: + * Empty + * 证书错误:Nginx 内部代码,用于 SSL 客户端证书错误,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h495 = 'Cert Error', + /** + * h496: + * Empty + * 无证书:Nginx 内部代码,当客户端未提供证书时使用,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h496 = 'No Cert', + /** + * h497: + * Empty + * HTTP 到 HTTPS:Nginx 内部代码,用于发送到 HTTPS 端口的纯 HTTP 请求,以将其与日志中的 4XX 区分开来,并进行错误页面重定向。 + */ + h497 = 'HTTP to HTTPS', + /** + * h498: + * Empty + * 令牌过期/无效:由 ArcGIS for Server 返回。代码 498 表示令牌已过期或无效。 + */ + h498 = 'Token expired/invalid', + /** + * h499: + * Empty + * 需要令牌:由 ArcGIS for Server 返回。代码 499 表示需要令牌(如果未提交令牌)。 + */ + h499 = 'Token required', + /** + * h500: RFC 7231 6.6.1 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1 + * 服务器内部错误:服务器自身的通用错误状态。 + */ + h500 = 'Internal Server Error', + /** + * h501: RFC 7231 6.6.2 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2 + * 未实现:服务器无法响应请求,通常表示服务器可能在未来支持此请求,否则使用 4xx 状态码可能更为适当。 + */ + h501 = 'Not Implemented', + /** + * h502: RFC 7231 6.6.3 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3 + * 错误网关:服务器作为代理时,从上游服务器接收到的响应无效。 + */ + h502 = 'Bad Gateway', + /** + * h503: RFC 7231 6.6.4 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4 + * 服务不可用:服务器停机,不接受请求。 + */ + h503 = 'Service Unavailable', + /** + * h504: RFC 7231 6.6.5 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5 + * 网关超时:服务器作为代理时,从上游服务器未能及时接收到响应。 + */ + h504 = 'Gateway Timeout', + /** + * h505: RFC 7231 6.6.6 + * https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.6 + * 不支持的 HTTP 版本:服务器不支持请求中所用的 HTTP 协议版本。 + */ + h505 = 'HTTP Version Not Supported', + /** + * h506: RFC 2295 8.1 + * https://datatracker.ietf.org/doc/html/rfc2295#section-8.1 + * 变体也在协商:请求的透明内容协商导致循环引用。 + */ + h506 = 'Variant Also Negotiates', + /** + * h507: RFC 4918 11.5 + * https://datatracker.ietf.org/doc/html/rfc4918#section-11.5 + * 存储空间不足:用户或服务器没有足够的存储配额来完成请求。 + */ + h507 = 'Insufficient Storage', + /** + * h508: RFC 5842 7.2 + * https://datatracker.ietf.org/doc/html/rfc5842#section-7.2 + * 检测到循环:服务器在请求中检测到无限循环。 + */ + h508 = 'Loop Detected', + /** + * h509: + * Empty + * 超出带宽限制(Apache bw/limited 扩展):此状态码未在任何 RFC 中规定,其使用方式未知。 + */ + h509 = 'Bandwidth Limit Exceeded', + /** + * h510: RFC 2774 7 + * https://datatracker.ietf.org/doc/html/rfc2774#section-7 + * 未扩展:需要进一步扩展请求才能完成。 + */ + h510 = 'Not Extended', + /** + * h511: RFC 6585 6 + * https://datatracker.ietf.org/doc/html/rfc6585#section-6 + * 需要网络认证:客户端必须先通过网络认证,才能发送请求。 + */ + h511 = 'Network Authentication Required', + /** + * h520: + * Empty + * 未知错误(Microsoft / CloudFlare):此状态码未在任何 RFC 中规定,由某些服务返回,如 Microsoft Azure 和 CloudFlare 服务器:520 错误本质上是对源服务器返回意外响应或不可解释/不允许(协议违规或空响应)的 "兜底" 响应。 + */ + h520 = 'Unknown Error (Microsoft / CloudFlare)', + /** + * h521: + * Empty + * Web 服务器宕机(CloudFlare):源服务器拒绝了来自 CloudFlare 的连接。 + */ + h521 = 'Web Server Is Down (CloudFlare)', + /** + * h522: + * Empty + * 连接超时(CloudFlare):CloudFlare 无法与源服务器完成 TCP 握手。 + */ + h522 = 'Connection Timed Out (CloudFlare)', + /** + * h523: + * Empty + * 源不可达(CloudFlare):CloudFlare 无法到达源服务器;例如,源服务器的 DNS 记录不正确。 + */ + h523 = 'Origin Is Unreachable (CloudFlare)', + /** + * h524: + * Empty + * 发生超时(CloudFlare):CloudFlare 能够与源服务器建立 TCP 连接,但未能及时收到 HTTP 响应。 + */ + h524 = 'A Timeout Occurred (CloudFlare)', + /** + * h525: + * Empty + * SSL 握手失败(CloudFlare):CloudFlare 无法与源服务器完成 SSL/TLS 握手。 + */ + h525 = 'SSL Handshake Failed (CloudFlare)', + /** + * h526: + * Empty + * 无效的 SSL 证书(CloudFlare):CloudFlare 无法验证源服务器提供的 SSL/TLS 证书。 + */ + h526 = 'Invalid SSL Certificate (CloudFlare)', + /** + * h527: + * Empty + * Railgun 错误(CloudFlare):在建立 WAN 连接后,请求超时或失败。 + */ + h527 = 'Railgun Error (CloudFlare)' +} diff --git a/packages/i18n/.eslintrc.json b/packages/i18n/.eslintrc.json deleted file mode 100644 index 2564a6e..0000000 --- a/packages/i18n/.eslintrc.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.json"], - "parser": "jsonc-eslint-parser", - "rules": {} - } - ] -} diff --git a/packages/i18n/.swcrc b/packages/i18n/.swcrc deleted file mode 100644 index 28e88ec..0000000 --- a/packages/i18n/.swcrc +++ /dev/null @@ -1,29 +0,0 @@ -{ - "jsc": { - "target": "es2017", - "parser": { - "syntax": "typescript", - "decorators": true, - "dynamicImport": true - }, - "transform": { - "decoratorMetadata": true, - "legacyDecorator": true - }, - "keepClassNames": true, - "externalHelpers": true, - "loose": true - }, - "module": { - "type": "es6" - }, - "sourceMaps": true, - "exclude": [ - "jest.config.ts", - ".*\\.spec.tsx?$", - ".*\\.test.tsx?$", - "./src/jest-setup.ts$", - "./**/jest-setup.ts$", - ".*.js$" - ] -} diff --git a/packages/i18n/README.md b/packages/i18n/README.md deleted file mode 100644 index ed29347..0000000 --- a/packages/i18n/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# i18n - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build i18n` to build the library. - -## Running unit tests - -Run `nx test i18n` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/packages/i18n/package.json b/packages/i18n/package.json deleted file mode 100644 index 2e5fa97..0000000 --- a/packages/i18n/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "@http-status-codes/i18n", - "version": "1.3.0", - "main": "./index.cjs", - "module": "./index.esm.js", - "description": "HTTP status codes i18n", - "author": "哎哟迪奥", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/aiyoudiao/http-status-codes-i18n.git" - }, - "bugs": { - "url": "https://github.com/aiyoudiao/http-status-codes-i18n/issues" - }, - "homepage": "https://github.com/aiyoudiao/http-status-codes-i18n#readme", - "keywords": [ - "node", - "http", - "status", - "codes", - "descriptions", - "status codes", - "HTTP status", - "HTTP codes", - "HTTP status codes", - "apache", - "HttpStatus", - "client", - "map", - "code", - "constants", - "javascript", - "typescript", - "developer tools", - "web development", - "API", - "error handling", - "API response", - "methods", - "headers", - "data", - "JSON" - ] -} \ No newline at end of file diff --git a/packages/i18n/project.json b/packages/i18n/project.json deleted file mode 100644 index f5e53d5..0000000 --- a/packages/i18n/project.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "i18n", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/i18n/src", - "projectType": "library", - "tags": [], - "// targets": "to see all targets run: nx show project i18n --web", - "targets": {} -} diff --git a/packages/i18n/rollup.config.js b/packages/i18n/rollup.config.js deleted file mode 100644 index 084fa74..0000000 --- a/packages/i18n/rollup.config.js +++ /dev/null @@ -1,37 +0,0 @@ -const { withNx } = require('@nx/rollup/with-nx'); -const terser = require('@rollup/plugin-terser'); - -module.exports = withNx( - { - main: './src/index.ts', - outputPath: '../../dist/packages/i18n', - tsConfig: './tsconfig.lib.json', - compiler: 'swc', - format: ['cjs', 'esm', 'es', 'amd', 'iife', 'umd', 'system'], - assets: [{ input: '.', output: '.', glob: 'packages/i18n/*.md' }], - }, - { - // Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options - // e.g. - output: { name: 'i18n', sourcemap: true, extend: true }, - plugins: [ - terser({ - format: { - comments: false, - }, - compress: { - drop_console: true, - passes: 3, // 多次压缩,提高效果 - hoist_funs: true, // 提升函数声明 - reduce_vars: true, // 减少变量使用 - collapse_vars: true, // 合并变量 - }, - mangle: { - properties: { - regex: /^_/, // 选择性的混淆变量名(以_开头的变量名) - }, - }, - }), - ], - } -); diff --git a/packages/i18n/src/index.ts b/packages/i18n/src/index.ts deleted file mode 100644 index cda584c..0000000 --- a/packages/i18n/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/i18n'; diff --git a/packages/i18n/src/lib/i18n.spec.ts b/packages/i18n/src/lib/i18n.spec.ts deleted file mode 100644 index d9794b9..0000000 --- a/packages/i18n/src/lib/i18n.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { i18n } from './i18n'; - -describe('i18n', () => { - it('should work', () => { - expect(i18n()).toEqual('i18n'); - }); -}); diff --git a/packages/i18n/src/lib/i18n.ts b/packages/i18n/src/lib/i18n.ts deleted file mode 100644 index e27b67c..0000000 --- a/packages/i18n/src/lib/i18n.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function i18n(): string { - return 'i18n'; -} diff --git a/packages/i18n/tsconfig.json b/packages/i18n/tsconfig.json deleted file mode 100644 index 0d0ea5a..0000000 --- a/packages/i18n/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "ES2015", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/packages/i18n/tsconfig.lib.json b/packages/i18n/tsconfig.lib.json deleted file mode 100644 index ce3b531..0000000 --- a/packages/i18n/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["src/**/*.ts"], - "exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} diff --git a/packages/i18n/tsconfig.spec.json b/packages/i18n/tsconfig.spec.json deleted file mode 100644 index 3c002c2..0000000 --- a/packages/i18n/tsconfig.spec.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": [ - "vitest/globals", - "vitest/importMeta", - "vite/client", - "node", - "vitest" - ] - }, - "include": [ - "vite.config.ts", - "vitest.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx", - "src/**/*.d.ts" - ] -} diff --git a/packages/i18n/vite.config.ts b/packages/i18n/vite.config.ts deleted file mode 100644 index 52775ea..0000000 --- a/packages/i18n/vite.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { defineConfig } from 'vite'; - -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; - -export default defineConfig({ - root: __dirname, - cacheDir: '../../node_modules/.vite/packages/i18n', - - plugins: [nxViteTsPaths()], - - // Uncomment this if you are using workers. - // worker: { - // plugins: [ nxViteTsPaths() ], - // }, - - test: { - watch: false, - globals: true, - environment: 'node', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - reporters: ['default'], - coverage: { - reportsDirectory: '../../coverage/packages/i18n', - provider: 'v8', - }, - }, -}); diff --git a/scripts/typescript/generate-codes.ts b/scripts/typescript/generate-codes.ts index 6ad1da4..83fbee5 100644 --- a/scripts/typescript/generate-codes.ts +++ b/scripts/typescript/generate-codes.ts @@ -1,640 +1,17 @@ import { - Writers, - VariableDeclarationKind, Project, - StructureKind, - EnumMemberStructure, - OptionalKind, QuoteKind, IndentationText, NewLineKind, } from 'ts-morph'; /* https://ts-morph.com/ */ -import { constantCase } from 'change-case'; import httpStatusCodesInfosByEn from '../http-data-sanitization/http-status-codes-infos.en.json'; import httpStatusCodesInfosByZh from '../http-data-sanitization/http-status-codes-infos.zh.json'; - -interface HttpStatusCodeInfo { - statusCode: string; - statusText: string; - statusDescription: string; - statusComment: string; - rfcLink: string; -} - -const generateStatusTextMembers = ( - httpStatusCodesInfos: HttpStatusCodeInfo[] -): OptionalKind[] => - httpStatusCodesInfos - .map( - ( - { statusCode, statusText, statusDescription, statusComment, rfcLink }, - i - ) => { - return [ - { - name: constantCase(statusText), - value: statusText, - docs: [ - `${statusCode}: ${statusComment}\n${rfcLink}\n${statusDescription}`, - ], - }, - ]; - } - ) - .flat(); - -const generateStatusCodeMembers = ( - httpStatusCodesInfos: HttpStatusCodeInfo[] -): OptionalKind[] => - httpStatusCodesInfos - .map( - ( - { statusCode, statusText, statusDescription, statusComment, rfcLink }, - i - ) => { - return [ - { - name: constantCase(statusText), - value: Number(statusCode), - docs: [ - `${constantCase( - statusText - )}: ${statusComment}\n${rfcLink}\n${statusDescription}`, - ], - }, - ]; - } - ) - .flat(); - -const generateStatusDescriptionMembers = ( - httpStatusCodesInfos: HttpStatusCodeInfo[] -): OptionalKind[] => - httpStatusCodesInfos - .map( - ( - { statusCode, statusText, statusDescription, statusComment, rfcLink }, - i - ) => { - return [ - { - name: constantCase(statusText), - value: statusDescription, - docs: [ - `${constantCase( - statusText - )}: ${statusComment}\n${rfcLink}\n${statusDescription}`, - ], - }, - ]; - } - ) - .flat(); - -const generatedMemberFiles = ( - project: Project, - httpStatusCodesInfos: HttpStatusCodeInfo[], - dir: string, - comment: string -) => { - console.log(`Generate ${dir} member files...`); - - const statusTextMembers = generateStatusTextMembers(httpStatusCodesInfos); - const statusCodeMembers = generateStatusCodeMembers(httpStatusCodesInfos); - const statusDescriptionMembers = - generateStatusDescriptionMembers(httpStatusCodesInfos); - - const statusTextFile = project.createSourceFile( - `${dir}/status-text.ts`, - { - statements: [ - { - kind: StructureKind.Enum, - name: 'HttpStatusText', - isExported: true, - members: statusTextMembers, - }, - ], - }, - { - overwrite: true, - } - ); - const statusCodeFile = project.createSourceFile( - `${dir}/status-code.ts`, - { - statements: [ - { - kind: StructureKind.Enum, - name: 'HttpStatusCode', - isExported: true, - members: statusCodeMembers, - }, - ], - }, - { - overwrite: true, - } - ); - const statusDescriptionFile = project.createSourceFile( - `${dir}/status-description.ts`, - { - statements: [ - { - kind: StructureKind.Enum, - name: 'HttpStatusDescription', - isExported: true, - members: statusDescriptionMembers, - }, - ], - }, - { - overwrite: true, - } - ); - - [statusTextFile, statusCodeFile, statusDescriptionFile].forEach( - (sourceFile) => { - sourceFile.insertStatements(0, comment); - sourceFile.formatText({ - ensureNewLineAtEndOfFile: true, - }); - } - ); - - console.log(`Generated all member files`); -}; +import { generatedHelperFiles } from './generate/helpers'; +import { generatedMemberFiles } from './generate/status'; // ---------------------------------------------------------------- -const statusCodeToStatusText = (httpStatusCodesInfos: HttpStatusCodeInfo[]) => - Object.fromEntries( - httpStatusCodesInfos.reduce( - ( - map: Map, - { statusCode, statusText, statusDescription, statusComment, rfcLink } - ) => { - map.set(Number(statusCode), JSON.stringify(statusText)); - return map; - }, - new Map() - ) - ); - -const statusCodeToStatusDescription = ( - httpStatusCodesInfos: HttpStatusCodeInfo[] -) => - Object.fromEntries( - httpStatusCodesInfos.reduce( - ( - map: Map, - { statusCode, statusText, statusDescription, statusComment, rfcLink } - ) => { - map.set(Number(statusCode), `${JSON.stringify(statusDescription)}`); - return map; - }, - new Map() - ) - ); - -const statusTextToStatusCode = (httpStatusCodesInfos: HttpStatusCodeInfo[]) => - Object.fromEntries( - httpStatusCodesInfos.reduce( - ( - map: Map, - { statusCode, statusText, statusDescription, statusComment, rfcLink } - ) => { - map.set(JSON.stringify(statusText), Number(statusCode)); - return map; - }, - new Map() - ) - ); - -const statusTextToStatusDescription = ( - httpStatusCodesInfos: HttpStatusCodeInfo[] -) => - Object.fromEntries( - httpStatusCodesInfos.reduce( - ( - map: Map, - { statusCode, statusText, statusDescription, statusComment, rfcLink } - ) => { - map.set(`"${statusText}"`, `${JSON.stringify(statusDescription)}`); - return map; - }, - new Map() - ) - ); - -const generatedHelperFiles = ( - project: Project, - httpStatusCodesInfos: HttpStatusCodeInfo[], - dir: string, - comment: string -) => { - console.log(`Generate ${dir} helper files...`); - - const helpersFile = project.createSourceFile( - `${dir}/helpers.ts`, - { - statements: [ - { - kind: StructureKind.VariableStatement, - isExported: true, - declarationKind: VariableDeclarationKind.Const, - docs: [ - { - description: - 'Key-value mapping of HTTP status codes and HTTP status texts.', - }, - ], - declarations: [ - { - name: 'statusCodeToStatusTextMap', - type: 'Record', - initializer: Writers.object( - statusCodeToStatusText(httpStatusCodesInfos) - ), - }, - ], - }, - { - kind: StructureKind.VariableStatement, - isExported: true, - declarationKind: VariableDeclarationKind.Const, - docs: [ - { - description: - 'Key-value mapping of HTTP status codes and HTTP status descriptions.', - }, - ], - declarations: [ - { - name: 'statusCodeToStatusDescriptionMap', - type: 'Record', - initializer: Writers.object( - statusCodeToStatusDescription(httpStatusCodesInfos) - ), - }, - ], - }, - { - kind: StructureKind.VariableStatement, - isExported: true, - declarationKind: VariableDeclarationKind.Const, - docs: [ - { - description: - 'Key-value mapping of HTTP status texts and HTTP status codes.', - }, - ], - declarations: [ - { - name: 'statusTextToStatusCodeMap', - type: 'Record', - initializer: Writers.object( - statusTextToStatusCode(httpStatusCodesInfos) - ), - }, - ], - }, - { - kind: StructureKind.VariableStatement, - isExported: true, - declarationKind: VariableDeclarationKind.Const, - docs: [ - { - description: - 'Key-value mapping of HTTP status texts and HTTP status descriptions.', - }, - ], - declarations: [ - { - name: 'statusTextToStatusDescriptionMap', - type: 'Record', - initializer: Writers.object( - statusTextToStatusDescription(httpStatusCodesInfos) - ), - }, - ], - }, - ], - }, - { - overwrite: true, - } - ); - - helpersFile.addTypeAlias({ - isExported: true, - name: 'HTTPStatusCode', - type: 'keyof typeof statusCodeToStatusTextMap', - }); - helpersFile.addTypeAlias({ - isExported: true, - name: 'HTTPStatusText', - type: 'keyof typeof statusTextToStatusCodeMap', - }); - helpersFile.addTypeAlias({ - isExported: true, - name: 'StatusInfo', - type: '{ code: number, message: string, success: boolean}', - }); - - helpersFile.addFunctions([ - { - name: 'isCodeOrTextValid', - returnType: 'boolean', - parameters: [ - { - name: 'codeOrText', - type: 'HTTPStatusCode | HTTPStatusText', - }, - ], - statements: [ - `return codeOrText in statusCodeToStatusTextMap || codeOrText in statusTextToStatusCodeMap;`, - ], - isExported: true, - docs: [ - { - description: - 'Returns whether the provided status code or status text is valid or not.', - tags: [ - { - tagName: 'example', - text: `isCodeOrTextValid(200) -> true -isCodeOrTextValid('OK') -> true -`, - }, - { - tagName: 'param', - text: 'codeOrText: HTTPStatusCode | HTTPStatusText', - }, - { - tagName: 'returns', - text: 'yesOrNo: boolean', - }, - ], - }, - ], - }, - { - name: 'getStatusInfo', - returnType: `StatusInfo`, - parameters: [ - { - name: 'codeOrText', - type: 'HTTPStatusCode | HTTPStatusText', - }, - ], - statements: [ - ` - if (!isCodeOrTextValid(codeOrText)) { - throw new Error(\`\${codeOrText} is not a known HTTP status code or status text.\`); - } - - const [code, message] = [ - statusTextToStatusCodeMap[codeOrText] || codeOrText as number, - statusCodeToStatusDescriptionMap[codeOrText as number] || statusTextToStatusDescriptionMap[codeOrText] - ] - - return { - code, - message, - success: code < 400 - }`, - ], - isExported: true, - docs: [ - { - description: - 'Returns an object containing information about the provided status code or status text.', - tags: [ - { - tagName: 'example', - text: `getStatusInfo(200) -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} -getStatusInfo('OK') -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} -`, - }, - { - tagName: 'param', - text: 'codeOrText: HTTPStatusCode | HTTPStatusText', - }, - { - tagName: 'returns', - text: 'StatusInfo: { code: number, message: string, success: boolean}', - }, - ], - }, - ], - }, - { - name: 'isStatusSuccessful', - returnType: 'boolean', - parameters: [ - { - name: 'codeOrText', - type: 'HTTPStatusCode | HTTPStatusText', - }, - ], - statements: [ - ` - try{ - return getStatusInfo(codeOrText).success; - } catch (e) { - return false; - }`, - ], - isExported: true, - docs: [ - { - description: - 'Returns whether the provided status code or status text is a successful status or not.', - tags: [ - { - tagName: 'example', - text: `isStatusSuccessful(200) -> true -isStatusSuccessful('OK') -> true -isStatusSuccessful(400) -> false -isStatusSuccessful('Bad request') -> false -`, - }, - { - tagName: 'param', - text: 'codeOrText: HTTPStatusCode | HTTPStatusText', - }, - { - tagName: 'returns', - text: 'successful: boolean', - }, - ], - }, - ], - }, - { - name: 'getSimpleStatusMessage', - returnType: 'string', - parameters: [ - { - name: 'codeOrText', - type: 'HTTPStatusCode | HTTPStatusText', - }, - ], - statements: [ - `const statusInfo = getStatusInfo(codeOrText) - return \`\${statusInfo.code} \${statusInfo.message.split(':')[0]}\`; - `, - ], - isExported: true, - docs: [ - { - description: - 'Returns a string containing the provided status code and simple message.', - tags: [ - { - tagName: 'example', - text: `getSimpleStatusMessage(200) -> 200 OK -getSimpleStatusMessage('OK') -> 200 OK -`, - }, - { - tagName: 'param', - text: 'codeOrText: HTTPStatusCode | HTTPStatusText', - }, - { - tagName: 'returns', - text: 'simpleStatusMessage: string', - }, - ], - }, - ], - }, - { - name: 'getStatusMessage', - returnType: 'string', - parameters: [ - { - name: 'codeOrText', - type: 'HTTPStatusCode | HTTPStatusText', - }, - ], - statements: [ - `const statusInfo = getStatusInfo(codeOrText) - return \`\${statusInfo.code} \${statusInfo.message}\`; - `, - ], - isExported: true, - docs: [ - { - description: - 'Returns a string containing the provided status code and message.', - tags: [ - { - tagName: 'example', - text: `getStatusMessage(200) -> 200 OK:The standard response for successful HTTP requests. -getStatusMessage('OK') -> 200 OK:The standard response for successful HTTP requests. -`, - }, - { - tagName: 'param', - text: 'codeOrText: HTTPStatusCode | HTTPStatusText', - }, - { - tagName: 'returns', - text: 'statusMessage: string', - }, - ], - }, - ], - }, - { - name: 'getStatusCode', - returnType: 'HTTPStatusCode', - parameters: [ - { - name: 'text', - type: 'HTTPStatusText', - }, - ], - statements: [ - ` const code = statusTextToStatusCodeMap[\`\${text}\`] - if (!code) { - throw new Error(\`\${text} is not a known HTTP status text.\`); - } - return code;`, - ], - isExported: true, - docs: [ - { - description: `Returns the status code for the given http status text. -If the given http status text does not exist, undefined is returned.`, - tags: [ - { - tagName: 'example', - text: `getStatusCode('OK') -> 200`, - }, - { - tagName: 'param', - text: 'text: HTTPStatusText', - }, - { - tagName: 'returns', - text: 'statusCode: HTTPStatusCode', - }, - ], - }, - ], - }, - { - name: 'getStatusText', - returnType: 'HTTPStatusText', - parameters: [ - { - name: 'code', - type: 'HTTPStatusCode', - }, - ], - statements: [ - ` const text = statusCodeToStatusTextMap[\`\${code}\`] - if (!text) { - throw new Error(\`\${code} is not a known HTTP status code.\`); - } - return text;`, - ], - isExported: true, - docs: [ - { - description: `Returns the status text for the given http status code. -If the given http status code does not exist, undefined is returned.`, - tags: [ - { - tagName: 'example', - text: `getStatusCode('200') -> OK`, - }, - { - tagName: 'param', - text: 'code: HTTPStatusCode', - }, - { - tagName: 'returns', - text: 'statusText: HTTPStatusText', - }, - ], - }, - ], - }, - ]); - - helpersFile.insertStatements(0, comment); - helpersFile.formatText({ - ensureNewLineAtEndOfFile: true, - }); - - console.log(`Generated all helper files`); -}; - // ---------------------------------------------------------------- const main = async () => { @@ -693,12 +70,7 @@ const main = async () => { commentByEn ); - generatedHelperFiles( - project, - httpStatusCodesInfosByEn, - '../../packages/i18n-en/src/lib', - commentByEn - ); + generatedHelperFiles(project, '../../packages/i18n-en/src/lib', commentByEn); generatedMemberFiles( project, @@ -707,12 +79,7 @@ const main = async () => { commentByZh ); - generatedHelperFiles( - project, - httpStatusCodesInfosByZh, - '../../packages/i18n-zh/src/lib', - commentByZh - ); + generatedHelperFiles(project, '../../packages/i18n-zh/src/lib', commentByZh); await project.save(); }; diff --git a/scripts/typescript/generate/helpers.ts b/scripts/typescript/generate/helpers.ts new file mode 100644 index 0000000..a3b08ae --- /dev/null +++ b/scripts/typescript/generate/helpers.ts @@ -0,0 +1,453 @@ +/** + * 创建 helpers.ts 文件 + */ + +import { + Writers, + VariableDeclarationKind, + Project, + StructureKind, +} from 'ts-morph'; /* https://ts-morph.com/ */ + +export const generatedHelperFiles = ( + project: Project, + dir: string, + comment: string +) => { + console.log(`Generate ${dir} helper files...`); + + const helpersFile = project.createSourceFile( + `${dir}/helpers.ts`, + { + statements: [ + { + kind: StructureKind.VariableStatement, + isExported: true, + declarationKind: VariableDeclarationKind.Const, + docs: [ + { + description: + 'Key-value mapping of HTTP status codes and HTTP status texts.', + }, + ], + declarations: [ + { + name: 'statusCodeToStatusTextMap', + type: 'Record', + initializer: `Object.keys( + HttpStatusCodeByCode + ) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusCodeByCode[cur as never]]: HttpStatusTextByCode[cur as never], + }), + {} + )`, + }, + ], + }, + { + kind: StructureKind.VariableStatement, + isExported: true, + declarationKind: VariableDeclarationKind.Const, + docs: [ + { + description: + 'Key-value mapping of HTTP status codes and HTTP status descriptions.', + }, + ], + declarations: [ + { + name: 'statusCodeToStatusDescriptionMap', + type: 'Record', + initializer: `Object.keys( + HttpStatusCodeByCode + ) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusCodeByCode[cur as never]]: HttpStatusDescriptionByCode[cur as never], + }), + {} + )`, + }, + ], + }, + { + kind: StructureKind.VariableStatement, + isExported: true, + declarationKind: VariableDeclarationKind.Const, + docs: [ + { + description: + 'Key-value mapping of HTTP status texts and HTTP status codes.', + }, + ], + declarations: [ + { + name: 'statusTextToStatusCodeMap', + type: 'Record', + initializer: `Object.keys( + HttpStatusTextByCode + ) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusTextByCode[cur as never]]: HttpStatusCodeByCode[cur as never], + }), + {} + )`, + }, + ], + }, + { + kind: StructureKind.VariableStatement, + isExported: true, + declarationKind: VariableDeclarationKind.Const, + docs: [ + { + description: + 'Key-value mapping of HTTP status texts and HTTP status descriptions.', + }, + ], + declarations: [ + { + name: 'statusTextToStatusDescriptionMap', + type: 'Record', + initializer: `Object.keys( + HttpStatusTextByCode + ) + .filter((name) => name.includes('h')) + .reduce( + (map, cur) => ({ + ...map, + [HttpStatusTextByCode[cur as never]]: HttpStatusDescriptionByCode[cur as never], + }), + {} + )`, + }, + ], + }, + ], + }, + { + overwrite: true, + } + ); + + helpersFile.addImportDeclaration({ + namedImports: ['HttpStatusCode', 'HttpStatusCodeByCode'], + moduleSpecifier: './status-code', + }); + + helpersFile.addImportDeclaration({ + namedImports: ['HttpStatusText', 'HttpStatusTextByCode'], + moduleSpecifier: './status-text', + }); + + helpersFile.addImportDeclaration({ + namedImports: ['HttpStatusDescriptionByCode'], + moduleSpecifier: './status-description', + }); + + helpersFile.addTypeAlias({ + isExported: true, + name: 'StatusInfo', + type: '{ code: number, message: string, success: boolean}', + }); + + helpersFile.addFunctions([ + { + name: 'isCodeOrTextValid', + returnType: 'boolean', + parameters: [ + { + name: 'codeOrText', + type: 'HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + ], + statements: [ + `return codeOrText in statusCodeToStatusTextMap || codeOrText in statusTextToStatusCodeMap;`, + ], + isExported: true, + docs: [ + { + description: + 'Returns whether the provided status code or status text is valid or not.', + tags: [ + { + tagName: 'example', + text: `isCodeOrTextValid(200) -> true +isCodeOrTextValid('OK') -> true +`, + }, + { + tagName: 'param', + text: 'codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + { + tagName: 'returns', + text: 'yesOrNo: boolean', + }, + ], + }, + ], + }, + { + name: 'getStatusInfo', + returnType: `StatusInfo`, + parameters: [ + { + name: 'codeOrText', + type: 'HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + ], + statements: [ + ` + if (!isCodeOrTextValid(codeOrText)) { + throw new Error(\`\${codeOrText} is not a known HTTP status code or status text.\`); + } + + const [code, message] = [ + statusTextToStatusCodeMap[codeOrText] || codeOrText as number, + statusCodeToStatusDescriptionMap[codeOrText as number] || statusTextToStatusDescriptionMap[codeOrText] + ] + + return { + code, + message, + success: code < 400 + }`, + ], + isExported: true, + docs: [ + { + description: + 'Returns an object containing information about the provided status code or status text.', + tags: [ + { + tagName: 'example', + text: `getStatusInfo(200) -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} +getStatusInfo('OK') -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} +`, + }, + { + tagName: 'param', + text: 'codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + { + tagName: 'returns', + text: 'StatusInfo: { code: number, message: string, success: boolean}', + }, + ], + }, + ], + }, + { + name: 'isStatusSuccessful', + returnType: 'boolean', + parameters: [ + { + name: 'codeOrText', + type: 'HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + ], + statements: [ + ` + try{ + return getStatusInfo(codeOrText).success; + } catch (e) { + return false; + }`, + ], + isExported: true, + docs: [ + { + description: + 'Returns whether the provided status code or status text is a successful status or not.', + tags: [ + { + tagName: 'example', + text: `isStatusSuccessful(200) -> true +isStatusSuccessful('OK') -> true +isStatusSuccessful(400) -> false +isStatusSuccessful('Bad request') -> false +`, + }, + { + tagName: 'param', + text: 'codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + { + tagName: 'returns', + text: 'successful: boolean', + }, + ], + }, + ], + }, + { + name: 'getSimpleStatusMessage', + returnType: 'string', + parameters: [ + { + name: 'codeOrText', + type: 'HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + ], + statements: [ + `const statusInfo = getStatusInfo(codeOrText) + return \`\${statusInfo.code} \${statusInfo.message.split(':')[0]}\`; + `, + ], + isExported: true, + docs: [ + { + description: + 'Returns a string containing the provided status code and simple message.', + tags: [ + { + tagName: 'example', + text: `getSimpleStatusMessage(200) -> 200 OK +getSimpleStatusMessage('OK') -> 200 OK +`, + }, + { + tagName: 'param', + text: 'codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + { + tagName: 'returns', + text: 'simpleStatusMessage: string', + }, + ], + }, + ], + }, + { + name: 'getStatusMessage', + returnType: 'string', + parameters: [ + { + name: 'codeOrText', + type: 'HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + ], + statements: [ + `const statusInfo = getStatusInfo(codeOrText) + return \`\${statusInfo.code} \${statusInfo.message}\`; + `, + ], + isExported: true, + docs: [ + { + description: + 'Returns a string containing the provided status code and message.', + tags: [ + { + tagName: 'example', + text: `getStatusMessage(200) -> 200 OK:The standard response for successful HTTP requests. +getStatusMessage('OK') -> 200 OK:The standard response for successful HTTP requests. +`, + }, + { + tagName: 'param', + text: 'codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode', + }, + { + tagName: 'returns', + text: 'statusMessage: string', + }, + ], + }, + ], + }, + { + name: 'getStatusCode', + returnType: 'HttpStatusCode', + parameters: [ + { + name: 'text', + type: 'HttpStatusText', + }, + ], + statements: [ + ` const code = statusTextToStatusCodeMap[\`\${text}\`] + if (!code) { + throw new Error(\`\${text} is not a known HTTP status text.\`); + } + return code;`, + ], + isExported: true, + docs: [ + { + description: `Returns the status code for the given http status text. +If the given http status text does not exist, undefined is returned.`, + tags: [ + { + tagName: 'example', + text: `getStatusCode('OK') -> 200`, + }, + { + tagName: 'param', + text: 'text: HttpStatusText', + }, + { + tagName: 'returns', + text: 'statusCode: HttpStatusCode', + }, + ], + }, + ], + }, + { + name: 'getStatusText', + returnType: 'string', + parameters: [ + { + name: 'code', + type: 'HttpStatusCode', + }, + ], + statements: [ + ` const text = statusCodeToStatusTextMap[\`\${code}\`] + if (!text) { + throw new Error(\`\${code} is not a known HTTP status code.\`); + } + return text;`, + ], + isExported: true, + docs: [ + { + description: `Returns the status text for the given http status code. +If the given http status code does not exist, undefined is returned.`, + tags: [ + { + tagName: 'example', + text: `getStatusCode('200') -> OK`, + }, + { + tagName: 'param', + text: 'code: HttpStatusCode', + }, + { + tagName: 'returns', + text: 'statusText: HttpStatusText', + }, + ], + }, + ], + }, + ]); + + helpersFile.insertStatements(0, comment); + helpersFile.formatText({ + ensureNewLineAtEndOfFile: true, + }); + + console.log(`Generated all helper files`); +}; diff --git a/scripts/typescript/generate/status.ts b/scripts/typescript/generate/status.ts new file mode 100644 index 0000000..c65b7bd --- /dev/null +++ b/scripts/typescript/generate/status.ts @@ -0,0 +1,190 @@ +/** + * 创建 以下 文件 + * status-code.ts + * status-text.ts + * status-description.ts + */ + +import { + Project, + StructureKind, + EnumMemberStructure, + OptionalKind, +} from 'ts-morph'; /* https://ts-morph.com/ */ +import { constantCase } from 'change-case'; + +interface HttpStatusCodeInfo { + statusCode: string; + statusText: string; + statusDescription: string; + statusComment: string; + rfcLink: string; +} + +type EnumType = 'constant' | 'code'; + +const generateStatusTextMembers = ( + httpStatusCodesInfos: HttpStatusCodeInfo[], + enumType: EnumType = 'constant' +): OptionalKind[] => + httpStatusCodesInfos + .map( + ( + { statusCode, statusText, statusDescription, statusComment, rfcLink }, + i + ) => { + const name = + enumType === 'code' ? `h${statusCode}` : constantCase(statusText); + return [ + { + name, + value: statusText, + docs: [ + `${name}: ${statusComment}\n${rfcLink}\n${statusDescription}`, + ], + }, + ]; + } + ) + .flat(); + +const generateStatusCodeMembers = ( + httpStatusCodesInfos: HttpStatusCodeInfo[], + enumType: EnumType = 'constant' +): OptionalKind[] => + httpStatusCodesInfos + .map( + ( + { statusCode, statusText, statusDescription, statusComment, rfcLink }, + i + ) => { + const name = + enumType === 'code' ? `h${statusCode}` : constantCase(statusText); + return [ + { + name, + value: Number(statusCode), + docs: [ + `${name}: ${statusComment}\n${rfcLink}\n${statusDescription}`, + ], + }, + ]; + } + ) + .flat(); + +const generateStatusDescriptionMembers = ( + httpStatusCodesInfos: HttpStatusCodeInfo[], + enumType: EnumType = 'constant' +): OptionalKind[] => + httpStatusCodesInfos + .map( + ( + { statusCode, statusText, statusDescription, statusComment, rfcLink }, + i + ) => { + const name = + enumType === 'code' ? `h${statusCode}` : constantCase(statusText); + return [ + { + name, + value: statusDescription, + docs: [ + `${name}: ${statusComment}\n${rfcLink}\n${statusDescription}`, + ], + }, + ]; + } + ) + .flat(); + +export const generatedMemberFiles = ( + project: Project, + httpStatusCodesInfos: HttpStatusCodeInfo[], + dir: string, + comment: string +) => { + console.log(`Generate ${dir} member files...`); + + const statusTextFile = project.createSourceFile( + `${dir}/status-text.ts`, + { + statements: [ + { + kind: StructureKind.Enum, + name: 'HttpStatusText', + isExported: true, + members: generateStatusTextMembers(httpStatusCodesInfos), + }, + { + kind: StructureKind.Enum, + name: 'HttpStatusTextByCode', + isExported: true, + members: generateStatusTextMembers(httpStatusCodesInfos, 'code'), + }, + ], + }, + { + overwrite: true, + } + ); + const statusCodeFile = project.createSourceFile( + `${dir}/status-code.ts`, + { + statements: [ + { + kind: StructureKind.Enum, + name: 'HttpStatusCode', + isExported: true, + members: generateStatusCodeMembers(httpStatusCodesInfos), + }, + { + kind: StructureKind.Enum, + name: 'HttpStatusCodeByCode', + isExported: true, + members: generateStatusCodeMembers(httpStatusCodesInfos, 'code'), + }, + ], + }, + { + overwrite: true, + } + ); + + const statusDescriptionFile = project.createSourceFile( + `${dir}/status-description.ts`, + { + statements: [ + { + kind: StructureKind.Enum, + name: 'HttpStatusDescription', + isExported: true, + members: generateStatusDescriptionMembers(httpStatusCodesInfos), + }, + { + kind: StructureKind.Enum, + name: 'HttpStatusDescriptionByCode', + isExported: true, + members: generateStatusDescriptionMembers( + httpStatusCodesInfos, + 'code' + ), + }, + ], + }, + { + overwrite: true, + } + ); + + [statusTextFile, statusCodeFile, statusDescriptionFile].forEach( + (sourceFile) => { + sourceFile.insertStatements(0, comment); + sourceFile.formatText({ + ensureNewLineAtEndOfFile: true, + }); + } + ); + + console.log(`Generated all member files`); +};