[Python-checkins] bpo-30553: Add status code 421 to http.HTTPStatus (GH-2589)

Berker Peksag webhook-mailer at python.org
Thu Oct 26 14:49:22 EDT 2017


https://github.com/python/cpython/commit/52ad72dd0a5a56414cc29b7c9b03259169825f35
commit: 52ad72dd0a5a56414cc29b7c9b03259169825f35
branch: master
author: Vitor Pereira <vmsousapereira at gmail.com>
committer: Berker Peksag <berker.peksag at gmail.com>
date: 2017-10-26T21:49:19+03:00
summary:

bpo-30553: Add status code 421 to http.HTTPStatus (GH-2589)

files:
A Misc/NEWS.d/next/Library/2017-07-05-14-48-26.bpo-30553.Oupsxo.rst
M Doc/library/http.rst
M Lib/http/__init__.py
M Lib/test/test_httplib.py

diff --git a/Doc/library/http.rst b/Doc/library/http.rst
index be661c5e8c2..7c34004a3ae 100644
--- a/Doc/library/http.rst
+++ b/Doc/library/http.rst
@@ -98,6 +98,7 @@ Code    Enum Name                           Details
 ``415`` ``UNSUPPORTED_MEDIA_TYPE``          HTTP/1.1 :rfc:`7231`, Section 6.5.13
 ``416`` ``REQUEST_RANGE_NOT_SATISFIABLE``   HTTP/1.1 Range Requests :rfc:`7233`, Section 4.4
 ``417`` ``EXPECTATION_FAILED``              HTTP/1.1 :rfc:`7231`, Section 6.5.14
+``421`` ``MISDIRECTED_REQUEST``             HTTP/2 :rfc:`7540`, Section 9.1.2
 ``422`` ``UNPROCESSABLE_ENTITY``            WebDAV :rfc:`4918`, Section 11.2
 ``423`` ``LOCKED``                          WebDAV :rfc:`4918`, Section 11.3
 ``424`` ``FAILED_DEPENDENCY``               WebDAV :rfc:`4918`, Section 11.4
@@ -122,3 +123,6 @@ In order to preserve backwards compatibility, enum values are also present
 in the :mod:`http.client` module in the form of constants. The enum name is
 equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
 ``http.client.OK``).
+
+.. versionchanged:: 3.7
+   Added ``421 MISDIRECTED_REQUEST`` status code.
diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py
index d4334cc88f9..aed94a58504 100644
--- a/Lib/http/__init__.py
+++ b/Lib/http/__init__.py
@@ -15,6 +15,7 @@ class HTTPStatus(IntEnum):
         * 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)
     """
     def __new__(cls, value, phrase, description=''):
         obj = int.__new__(cls, value)
@@ -98,6 +99,8 @@ def __new__(cls, value, phrase, description=''):
         'Cannot satisfy request range')
     EXPECTATION_FAILED = (417, 'Expectation Failed',
         'Expect condition could not be satisfied')
+    MISDIRECTED_REQUEST = (421, 'Misdirected Request',
+        'Server is not able to produce a response')
     UNPROCESSABLE_ENTITY = 422, 'Unprocessable Entity'
     LOCKED = 423, 'Locked'
     FAILED_DEPENDENCY = 424, 'Failed Dependency'
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index bec994ed293..5591f1d9e3d 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1354,6 +1354,7 @@ def test_client_constants(self):
             'UNSUPPORTED_MEDIA_TYPE',
             'REQUESTED_RANGE_NOT_SATISFIABLE',
             'EXPECTATION_FAILED',
+            'MISDIRECTED_REQUEST',
             'UNPROCESSABLE_ENTITY',
             'LOCKED',
             'FAILED_DEPENDENCY',
diff --git a/Misc/NEWS.d/next/Library/2017-07-05-14-48-26.bpo-30553.Oupsxo.rst b/Misc/NEWS.d/next/Library/2017-07-05-14-48-26.bpo-30553.Oupsxo.rst
new file mode 100644
index 00000000000..51f0d5b9922
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2017-07-05-14-48-26.bpo-30553.Oupsxo.rst
@@ -0,0 +1,2 @@
+Add HTTP/2 status code 421 (Misdirected Request) to
+:class:`http.HTTPStatus`. Patch by Vitor Pereira.



More information about the Python-checkins mailing list