Skip to content

Add RFC 9110 status code constants#1069

Open
mbeijen wants to merge 1 commit into
pydantic:mainfrom
mbeijen:rfc9110-status-texts
Open

Add RFC 9110 status code constants#1069
mbeijen wants to merge 1 commit into
pydantic:mainfrom
mbeijen:rfc9110-status-texts

Conversation

@mbeijen

@mbeijen mbeijen commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

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_LARGECONTENT_TOO_LARGE (413)
  • REQUEST_URI_TOO_LONGURI_TOO_LONG (414)
  • REQUESTED_RANGE_NOT_SATISFIABLERANGE_NOT_SATISFIABLE (416)
  • UNPROCESSABLE_ENTITYUNPROCESSABLE_CONTENT (422)

Ported from a fix I originally carried in the httpxyz fork.

Review in cubic

@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 10.08%

❌ 1 regressed benchmark
✅ 14 untouched benchmarks
⏩ 7 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation test_bench_line_decoder 115.3 µs 128.3 µs -10.08%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mbeijen:rfc9110-status-texts (b1cc86e) with main (c4e73cf)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
@mbeijen
mbeijen force-pushed the rfc9110-status-texts branch from 197af58 to b1cc86e Compare July 15, 2026 20:53
mbeijen added a commit to mbeijen/httpx2 that referenced this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant