Repository navigation
fix(http): handle optional whitespace in HTTP/1 headers - #6311
Open
binaryfire wants to merge 2 commits into
Open
binaryfire wants to merge 2 commits into
binaryfire wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6311 +/- ##
=======================================
Coverage 84.33% 84.34%
=======================================
Files 114 114
Lines 19154 19164 +10
Branches 3439 3442 +3
=======================================
+ Hits 16153 16163 +10
Misses 3001 3001 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
Follow-up: I expanded this to cover the same whitespace rule in Swoole's reactor-side header handling. It now also handles leading tabs in Connection, multipart Content-Type, and Expect, plus trailing whitespace in static Range headers. The title, body, and regressions have been updated. |
Remove trailing spaces and tabs from completed HTTP/1 header values before exposing them through request, client, and wrapper APIs. Apply the same rule to multipart boundaries captured by the server preprocessor so large uploads follow the normal parser path. Cover direct parsing, fragmented input, raw client responses, and preprocessed multipart uploads.
Recognize spaces and tabs consistently in the reactor header scanners, including Expect handling, and exclude trailing whitespace from raw header lookups used by the static handler. Cover keep-alive, multipart, 100 Continue, and static range behavior without adding parser state or allocations.
binaryfire
force-pushed
the
fix/http1-header-trailing-whitespace
branch
from
October 28, 2026 03:12
f786c49 to
1a76d30
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
HTTP/1 request and coroutine client parsing preserved trailing spaces and tabs in header values. The reactor's earlier header scans also handled optional whitespace inconsistently. RFC 9110 allows spaces and tabs around a field value and requires parsers to exclude them before evaluating it.
This can change values used by application code. For example, a bearer token with valid trailing header whitespace includes the suffix and fails authentication. Hypervel has a focused regression for this behavior.
Change
Trim trailing spaces and tabs after each complete HTTP/1 header value is assembled, before storing or interpreting it. Apply the same rule to request parsing, coroutine client responses, the C++ HTTP wrapper, and raw header lookups used by the static handler.
Recognize leading spaces and tabs in the reactor's
Connection, multipartContent-Type, andExpectscans. This keeps valid whitespace from causing several different failures:Expect: 100-continuereceives the interim response instead of waiting for the client timeout.The keep-alive scan follows the same rule. Multipart boundaries are also trimmed when captured by the preprocessing path.
Internal whitespace remains unchanged.
Tests
Added regression coverage for direct and byte-fragmented request parsing, raw coroutine client responses, reactor header scans,
Expect: 100-continue, static ranges, and multipart uploads large enough to use the preprocessing path. The regressions fail without their corresponding fixes and pass with this change.Ran the focused request and client PHPTs and the related HTTP server core tests.