Skip to content

Add hdrs.X_FORWARDED_PREFIX - #14432

Open
felipecrs wants to merge 3 commits into
aio-libs:masterfrom
felipecrs:hdrs-x-forwarded-prefix
Open

felipecrs wants to merge 3 commits into
aio-libs:masterfrom
felipecrs:hdrs-x-forwarded-prefix

Conversation

@felipecrs

@felipecrs felipecrs commented Nov 22, 2026 •

Copy link
Copy Markdown

What do these changes do?

Adds hdrs.X_FORWARDED_PREFIX (X-Forwarded-Prefix) to the "de facto; added by reverse proxies and load balancers" group, next to X_FORWARDED_PORT added in #13886. The header is widely used by proxies and honored by many frameworks to tell a backend the path prefix it is served under.

It is needed by home-assistant/core#193747, which sets this header on ingress requests and currently has to define the name itself.

Are there changes in behavior for the user?

No behavior change besides a new public constant. The C parser now returns the shared istr constant for this header name.

Is it a substantial burden for the maintainers to support this?

One more line in hdrs.py, in the same group as the existing X_FORWARDED_* constants. The existing test_known_header_name_is_hdrs_constant covers it automatically.

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist (covered by the existing parametrized test_known_header_name_is_hdrs_constant)
  • Documentation reflects the changes N/A
  • If you provide code modifications, please add yourself to
    CONTRIBUTORS.txt
  • Add a new news fragment into the CHANGES/ folder

Drafted with Claude Code.

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Nov 22, 2026
@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.12%. Comparing base (b60c612) to head (e0273d0).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14432   +/-   ##
=======================================
  Coverage   99.12%   99.12%           
=======================================
  Files         135      135           
  Lines       53661    53662    +1     
  Branches     2737     2737           
=======================================
+ Hits        53191    53192    +1     
  Misses        356      356           
  Partials      114      114           
Flag Coverage Δ
Autobahn 21.66% <100.00%> (+<0.01%) ⬆️
CI-GHA 99.05% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.73% <100.00%> (-0.01%) ⬇️
OS-Windows 97.48% <100.00%> (-0.01%) ⬇️
OS-macOS 98.35% <100.00%> (+<0.01%) ⬆️
Py-3.11 98.29% <100.00%> (+<0.01%) ⬆️
Py-3.12 98.37% <100.00%> (+<0.01%) ⬆️
Py-3.13 98.36% <100.00%> (+<0.01%) ⬆️
Py-3.14 98.42% <100.00%> (-0.01%) ⬇️
Py-3.15 98.44% <100.00%> (+0.01%) ⬆️
Py-3.15t 98.28% <100.00%> (-0.01%) ⬇️
Py-pypy-3.12 96.95% <100.00%> (-0.02%) ⬇️
VM-macos-latest 98.35% <100.00%> (+<0.01%) ⬆️
VM-ubuntu-latest 98.73% <100.00%> (-0.01%) ⬇️
VM-windows-latest 97.48% <100.00%> (-0.01%) ⬇️
cython-coverage 83.94% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed

codspeed Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 50 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 102 untouched benchmarks
⏩ 83 skipped benchmarks1


Comparing felipecrs:hdrs-x-forwarded-prefix (e0273d0) with master (b60c612)

Open in CodSpeed

Footnotes

  1. 83 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. ↩

@felipecrs
felipecrs marked this pull request as ready for review November 22, 2026 04:44
@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: apex

[Low impact] The change reaches aiohttp callers using one reverse-proxy header.

The code change looks sound, but the required documentation update must land before merging.

Reviews (2) · Last reviewed commit: "Fix changelog reference to an undocument..." · Reviewed by Greptile

Comment thread aiohttp/hdrs.py Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant