Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f080b0

Browse files
authored
bpo-26589: Add http status code 451 (GH-15413)
1 parent 120b707 commit 8f080b0

4 files changed

Lines changed: 12 additions & 0 deletions

File tree

Doc/library/http.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Code Enum Name Details
106106
``428`` ``PRECONDITION_REQUIRED`` Additional HTTP Status Codes :rfc:`6585`
107107
``429`` ``TOO_MANY_REQUESTS`` Additional HTTP Status Codes :rfc:`6585`
108108
``431`` ``REQUEST_HEADER_FIELDS_TOO_LARGE`` Additional HTTP Status Codes :rfc:`6585`
109+
``451`` ``UNAVAILABLE_FOR_LEGAL_REASONS`` An HTTP Status Code to Report Legal Obstacles :rfc:`7725`
109110
``500`` ``INTERNAL_SERVER_ERROR`` HTTP/1.1 :rfc:`7231`, Section 6.6.1
110111
``501`` ``NOT_IMPLEMENTED`` HTTP/1.1 :rfc:`7231`, Section 6.6.2
111112
``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
126127

127128
.. versionchanged:: 3.7
128129
Added ``421 MISDIRECTED_REQUEST`` status code.
130+
131+
.. versionadded:: 3.8
132+
Added ``451 UNAVAILABLE_FOR_LEGAL_REASONS`` status code.

Lib/http/__init__.py

Lines changed: 5 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 7725: An HTTP Status Code to Report Legal Obstacles
1819
* RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2)
1920
"""
2021
def __new__(cls, value, phrase, description=''):
@@ -114,6 +115,10 @@ def __new__(cls, value, phrase, description=''):
114115
'Request Header Fields Too Large',
115116
'The server is unwilling to process the request because its header '
116117
'fields are too large')
118+
UNAVAILABLE_FOR_LEGAL_REASONS = (451,
119+
'Unavailable For Legal Reasons',
120+
'The server is denying access to the '
121+
'resource as a consequence of a legal demand')
117122

118123
# server errors
119124
INTERNAL_SERVER_ERROR = (500, 'Internal Server Error',

Lib/test/test_httplib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ def test_client_constants(self):
14011401
'PRECONDITION_REQUIRED',
14021402
'TOO_MANY_REQUESTS',
14031403
'REQUEST_HEADER_FIELDS_TOO_LARGE',
1404+
'UNAVAILABLE_FOR_LEGAL_REASONS',
14041405
'INTERNAL_SERVER_ERROR',
14051406
'NOT_IMPLEMENTED',
14061407
'BAD_GATEWAY',
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added a new status code to the http module: 451
2+
UNAVAILABLE_FOR_LEGAL_REASONS

0 commit comments

Comments
 (0)