Add RFC 9110 status code constants#1069
Conversation
Merging this PR will degrade performance by 10.08%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/httpx2/httpx2/_status_codes.py">
<violation number="1" location="src/httpx2/httpx2/_status_codes.py:160">
P3: The alias definitions preserve the original UPPERCASE constant names, but `codes.request_entity_too_large` etc. (the lowercase `requests`-compatible forms) are silently dropped because the `for code in codes:` loop only iterates over canonical members, not aliases. Anyone migrating from `httpx.codes.request_entity_too_large` will get an `AttributeError`. Consider preserving these too, either via explicit `setattr` calls after the loop or by adding them as additional alias entries.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| NETWORK_AUTHENTICATION_REQUIRED = 511, "Network Authentication Required" | ||
|
|
||
| # for backwards compatibility, keep the old constants around | ||
| REQUEST_ENTITY_TOO_LARGE = CONTENT_TOO_LARGE |
There was a problem hiding this comment.
P3: The alias definitions preserve the original UPPERCASE constant names, but codes.request_entity_too_large etc. (the lowercase requests-compatible forms) are silently dropped because the for code in codes: loop only iterates over canonical members, not aliases. Anyone migrating from httpx.codes.request_entity_too_large will get an AttributeError. Consider preserving these too, either via explicit setattr calls after the loop or by adding them as additional alias entries.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/httpx2/httpx2/_status_codes.py, line 160:
<comment>The alias definitions preserve the original UPPERCASE constant names, but `codes.request_entity_too_large` etc. (the lowercase `requests`-compatible forms) are silently dropped because the `for code in codes:` loop only iterates over canonical members, not aliases. Anyone migrating from `httpx.codes.request_entity_too_large` will get an `AttributeError`. Consider preserving these too, either via explicit `setattr` calls after the loop or by adding them as additional alias entries.</comment>
<file context>
@@ -156,6 +156,12 @@ def is_error(cls, value: int) -> bool:
NETWORK_AUTHENTICATION_REQUIRED = 511, "Network Authentication Required"
+ # for backwards compatibility, keep the old constants around
+ REQUEST_ENTITY_TOO_LARGE = CONTENT_TOO_LARGE
+ REQUEST_URI_TOO_LONG = URI_TOO_LONG
+ REQUESTED_RANGE_NOT_SATISFIABLE = RANGE_NOT_SATISFIABLE
</file context>
RFC 9110 (HTTP Semantics) renamed several status phrases and obsoletes RFC 7231/7238. Add the new constant names and phrases, keeping the old constant names as aliases for backwards compatibility: - REQUEST_ENTITY_TOO_LARGE -> CONTENT_TOO_LARGE (413) - REQUEST_URI_TOO_LONG -> URI_TOO_LONG (414) - REQUESTED_RANGE_NOT_SATISFIABLE -> RANGE_NOT_SATISFIABLE (416) - UNPROCESSABLE_ENTITY -> UNPROCESSABLE_CONTENT (422)
197af58 to
b1cc86e
Compare
RFC 9110 (HTTP Semantics) obsoletes RFC 7231 (which obsoletes 2616) and RFC 7238, and renamed several status phrases. This adds the new constant names and phrases, keeping the old constant names as aliases for backwards compatibility:
REQUEST_ENTITY_TOO_LARGE→CONTENT_TOO_LARGE(413)REQUEST_URI_TOO_LONG→URI_TOO_LONG(414)REQUESTED_RANGE_NOT_SATISFIABLE→RANGE_NOT_SATISFIABLE(416)UNPROCESSABLE_ENTITY→UNPROCESSABLE_CONTENT(422)Ported from a fix I originally carried in the httpxyz fork.