Skip to content

Commit

Permalink
Add rfc9110 status code texts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mbeijen committed Apr 17, 2024
1 parent 4b85e6c commit 6f500a2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions httpx/_status_codes.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand All @@ -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:
Expand Down

0 comments on commit 6f500a2

Please sign in to comment.