Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
60 changes: 57 additions & 3 deletions codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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."
Expand All @@ -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."
}
}
]
]
38 changes: 37 additions & 1 deletion src/reason-phrases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
38 changes: 37 additions & 1 deletion src/status-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
16 changes: 14 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ export const statusCodeToReasonPhrase: Record<string, string> = {
"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<string, number> = {
"Accepted": 202,
Expand Down Expand Up @@ -117,5 +123,11 @@ export const reasonPhraseToStatusCode: Record<string, number> = {
"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
};