Skip to content

Commit 52ad72d

Browse files
vmspberkerpeksag
authored andcommitted
bpo-30553: Add status code 421 to http.HTTPStatus (pythonGH-2589)
1 parent bdf4298 commit 52ad72d

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

Doc/library/http.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Code Enum Name Details
9898
``415`` ``UNSUPPORTED_MEDIA_TYPE`` HTTP/1.1 :rfc:`7231`, Section 6.5.13
9999
``416`` ``REQUEST_RANGE_NOT_SATISFIABLE`` HTTP/1.1 Range Requests :rfc:`7233`, Section 4.4
100100
``417`` ``EXPECTATION_FAILED`` HTTP/1.1 :rfc:`7231`, Section 6.5.14
101+
``421`` ``MISDIRECTED_REQUEST`` HTTP/2 :rfc:`7540`, Section 9.1.2
101102
``422`` ``UNPROCESSABLE_ENTITY`` WebDAV :rfc:`4918`, Section 11.2
102103
``423`` ``LOCKED`` WebDAV :rfc:`4918`, Section 11.3
103104
``424`` ``FAILED_DEPENDENCY`` WebDAV :rfc:`4918`, Section 11.4
@@ -122,3 +123,6 @@ In order to preserve backwards compatibility, enum values are also present
122123
in the :mod:`http.client` module in the form of constants. The enum name is
123124
equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
124125
``http.client.OK``).
126+
127+
.. versionchanged:: 3.7
128+
Added ``421 MISDIRECTED_REQUEST`` status code.

Lib/http/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class HTTPStatus(IntEnum):
1515
* RFC 7238: Permanent Redirect
1616
* RFC 2295: Transparent Content Negotiation in HTTP
1717
* RFC 2774: An HTTP Extension Framework
18+
* RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2)
1819
"""
1920
def __new__(cls, value, phrase, description=''):
2021
obj = int.__new__(cls, value)
@@ -98,6 +99,8 @@ def __new__(cls, value, phrase, description=''):
9899
'Cannot satisfy request range')
99100
EXPECTATION_FAILED = (417, 'Expectation Failed',
100101
'Expect condition could not be satisfied')
102+
MISDIRECTED_REQUEST = (421, 'Misdirected Request',
103+
'Server is not able to produce a response')
101104
UNPROCESSABLE_ENTITY = 422, 'Unprocessable Entity'
102105
LOCKED = 423, 'Locked'
103106
FAILED_DEPENDENCY = 424, 'Failed Dependency'

Lib/test/test_httplib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ def test_client_constants(self):
13541354
'UNSUPPORTED_MEDIA_TYPE',
13551355
'REQUESTED_RANGE_NOT_SATISFIABLE',
13561356
'EXPECTATION_FAILED',
1357+
'MISDIRECTED_REQUEST',
13571358
'UNPROCESSABLE_ENTITY',
13581359
'LOCKED',
13591360
'FAILED_DEPENDENCY',
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add HTTP/2 status code 421 (Misdirected Request) to
2+
:class:`http.HTTPStatus`. Patch by Vitor Pereira.

0 commit comments

Comments
 (0)