Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python-ecosys/aiohttp: fix header - case-insensitivity #972

Merged
merged 1 commit into from
Apr 12, 2025

Conversation

FuNK3Y
Copy link

@FuNK3Y FuNK3Y commented Feb 7, 2025

According to RFC (https://datatracker.ietf.org/doc/html/rfc7230#section-3.2) header names are case-insensitive.

This PR makes sure that the module behaves consistently regardless of the casing of Content-type and Content-Length (other headers are not considered by the module)

Without this fix, the client seems to wait for the connection termination (~10 seconds) prior to returning any content if the casing of Content-Length is different.

@FuNK3Y
Copy link
Author

FuNK3Y commented Feb 7, 2025

The pipeline is failing for an unrelated reason (version of GHA upload artifact)

@FuNK3Y FuNK3Y force-pushed the fix-header-case-sensitivity branch 3 times, most recently from e5fffb6 to 6dddab7 Compare February 7, 2025 19:40
@FuNK3Y FuNK3Y changed the title aiohttp: fix header - case-insensitivity python-ecosys/aiohttp: fix header - case-insensitivity Feb 10, 2025
@dpgeorge
Copy link
Member

Thanks for the fix. This is necessary as you point out, to comply with HTTP spec.

However I have some suggestions (inline) to optimise it for MicroPython.

@FuNK3Y FuNK3Y force-pushed the fix-header-case-sensitivity branch 6 times, most recently from 1610ec7 to 60e6188 Compare April 11, 2025 10:43
@FuNK3Y
Copy link
Author

FuNK3Y commented Apr 11, 2025

@dpgeorge thanks for the proposed changes. I implemented those and tested those successfully.

Copy link
Member

@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

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

Great, thanks for updating!

According to RFC https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
header names are case-insensitive.

This commit makes sure that the module behaves consistently regardless of
the casing of "Content-type" and "Content-Length" (other headers are not
considered by the module).

Without this fix, the client seems to wait for the connection termination
(~10 seconds) prior to returning any content if the casing of
"Content-Length" is different.

Signed-off-by: FuNK3Y <[email protected]>
@dpgeorge dpgeorge force-pushed the fix-header-case-sensitivity branch from 60e6188 to 86df723 Compare April 12, 2025 00:52
@dpgeorge dpgeorge merged commit 86df723 into micropython:master Apr 12, 2025
4 checks passed
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.

2 participants