From e349e32e61cb9789c2ae544c12215dfd3e8afc9e Mon Sep 17 00:00:00 2001 From: Christian Pedersen Date: Fri, 19 Jun 2015 11:23:57 +0200 Subject: [PATCH 1/2] Add HTTP response codes Implementation of response codes from http://tools.ietf.org/html/rfc6585 --- falcon/status_codes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/falcon/status_codes.py b/falcon/status_codes.py index 568cd81ea..6b9dda27f 100644 --- a/falcon/status_codes.py +++ b/falcon/status_codes.py @@ -90,6 +90,12 @@ HTTP_IM_A_TEAPOT = HTTP_418 HTTP_426 = '426 Upgrade Required' HTTP_UPGRADE_REQUIRED = HTTP_426 +HTTP_428 = '428 Precondition Required' +HTTP_PRECONDITION_REQUIRED = HTTP_428 +HTTP_429 = '429 Too Many Requests' +HTTP_TOO_MANY_REQUESTS = HTTP_429 +HTTP_431 = '431 Request Header Fields Too Large' +HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = HTTP_431 HTTP_500 = '500 Internal Server Error' HTTP_INTERNAL_SERVER_ERROR = HTTP_500 @@ -103,6 +109,8 @@ HTTP_GATEWAY_TIMEOUT = HTTP_504 HTTP_505 = '505 HTTP Version not supported' HTTP_HTTP_VERSION_NOT_SUPPORTED = HTTP_505 +HTTP_511 = '511 Network Authentication Required' +HTTP_NETWORK_AUTHENTICATION_REQUIRED = HTTP_511 # 70X - Inexcusable HTTP_701 = '701 Meh' From 702b7a7f7b254749eaf8d62023ab5b9f384259a5 Mon Sep 17 00:00:00 2001 From: Christian Pedersen Date: Fri, 19 Jun 2015 11:29:42 +0200 Subject: [PATCH 2/2] Document new response codes --- doc/api/status.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/api/status.rst b/doc/api/status.rst index 9501c8e6d..9e72add2c 100644 --- a/doc/api/status.rst +++ b/doc/api/status.rst @@ -96,6 +96,9 @@ string objects that must be created when preparing responses. HTTP_EXPECTATION_FAILED = HTTP_417 HTTP_IM_A_TEAPOT = HTTP_418 HTTP_UPGRADE_REQUIRED = HTTP_426 + HTTP_PRECONDITION_REQUIRED = HTTP_428 + HTTP_TOO_MANY_REQUESTS = HTTP_429 + HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = HTTP_431 HTTP_400 = '400 Bad Request' HTTP_401 = '401 Unauthorized' # <-- Really means "unauthenticated" @@ -117,6 +120,9 @@ string objects that must be created when preparing responses. HTTP_417 = '417 Expectation Failed' HTTP_418 = "418 I'm a teapot" HTTP_426 = '426 Upgrade Required' + HTTP_428 = '428 Precondition Required' + HTTP_429 = '429 Too Many Requests' + HTTP_431 = '431 Request Header Fields Too Large' 5xx Server Error ---------------- @@ -129,6 +135,7 @@ string objects that must be created when preparing responses. HTTP_SERVICE_UNAVAILABLE = HTTP_503 HTTP_GATEWAY_TIMEOUT = HTTP_504 HTTP_HTTP_VERSION_NOT_SUPPORTED = HTTP_505 + HTTP_NETWORK_AUTHENTICATION_REQUIRED = HTTP_511 HTTP_500 = '500 Internal Server Error' HTTP_501 = '501 Not Implemented' @@ -136,3 +143,4 @@ string objects that must be created when preparing responses. HTTP_503 = '503 Service Unavailable' HTTP_504 = '504 Gateway Time-out' HTTP_505 = '505 HTTP Version not supported' + HTTP_511 = '511 Network Authentication Required'