Skip to content

Fix http-headers crash on whitespace-only lines - #753

Merged
kellyjonbrazil merged 2 commits into
kellyjonbrazil:devfrom
tunglambk:fix/http-headers-whitespace-line
Sep 15, 2026
Merged

kellyjonbrazil merged 2 commits into
kellyjonbrazil:devfrom
tunglambk:fix/http-headers-whitespace-line

Conversation

@tunglambk

Copy link
Copy Markdown
Contributor

Fixes #752.

http_headers dropped empty lines with filter(None, ...), which still lets a whitespace-only line through to first_word = line.split(maxsplit=1)[0], raising IndexError. curl_head reaches the same line through http_headers.parse.

The lines are now filtered the way hosts is after #743.

Two tests were added, one for a request and one for a response containing a whitespace-only line. Both raise the IndexError on dev and pass with the change. tests/test_http_headers.py runs 4 tests; a full python -m unittest discover tests reports the same failures before and after the change in this environment.

Tung Lam and others added 2 commits September 14, 2026 09:31
The parser skipped empty lines with filter(None, ...), which still let a whitespace-only line reach line.split(maxsplit=1)[0] and raise IndexError. Filter the lines the same way the hosts parser does.
@kellyjonbrazil
kellyjonbrazil merged commit b2b27ef into kellyjonbrazil:dev Sep 15, 2026
20 checks passed
@kellyjonbrazil

Copy link
Copy Markdown
Owner

Looks good - thanks for the contribution. This will make it to the next release.

@tunglambk
tunglambk deleted the fix/http-headers-whitespace-line branch September 15, 2026 02:15
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