8000 bpo-39509: Update HTTP status code to follow IANA (GH-18294) · python/cpython@da52be4 · GitHub
[go: up one dir, main page]

Skip to content

Commit da52be4

Browse files
authored
bpo-39509: Update HTTP status code to follow IANA (GH-18294)
Add status codes 103 EARLY_HINTS and 425 TOO_EARLY.
1 parent b81f40f commit da52be4

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

Doc/library/http.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Code Enum Name Details
6262
``100`` ``CONTINUE`` HTTP/1.1 :rfc:`7231`, Section 6.2.1
6363
``101`` ``SWITCHING_PROTOCOLS`` HTTP/1.1 :rfc:`7231`, Section 6.2.2
6464
``102`` ``PROCESSING`` WebDAV :rfc:`2518`, Section 10.1
65+
``103`` ``EARLY_HINTS`` An HTTP Status Code for Indicating Hints :rfc:`8297`
6566
``200`` ``OK`` HTTP/1.1 :rfc:`7231`, Section 6.3.1
6667
``201`` ``CREATED`` HTTP/1.1 :rfc:`7231`, Section 6.3.2
6768
``202`` ``ACCEPTED`` HTTP/1.1 :rfc:`7231`, Section 6.3.3
@@ -102,6 +103,7 @@ Code Enum Name Details
102103
``422`` ``UNPROCESSABLE_ENTITY`` WebDAV :rfc:`4918`, Section 11.2
103104
``423`` ``LOCKED`` WebDAV :rfc:`4918`, Section 11.3
104105
``424`` ``FAILED_DEPENDENCY`` WebDAV :rfc:`4918`, Section 11.4
106+
``425`` ``TOO_EARLY`` Using Early Data in HTTP :rfc:`8470`
105107
``426`` ``UPGRADE_REQUIRED`` HTTP/1.1 :rfc:`7231`, Section 6.5.15
106108
``428`` ``PRECONDITION_REQUIRED`` Additional HTTP Status Codes :rfc:`6585`
107109
``429`` ``TOO_MANY_REQUESTS`` Additional HTTP Status Codes :rfc:`6585`
@@ -130,3 +132,6 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
130132

131133
.. versionadded:: 3.8
132134
Added ``451 UNAVAILABLE_FOR_LEGAL_REASONS`` status code.
135+
136+
.. versionadded:: 3.9
137+
Added ``103 EARLY_HINTS`` and ``425 TOO_EARLY`` status codes.

Doc/whatsnew/3.9.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ Added a new function :func:`gc.is_finalized` to check if an object has been
232232
finalized by the garbage collector. (Contributed by Pablo Galindo in
233233
:issue:`39322`.)
234234

235+
http
236+
----
237+
238+
HTTP status codes ``103 EARLY_HINTS`` and ``425 TOO_EARLY`` are added to
239+
:class:`http.HTTPStatus`. (Contributed by Dong-hee Na in :issue:`39509`.)
240+
235241
imaplib
236242
-------
237243

Lib/http/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class HTTPStatus(IntEnum):
1717
* RFC 2774: An HTTP Extension Framework
1818
* RFC 7725: An HTTP Status Code to Report Legal Obstacles
1919
* RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2)
20+
* RFC 8297: An HTTP Status Code for Indicating Hints
21+
* RFC 8470: Using Early Data in HTTP
2022
"""
2123
def __new__(cls, value, phrase, description=''):
2224
obj = int.__new__(cls, value)
@@ -31,6 +33,7 @@ def __new__(cls, value, phrase, description=''):
3133
SWITCHING_PROTOCOLS = (101, 'Switching Protocols',
3234
'Switching to new protocol; obey Upgrade header')
3335
PROCESSING = 102, 'Processing'
36+
EARLY_HINTS = 103, 'Early Hints'
3437

3538
# success
3639
OK = 200, 'OK', 'Request fulfilled, document follows'
@@ -105,6 +108,7 @@ def __new__(cls, value, phrase, description=''):
105108
UNPROCESSABLE_ENTITY = 422, 'Unprocessable Entity'
106109
LOCKED = 423, 'Locked'
107110
FAILED_DEPENDENCY = 424, 'Failed Dependency'
111+
TOO_EARLY = 425, 'Too Early'
108112
UPGRADE_REQUIRED = 426, 'Upgrade Required'
109113
PRECONDITION_REQUIRED = (428, 'Precondition Required',
110114
'The origin server requires the request to be conditional')

Lib/test/test_httplib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,8 @@ def test_client_constants(self):
14401440
'INSUFFICIENT_STORAGE',
14411441
'NOT_EXTENDED',
14421442
'NETWORK_AUTHENTICATION_REQUIRED',
1443+
'EARLY_HINTS',
1444+
'TOO_EARLY'
14431445
]
14441446
for const in expected:
14451447
with self.subTest(constant=const):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HTTP status codes ``103 EARLY_HINTS`` and ``425 TOO_EARLY`` are added to
2+
:class:`http.HTTPStatus`. Patch by Dong-hee Na.

0 commit comments

Comments
 (0)
0