aiohttp: Match response header names case-insensitively. - #1146
Merged
dpgeorge merged 1 commit intoAug 10, 2026
Merged
Conversation
Member
|
see related #523 |
Contributor
Author
|
Thanks. #523 looks like the same wire-parse issue in requests Would you rather I fold that fix into this PR, or keep a separate |
Member
pablogventura
force-pushed
the
aiohttp-case-insensitive-headers
branch
from
August 10, 2026 02:16
cdb5cf2 to
8678eea
Compare
Contributor
Author
|
Thanks. Applied in 8678eea: one
I'll put the |
Response header field names are case-insensitive (RFC 9110 Sec. 5.1), but ClientSession._request matched Transfer-Encoding and Location with fixed capitalization via startswith. Servers that send transfer-encoding: or location: would skip chunked detection or redirects. Fixes issue micropython#1126. Signed-off-by: Pablo Ventura <pablogventura@gmail.com>
dpgeorge
force-pushed
the
aiohttp-case-insensitive-headers
branch
from
August 10, 2026 05:11
8678eea to
220ca9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1126. Response header field names are case-insensitive (RFC 9110
Sec. 5.1), but
ClientSession._requestmatchedTransfer-EncodingandLocationwith fixed capitalization viastartswith. Servers that sendtransfer-encoding:orlocation:would skip chunked detection orredirects.
Match those names with
line.lower().startswith(...), same idea as thesketch on the issue and prior art in #523 (for old
urequests, supersededafter the rename to
requests). TheLocationvalue is still taken fromthe original line so URL case is preserved.
Testing
mpy-crossonaiohttp/__init__.py(compiled as__init__.py):the header parse loop.
Trade-offs and Alternatives
requestsand can bea small follow-up; left out here to keep the diff minimal and avoid
overlapping the open chunked-response work.
_Headershelper) is a larger change and out of scope for this issue.
Generative AI
I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.