[Python-checkins] bpo-26589: Add http status code 451 (GH-15413)

Raymond Hettinger webhook-mailer at python.org
Fri Aug 23 13:19:20 EDT 2019


https://github.com/python/cpython/commit/8f080b09953a2d862de5c74edf414a54ea3dbea5
commit: 8f080b09953a2d862de5c74edf414a54ea3dbea5
branch: master
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-08-23T10:19:15-07:00
summary:

bpo-26589: Add http status code 451 (GH-15413)

files:
A Misc/NEWS.d/next/Library/2019-08-23-00-55-19.bpo-26589.M1xyxG.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 88d62cca3f90..8df14578de1f 100644
--- a/Doc/library/http.rst
+++ b/Doc/library/http.rst
@@ -106,6 +106,7 @@ Code    Enum Name                           Details
 ``428`` ``PRECONDITION_REQUIRED``           Additional HTTP Status Codes :rfc:`6585`
 ``429`` ``TOO_MANY_REQUESTS``               Additional HTTP Status Codes :rfc:`6585`
 ``431`` ``REQUEST_HEADER_FIELDS_TOO_LARGE`` Additional HTTP Status Codes :rfc:`6585`
+``451`` ``UNAVAILABLE_FOR_LEGAL_REASONS``   An HTTP Status Code to Report Legal Obstacles :rfc:`7725`
 ``500`` ``INTERNAL_SERVER_ERROR``           HTTP/1.1 :rfc:`7231`, Section 6.6.1
 ``501`` ``NOT_IMPLEMENTED``                 HTTP/1.1 :rfc:`7231`, Section 6.6.2
 ``502`` ``BAD_GATEWAY``                     HTTP/1.1 :rfc:`7231`, Section 6.6.3
@@ -126,3 +127,6 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
 
 .. versionchanged:: 3.7
    Added ``421 MISDIRECTED_REQUEST`` status code.
+
+.. versionadded:: 3.8
+   Added ``451 UNAVAILABLE_FOR_LEGAL_REASONS`` status code.
diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py
index e14a1eb074c5..350afe77926b 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 7725: An HTTP Status Code to Report Legal Obstacles
         * RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2)
     """
     def __new__(cls, value, phrase, description=''):
@@ -114,6 +115,10 @@ def __new__(cls, value, phrase, description=''):
         'Request Header Fields Too Large',
         'The server is unwilling to process the request because its header '
         'fields are too large')
+    UNAVAILABLE_FOR_LEGAL_REASONS = (451,
+        'Unavailable For Legal Reasons',
+        'The server is denying access to the '
+        'resource as a consequence of a legal demand')
 
     # server errors
     INTERNAL_SERVER_ERROR = (500, 'Internal Server Error',
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 656932fbaab7..1121224da443 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1401,6 +1401,7 @@ def test_client_constants(self):
             'PRECONDITION_REQUIRED',
             'TOO_MANY_REQUESTS',
             'REQUEST_HEADER_FIELDS_TOO_LARGE',
+            'UNAVAILABLE_FOR_LEGAL_REASONS',
             'INTERNAL_SERVER_ERROR',
             'NOT_IMPLEMENTED',
             'BAD_GATEWAY',
diff --git a/Misc/NEWS.d/next/Library/2019-08-23-00-55-19.bpo-26589.M1xyxG.rst b/Misc/NEWS.d/next/Library/2019-08-23-00-55-19.bpo-26589.M1xyxG.rst
new file mode 100644
index 000000000000..ef132dcceb2c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-08-23-00-55-19.bpo-26589.M1xyxG.rst
@@ -0,0 +1,2 @@
+Added a new status code to the http module: 451
+UNAVAILABLE_FOR_LEGAL_REASONS



More information about the Python-checkins mailing list