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

Skip to content

Commit a6bcdec

Browse files
committed
bpo-39509: Update HTTP status code to follow IANA
1 parent 58a4054 commit a6bcdec

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

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+
Update HTTP status code of the the http module to follow IANA: 103, 425
2+
Patch by Dong-hee Na.

0 commit comments

Comments
 (0)
0