Skip to content

Normalize list-style header parsing in pure-Python parser#12253

Open
rodrigobnogueira wants to merge 2 commits intoaio-libs:masterfrom
rodrigobnogueira:fix-header-list-parsing-master
Open

Normalize list-style header parsing in pure-Python parser#12253
rodrigobnogueira wants to merge 2 commits intoaio-libs:masterfrom
rodrigobnogueira:fix-header-list-parsing-master

Conversation

@rodrigobnogueira
Copy link
Copy Markdown
Member

@rodrigobnogueira rodrigobnogueira commented Mar 18, 2026

What do these changes do?

This PR fixes list-style token parsing for the Connection header and related tokenized headers in the HTTP parser.

The parser now normalizes comma-separated values and validates token fragments more consistently, avoiding edge-case misparsing.

Are there changes in behavior for the user?

Yes.

Malformed Transfer-Encoding values are now rejected more strictly during parsing.

Specifically, when parsing yields no valid transfer-coding tokens (for example because the field value is empty/invalid after normalization), the parser raises BadHttpMessage("Request has invalid \Transfer-Encoding`")`.

Previously, some malformed cases could be treated as "not chunked" and continue. The new behavior fails fast for invalid Transfer-Encoding, which is safer and more RFC-aligned.

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

No.

This is a focused parser correctness hardening with tests and changelog updates, and it keeps behavior consistent around invalid tokenized headers.

Related issue number

N/A

Checklist

  • I think this is a desirable change and covered by tests.
  • I have considered backward compatibility.
  • I have considered possible performance impact.
  • I have updated the documentation, or no docs update is needed.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Mar 18, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.10%. Comparing base (2602b71) to head (ea80eb3).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12253      +/-   ##
==========================================
- Coverage   99.11%   99.10%   -0.01%     
==========================================
  Files         130      130              
  Lines       45432    45489      +57     
  Branches     2400     2410      +10     
==========================================
+ Hits        45028    45084      +56     
  Misses        273      273              
- Partials      131      132       +1     
Flag Coverage Δ
CI-GHA 98.96% <100.00%> (-0.01%) ⬇️
OS-Linux 98.70% <100.00%> (+<0.01%) ⬆️
OS-Windows 96.98% <100.00%> (+<0.01%) ⬆️
OS-macOS 97.86% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 97.41% <100.00%> (+<0.01%) ⬆️
Py-3.10.20 97.89% <100.00%> (-0.01%) ⬇️
Py-3.11.15 98.09% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 97.62% <100.00%> (+<0.01%) ⬆️
Py-3.12.10 97.71% <100.00%> (+<0.01%) ⬆️
Py-3.12.13 98.18% <100.00%> (-0.01%) ⬇️
Py-3.13.12 98.43% <100.00%> (-0.01%) ⬇️
Py-3.14.3 98.49% <100.00%> (+<0.01%) ⬆️
Py-3.14.3t 97.49% <100.00%> (+<0.01%) ⬆️
Py-pypy3.11.13-7.3.20 97.53% <100.00%> (+<0.01%) ⬆️
VM-macos 97.86% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 98.70% <100.00%> (+<0.01%) ⬆️
VM-windows 96.98% <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 Sentry.
📢 Have feedback on the report? Share it here.

@rodrigobnogueira rodrigobnogueira marked this pull request as draft March 18, 2026 00:25
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 59 untouched benchmarks


Comparing rodrigobnogueira:fix-header-list-parsing-master (ea80eb3) with master (2602b71)

Open in CodSpeed

@rodrigobnogueira rodrigobnogueira changed the title Normalize list-style Connection and Transfer-Encoding parsing in Python parser Clarify list-header parsing normalization in pure-Python parser Mar 22, 2026
@rodrigobnogueira rodrigobnogueira force-pushed the fix-header-list-parsing-master branch from 8e8bc9e to b4fc804 Compare March 22, 2026 23:41
@rodrigobnogueira rodrigobnogueira changed the title Clarify list-header parsing normalization in pure-Python parser Normalize list-style header parsing in pure-Python parser Mar 22, 2026
@rodrigobnogueira rodrigobnogueira force-pushed the fix-header-list-parsing-master branch from 8dd9795 to 30c7234 Compare March 23, 2026 00:48
rodrigobnogueira added a commit to rodrigobnogueira/aiohttp that referenced this pull request Mar 23, 2026
rodrigobnogueira added a commit to rodrigobnogueira/aiohttp that referenced this pull request Mar 23, 2026
@rodrigobnogueira rodrigobnogueira force-pushed the fix-header-list-parsing-master branch from 908082a to 5077768 Compare March 23, 2026 01:34
@rodrigobnogueira rodrigobnogueira marked this pull request as ready for review March 23, 2026 01:37
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