Skip to content

Reject duplicate Content-Length headers#12389

Open
metsw24-max wants to merge 1 commit intoaio-libs:masterfrom
metsw24-max:consistent-Content-Length-handling
Open

Reject duplicate Content-Length headers#12389
metsw24-max wants to merge 1 commit intoaio-libs:masterfrom
metsw24-max:consistent-Content-Length-handling

Conversation

@metsw24-max
Copy link
Copy Markdown

What do these changes do?

This change makes the Python HTTP response parser reject responses with multiple Content-Length headers by using headers.getall() and raising BadHttpMessage. This aligns behavior with the C parser and removes ambiguity in message framing.

Are there changes in behavior for the user?

Yes. Previously only the first Content-Length header was used. Now, responses with more than one Content-Length header will be rejected with BadHttpMessage.

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

No. The change is small, localized, and improves correctness and consistency without adding maintenance complexity.

@metsw24-max metsw24-max requested a review from asvetlov as a code owner April 17, 2026 11:41
@Dreamsorcerer
Copy link
Copy Markdown
Member

Needs a test to reproduce the issue. I'm pretty sure duplicates are already rejected (atleast server-side).

@Dreamsorcerer Dreamsorcerer added the pr-unfinished The PR is unfinished and may need a volunteer to complete it label Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-unfinished The PR is unfinished and may need a volunteer to complete it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants