From 6f500a2c1afd200a0a3011a562d4b3c6cb023067 Mon Sep 17 00:00:00 2001 From: "Michiel W. Beijen" Date: Wed, 17 Apr 2024 19:54:06 +0200 Subject: [PATCH] Add rfc9110 status code texts Implement updated wording from RFC9110 for status code constants. We keep the old constants around and map them to the new wording for backwards compatibility --- httpx/_status_codes.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/httpx/_status_codes.py b/httpx/_status_codes.py index 133a6231a5..93c8693e24 100644 --- a/httpx/_status_codes.py +++ b/httpx/_status_codes.py @@ -10,12 +10,12 @@ class codes(IntEnum): Status codes from the following RFCs are all observed: - * RFC 7231: Hypertext Transfer Protocol (HTTP/1.1), obsoletes 2616 + * RFC 9110: HTTP Semantics + obsoletes 7231, which obsoletes 2616. Obsoletes 7238 * RFC 6585: Additional HTTP Status Codes * RFC 3229: Delta encoding in HTTP * RFC 4918: HTTP Extensions for WebDAV, obsoletes 2518 * RFC 5842: Binding Extensions to WebDAV - * RFC 7238: Permanent Redirect * RFC 2295: Transparent Content Negotiation in HTTP * RFC 2774: An HTTP Extension Framework * RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2) @@ -126,14 +126,14 @@ def is_error(cls, value: int) -> bool: GONE = 410, "Gone" LENGTH_REQUIRED = 411, "Length Required" PRECONDITION_FAILED = 412, "Precondition Failed" - REQUEST_ENTITY_TOO_LARGE = 413, "Request Entity Too Large" - REQUEST_URI_TOO_LONG = 414, "Request-URI Too Long" + CONTENT_TOO_LARGE = 413, "Content Too Large" + URI_TOO_LONG = 414, "URI Too Long" UNSUPPORTED_MEDIA_TYPE = 415, "Unsupported Media Type" - REQUESTED_RANGE_NOT_SATISFIABLE = 416, "Requested Range Not Satisfiable" + RANGE_NOT_SATISFIABLE = 416, "Range Not Satisfiable" EXPECTATION_FAILED = 417, "Expectation Failed" IM_A_TEAPOT = 418, "I'm a teapot" MISDIRECTED_REQUEST = 421, "Misdirected Request" - UNPROCESSABLE_ENTITY = 422, "Unprocessable Entity" + UNPROCESSABLE_CONTENT = 422, "Unprocessable Content" LOCKED = 423, "Locked" FAILED_DEPENDENCY = 424, "Failed Dependency" TOO_EARLY = 425, "Too Early" @@ -156,6 +156,11 @@ def is_error(cls, value: int) -> bool: NOT_EXTENDED = 510, "Not Extended" NETWORK_AUTHENTICATION_REQUIRED = 511, "Network Authentication Required" + # for backwards compatibility, keep the old constants around + REQUEST_ENTITY_TOO_LARGE = CONTENT_TOO_LARGE + REQUEST_URI_TOO_LONG = URI_TOO_LONG + REQUESTED_RANGE_NOT_SATISFIABLE = RANGE_NOT_SATISFIABLE + UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT # Include lower-case styles for `requests` compatibility. for code in codes: