Skip to content

gh-157951: Don't read a chunked body for 1xx, 204 and 304 responses in http.client - #157952

Open
DrVelvetFog wants to merge 1 commit into
python:mainfrom
DrVelvetFog:gh-157951-http-client-bodiless-chunked
Open

DrVelvetFog wants to merge 1 commit into
python:mainfrom
DrVelvetFog:gh-157951-http-client-bodiless-chunked

Conversation

@DrVelvetFog

@DrVelvetFog DrVelvetFog commented Sep 22, 2026

Copy link
Copy Markdown

HTTPResponse.begin() already sets length = 0 for 1xx, 204, 304 and HEAD, but left chunked set when the response had Transfer-Encoding: chunked, so read() blocked in _read_chunked(). This clears chunked in the same place. HEAD was already handled by the check in read(), and that check stays.

Test: test_bodiless_status_with_chunked_sync sends a 204 and a 304 with Transfer-Encoding: chunked followed by another response, and checks that read() returns b"" and leaves the next response unread. It fails without the change.

@python-cla-bot

python-cla-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@aisk aisk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I applied the test locally and confirmed it fails, then applied the fix and it passes. LGTM.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants