-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-102247: Update HTTP status codes in http package to match rfc9110 #102570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
944e2de
e4bdf25
14bc8ea
999e811
7757698
0273b0d
90bf421
8d70181
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the problems of removing this constant is that it will break end-user code. This is one example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if we decide to accept this change, we may need to add deprecation period rather than direct removing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we have to keep the old names as aliases for the new ones. I would continue to support them indefinitely, even -- deprecations and breaking things has a cost, and supporting a few extra constant names indefinitely is essentially free, so it's not worth spending our limited breakage budget on it. |
||
UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT # for backward compatibility | ||
LOCKED = 423, 'Locked' | ||
FAILED_DEPENDENCY = 424, 'Failed Dependency' | ||
TOO_EARLY = 425, 'Too Early' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,13 +1690,15 @@ def test_client_constants(self): | |
'GONE', | ||
'LENGTH_REQUIRED', | ||
'PRECONDITION_FAILED', | ||
'CONTENT_TOO_LARGE', | ||
'REQUEST_ENTITY_TOO_LARGE', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please maintain old constants |
||
'REQUEST_URI_TOO_LONG', | ||
'UNSUPPORTED_MEDIA_TYPE', | ||
'REQUESTED_RANGE_NOT_SATISFIABLE', | ||
'EXPECTATION_FAILED', | ||
'IM_A_TEAPOT', | ||
'MISDIRECTED_REQUEST', | ||
'UNPROCESSABLE_CONTENT', | ||
'UNPROCESSABLE_ENTITY', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
'LOCKED', | ||
'FAILED_DEPENDENCY', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Update HTTP status codes in http package to match rfc9110. Patch by | ||
Yeojin Kim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to notify the change with the versionchanged tag.