http2: report invalid for spaced header names#33161
Conversation
|
@nodejs/http @nodejs/http2 @nodejs/streams PTAL |
|
@rexagod Is this semver-major? It looks that way to me. |
|
@addaleax +1. Thank you for tagging this! |
8ae28ff to
2935f72
Compare
There was a problem hiding this comment.
This will be equivalent to 'test', hence a valid header. See below.
node/lib/internal/http2/compat.js
Line 604 in a29d7c7
There was a problem hiding this comment.
Hm, I wonder, the http fails with ERR_INVALID_HTTP_TOKEN if you try to set the header name of ' test'.
There was a problem hiding this comment.
Each header field consists
of a name followed by a colon (":") and the field value. Field names
are case-insensitive. The field value MAY be preceded by any amount
of LWS, though a single SP is preferred.
@lundibundi The RFC2616 for HTTP/1 states that the field value may be preceded by any amount of LWS, but nothing similar is stated for the field names. Furthermore, this is not a problem in HTTP/2 owing to the binary protocol.
There was a problem hiding this comment.
That part of the RFC if referring to the format of the HTTP message (i.e. actual text representation of the message), not the specific field name/value. Just down below in that section, we can see
field-name = token
And the token is
token = 1*<any CHAR except CTLs or separators>
Therefore there shouldn't be any leading whitespace in the user-provided value for header name which our http/1 implementation is enforcing correctly (by throwing ERR_INVALID_HTTP_TOKEN).
It's fine to do that in a follow-up PR, I just mentioned it so that we won't forget about it.
Codecov Report
@@ Coverage Diff @@
## master #33161 +/- ##
==========================================
+ Coverage 96.26% 96.71% +0.44%
==========================================
Files 197 203 +6
Lines 65980 67388 +1408
==========================================
+ Hits 63518 65171 +1653
+ Misses 2462 2217 -245
Continue to review full report at Codecov.
|
|
@rexagod there are still a few comments to fix, then we can land. |
|
@mcollina I think all the comments have been resolved now. Please let me know if there's anything else left to fix here. |
lundibundi
left a comment
There was a problem hiding this comment.
LGTM.
Making explicit that IMO the leading whitespace in header names can be handled in a follow-up PR since this PR already improves things in compat layer a bit and there is no need to handle everything in one PR.
Refs: #29829
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes