From e912d31fb214c80871373d159406cd7756a4e900 Mon Sep 17 00:00:00 2001 From: ishwardatt <89002840+ishwardatt@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:31:45 +0530 Subject: [PATCH 1/2] added cloudflare status codes --- codes.json | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/codes.json b/codes.json index fdb3111..0a2ae6d 100644 --- a/codes.json +++ b/codes.json @@ -165,7 +165,7 @@ "code": 420, "phrase": "Method Failure", "constant": "METHOD_FAILURE", - "isDeprecated": true, + "isDeprecated": true, "comment": { "doc": "Official Documentation @ https://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt", "description": "A deprecated response used by the Spring Framework when a method has failed." @@ -510,7 +510,7 @@ "code": 305, "phrase": "Use Proxy", "constant": "USE_PROXY", - "isDeprecated": true, + "isDeprecated": true, "comment": { "doc": "Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.4.6", "description": "Was defined in a previous version of the HTTP specification to indicate that a requested response must be accessed by a proxy. It has been deprecated due to security concerns regarding in-band configuration of a proxy." @@ -525,5 +525,59 @@ "doc": "Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7540#section-9.1.2", "description": "Defined in the specification of HTTP/2 to indicate that a server is not able to produce a response for the combination of scheme and authority that are included in the request URI." } + }, + { + "code": 521, + "phrase": "Web Server Is Down", + "constant": "WEB_SERVER_IS_DOWN", + "comment": { + "doc": "Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-521-web-server-is-down", + "description": "The origin server has refused the connection from Cloudflare." + } + }, + { + "code": 522, + "phrase": "Connection Timed Out", + "constant": "CONNECTION_TIMED_OUT", + "comment": { + "doc": "Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-522-connection-timed-out", + "description": "Cloudflare could not negotiate a TCP handshake with the origin server." + } + }, + { + "code": 523, + "phrase": "Origin Is Unreachable", + "constant": "ORIGIN_IS_UNREACHABLE", + "comment": { + "doc": "Cloudflare-specific HTTP error code.Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-523-origin-is-unreachable", + "description": "Cloudflare could not reach the origin server; for example, if the DNS records for the origin server are incorrect." + } + }, + { + "code": 524, + "phrase": "A Timeout Occurred", + "constant": "A_TIMEOUT_OCCURRED", + "comment": { + "doc": "Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-524-a-timeout-occurred", + "description": "Cloudflare successfully connected to the origin server, but the origin did not respond within the configured timeout period." + } + }, + { + "code": 525, + "phrase": "SSL Handshake Failed", + "constant": "SSL_HANDSHAKE_FAILED", + "comment": { + "doc": "Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-525-ssl-handshake-failed", + "description": "Cloudflare could not negotiate a SSL/TLS handshake with the origin server." + } + }, + { + "code": 526, + "phrase": "Invalid SSL Certificate", + "constant": "INVALID_SSL_CERTIFICATE", + "comment": { + "doc": "Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-526-invalid-ssl-certificate", + "description": "Cloudflare could not validate the SSL certificate presented by the origin server." + } } -] +] \ No newline at end of file From 170eef9f1ac5cc0a33886c8e6f824e197e8b20b4 Mon Sep 17 00:00:00 2001 From: ishwardatt <89002840+ishwardatt@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:39:30 +0530 Subject: [PATCH 2/2] updated reason-phrases, status-codes and utils --- README.md | 6 ++++++ src/reason-phrases.ts | 38 +++++++++++++++++++++++++++++++++++++- src/status-codes.ts | 38 +++++++++++++++++++++++++++++++++++++- src/utils.ts | 16 ++++++++++++++-- 4 files changed, 94 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 485e812..3a7dcac 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,12 @@ response | 505 | HTTP_VERSION_NOT_SUPPORTED | HTTP Version Not Supported | | 507 | INSUFFICIENT_STORAGE | Insufficient Storage | | 511 | NETWORK_AUTHENTICATION_REQUIRED | Network Authentication Required | +| 521 | WEB_SERVER_IS_DOWN | Web Server Is Down | +| 522 | CONNECTION_TIMED_OUT | Connection Timed Out | +| 523 | ORIGIN_IS_UNREACHABLE | Origin Is Unreachable | +| 524 | A_TIMEOUT_OCCURRED | A Timeout Occurred | +| 525 | SSL_HANDSHAKE_FAILED | SSL Handshake Failed | +| 526 | INVALID_SSL_CERTIFICATE | Invalid SSL Certificate | ## Migrating from v1.x.x diff --git a/src/reason-phrases.ts b/src/reason-phrases.ts index 1ecb83e..1a04dd0 100644 --- a/src/reason-phrases.ts +++ b/src/reason-phrases.ts @@ -353,5 +353,41 @@ export enum ReasonPhrases { * * Defined in the specification of HTTP/2 to indicate that a server is not able to produce a response for the combination of scheme and authority that are included in the request URI. */ - MISDIRECTED_REQUEST = "Misdirected Request" + MISDIRECTED_REQUEST = "Misdirected Request", + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-521-web-server-is-down + * + * The origin server has refused the connection from Cloudflare. + */ + WEB_SERVER_IS_DOWN = "Web Server Is Down", + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-522-connection-timed-out + * + * Cloudflare could not negotiate a TCP handshake with the origin server. + */ + CONNECTION_TIMED_OUT = "Connection Timed Out", + /** + * Cloudflare-specific HTTP error code.Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-523-origin-is-unreachable + * + * Cloudflare could not reach the origin server; for example, if the DNS records for the origin server are incorrect. + */ + ORIGIN_IS_UNREACHABLE = "Origin Is Unreachable", + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-524-a-timeout-occurred + * + * Cloudflare successfully connected to the origin server, but the origin did not respond within the configured timeout period. + */ + A_TIMEOUT_OCCURRED = "A Timeout Occurred", + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-525-ssl-handshake-failed + * + * Cloudflare could not negotiate a SSL/TLS handshake with the origin server. + */ + SSL_HANDSHAKE_FAILED = "SSL Handshake Failed", + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-526-invalid-ssl-certificate + * + * Cloudflare could not validate the SSL certificate presented by the origin server. + */ + INVALID_SSL_CERTIFICATE = "Invalid SSL Certificate" } diff --git a/src/status-codes.ts b/src/status-codes.ts index c20c323..f3bb5d4 100644 --- a/src/status-codes.ts +++ b/src/status-codes.ts @@ -353,5 +353,41 @@ export enum StatusCodes { * * The 511 status code indicates that the client needs to authenticate to gain network access. */ - NETWORK_AUTHENTICATION_REQUIRED = 511 + NETWORK_AUTHENTICATION_REQUIRED = 511, + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-521-web-server-is-down + * + * The origin server has refused the connection from Cloudflare. + */ + WEB_SERVER_IS_DOWN = 521, + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-522-connection-timed-out + * + * Cloudflare could not negotiate a TCP handshake with the origin server. + */ + CONNECTION_TIMED_OUT = 522, + /** + * Cloudflare-specific HTTP error code.Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-523-origin-is-unreachable + * + * Cloudflare could not reach the origin server; for example, if the DNS records for the origin server are incorrect. + */ + ORIGIN_IS_UNREACHABLE = 523, + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-524-a-timeout-occurred + * + * Cloudflare successfully connected to the origin server, but the origin did not respond within the configured timeout period. + */ + A_TIMEOUT_OCCURRED = 524, + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-525-ssl-handshake-failed + * + * Cloudflare could not negotiate a SSL/TLS handshake with the origin server. + */ + SSL_HANDSHAKE_FAILED = 525, + /** + * Cloudflare-specific HTTP error code. Official Documentation @ https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/#error-526-invalid-ssl-certificate + * + * Cloudflare could not validate the SSL certificate presented by the origin server. + */ + INVALID_SSL_CERTIFICATE = 526 } diff --git a/src/utils.ts b/src/utils.ts index d70f02d..f73f21d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -57,7 +57,13 @@ export const statusCodeToReasonPhrase: Record = { "422": "Unprocessable Entity", "415": "Unsupported Media Type", "305": "Use Proxy", - "421": "Misdirected Request" + "421": "Misdirected Request", + "521": "Web Server Is Down", + "522": "Connection Timed Out", + "523": "Origin Is Unreachable", + "524": "A Timeout Occurred", + "525": "SSL Handshake Failed", + "526": "Invalid SSL Certificate" }; export const reasonPhraseToStatusCode: Record = { "Accepted": 202, @@ -117,5 +123,11 @@ export const reasonPhraseToStatusCode: Record = { "Unprocessable Entity": 422, "Unsupported Media Type": 415, "Use Proxy": 305, - "Misdirected Request": 421 + "Misdirected Request": 421, + "Web Server Is Down": 521, + "Connection Timed Out": 522, + "Origin Is Unreachable": 523, + "A Timeout Occurred": 524, + "SSL Handshake Failed": 525, + "Invalid SSL Certificate": 526 };