diff --git a/Doc/library/http.rst b/Doc/library/http.rst index 5e1912716e5319..a0db5d7b25094a 100644 --- a/Doc/library/http.rst +++ b/Doc/library/http.rst @@ -80,7 +80,7 @@ Code Enum Name Details ``304`` ``NOT_MODIFIED`` HTTP/1.1 :rfc:`7232`, Section 4.1 ``305`` ``USE_PROXY`` HTTP/1.1 :rfc:`7231`, Section 6.4.5 ``307`` ``TEMPORARY_REDIRECT`` HTTP/1.1 :rfc:`7231`, Section 6.4.7 -``308`` ``PERMANENT_REDIRECT`` Permanent Redirect :rfc:`7238`, Section 3 (Experimental) +``308`` ``PERMANENT_REDIRECT`` HTTP Semantics :rfc:`9110`, Section 15.4.9 ``400`` ``BAD_REQUEST`` HTTP/1.1 :rfc:`7231`, Section 6.5.1 ``401`` ``UNAUTHORIZED`` HTTP/1.1 Authentication :rfc:`7235`, Section 3.1 ``402`` ``PAYMENT_REQUIRED`` HTTP/1.1 :rfc:`7231`, Section 6.5.2 @@ -94,14 +94,14 @@ Code Enum Name Details ``410`` ``GONE`` HTTP/1.1 :rfc:`7231`, Section 6.5.9 ``411`` ``LENGTH_REQUIRED`` HTTP/1.1 :rfc:`7231`, Section 6.5.10 ``412`` ``PRECONDITION_FAILED`` HTTP/1.1 :rfc:`7232`, Section 4.2 -``413`` ``REQUEST_ENTITY_TOO_LARGE`` HTTP/1.1 :rfc:`7231`, Section 6.5.11 +``413`` ``CONTENT_TOO_LARGE`` HTTP Semantics :rfc:`9110`, Section 15.5.14 ``414`` ``REQUEST_URI_TOO_LONG`` HTTP/1.1 :rfc:`7231`, Section 6.5.12 ``415`` ``UNSUPPORTED_MEDIA_TYPE`` HTTP/1.1 :rfc:`7231`, Section 6.5.13 ``416`` ``REQUESTED_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 ``418`` ``IM_A_TEAPOT`` HTCPCP/1.0 :rfc:`2324`, Section 2.3.2 -``421`` ``MISDIRECTED_REQUEST`` HTTP/2 :rfc:`7540`, Section 9.1.2 -``422`` ``UNPROCESSABLE_ENTITY`` WebDAV :rfc:`4918`, Section 11.2 +``421`` ``MISDIRECTED_REQUEST`` HTTP Semantics :rfc:`9110`, Section 15.5.20 +``422`` ``UNPROCESSABLE_CONTENT`` HTTP Semantics :rfc:`9110`, Section 15.5.21 ``423`` ``LOCKED`` WebDAV :rfc:`4918`, Section 11.3 ``424`` ``FAILED_DEPENDENCY`` WebDAV :rfc:`4918`, Section 11.4 ``425`` ``TOO_EARLY`` Using Early Data in HTTP :rfc:`8470` @@ -137,6 +137,11 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as .. versionadded:: 3.9 Added ``103 EARLY_HINTS``, ``418 IM_A_TEAPOT`` and ``425 TOO_EARLY`` status codes. +.. versionadded:: 3.12 + Updated ``413 REQUEST_ENTITY_TOO_LARGE`` and ``422 UNPROCESSABLE_ENTITY`` + to ``413 CONTENT_TOO_LARGE`` and ``422 UNPROCESSABLE_CONTENT``. Backward compatibility + of previous status codes in :mod:`http` module is preserved. + HTTP status category -------------------- diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index d982cb62ec2f4e..a79ee105baec36 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -372,6 +372,14 @@ sys with contributions from Gregory P. Smith [Google] and Mark Shannon in :gh:`96123`.) +http +---- + +* Updated ``413 REQUEST_ENTITY_TOO_LARGE`` and ``422 UNPROCESSABLE_ENTITY`` + to ``413 CONTENT_TOO_LARGE`` and ``422 UNPROCESSABLE_CONTENT``. This is + for applying :rfc:`9110`. Backward compatibility of previous status codes in + :mod:`http` module is preserved. (Contributed by Yeojin Kim in :gh:`102570`.) + Optimizations ============= diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py index e093a1fec4dffc..556c32320b3f64 100644 --- a/Lib/http/__init__.py +++ b/Lib/http/__init__.py @@ -22,6 +22,7 @@ class HTTPStatus: * RFC 2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) * RFC 8297: An HTTP Status Code for Indicating Hints * RFC 8470: Using Early Data in HTTP + * RFC 9110: HTTP Semantics """ def __new__(cls, value, phrase, description=''): obj = int.__new__(cls, value) @@ -115,8 +116,9 @@ def is_server_error(self): 'Client must specify Content-Length') PRECONDITION_FAILED = (412, 'Precondition Failed', 'Precondition in headers is false') - REQUEST_ENTITY_TOO_LARGE = (413, 'Request Entity Too Large', - 'Entity is too large') + CONTENT_TOO_LARGE = (413, 'Content Too Large', + 'Content is too large') + REQUEST_ENTITY_TOO_LARGE = CONTENT_TOO_LARGE # for backward compatibility REQUEST_URI_TOO_LONG = (414, 'Request-URI Too Long', 'URI is too long') UNSUPPORTED_MEDIA_TYPE = (415, 'Unsupported Media Type', @@ -130,7 +132,8 @@ def is_server_error(self): 'Server refuses to brew coffee because it is a teapot.') MISDIRECTED_REQUEST = (421, 'Misdirected Request', 'Server is not able to produce a response') - UNPROCESSABLE_ENTITY = 422, 'Unprocessable Entity' + UNPROCESSABLE_CONTENT = 422, 'Unprocessable Content' + UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT # for backward compatibility LOCKED = 423, 'Locked' FAILED_DEPENDENCY = 424, 'Failed Dependency' TOO_EARLY = 425, 'Too Early' diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 9ff6afcbadec54..1d23ba1150dbf6 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -633,8 +633,9 @@ def is_server_error(self): 'Client must specify Content-Length') PRECONDITION_FAILED = (412, 'Precondition Failed', 'Precondition in headers is false') - REQUEST_ENTITY_TOO_LARGE = (413, 'Request Entity Too Large', - 'Entity is too large') + CONTENT_TOO_LARGE = (413, 'Content Too Large', + 'Content is too large') + REQUEST_ENTITY_TOO_LARGE = CONTENT_TOO_LARGE # for backward compatibility REQUEST_URI_TOO_LONG = (414, 'Request-URI Too Long', 'URI is too long') UNSUPPORTED_MEDIA_TYPE = (415, 'Unsupported Media Type', @@ -648,7 +649,8 @@ def is_server_error(self): 'Server refuses to brew coffee because it is a teapot.') MISDIRECTED_REQUEST = (421, 'Misdirected Request', 'Server is not able to produce a response') - UNPROCESSABLE_ENTITY = 422, 'Unprocessable Entity' + UNPROCESSABLE_CONTENT = 422, 'Unprocessable Content' + UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT # for backward compatibility LOCKED = 423, 'Locked' FAILED_DEPENDENCY = 424, 'Failed Dependency' TOO_EARLY = 425, 'Too Early' @@ -1688,6 +1690,7 @@ def test_client_constants(self): 'GONE', 'LENGTH_REQUIRED', 'PRECONDITION_FAILED', + 'CONTENT_TOO_LARGE', 'REQUEST_ENTITY_TOO_LARGE', 'REQUEST_URI_TOO_LONG', 'UNSUPPORTED_MEDIA_TYPE', @@ -1695,6 +1698,7 @@ def test_client_constants(self): 'EXPECTATION_FAILED', 'IM_A_TEAPOT', 'MISDIRECTED_REQUEST', + 'UNPROCESSABLE_CONTENT', 'UNPROCESSABLE_ENTITY', 'LOCKED', 'FAILED_DEPENDENCY', diff --git a/Misc/NEWS.d/next/Library/2023-03-10-10-20-01.gh-issue-102247.uvsFqi.rst b/Misc/NEWS.d/next/Library/2023-03-10-10-20-01.gh-issue-102247.uvsFqi.rst new file mode 100644 index 00000000000000..2d9ddae8aebf6a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-03-10-10-20-01.gh-issue-102247.uvsFqi.rst @@ -0,0 +1,2 @@ +Update HTTP status codes in http package to match rfc9110. Patch by +Yeojin Kim