Skip to content

Commit f46c50b

Browse files
jasnelladdaleax
authored andcommitted
http2: add some doc detail for invalid header chars
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <[email protected]> Backport-Reviewed-By: Timothy Gu <[email protected]> PR-URL: #14239 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent b43caf9 commit f46c50b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/api/http2.md

+21
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,27 @@ These will be reported using either a synchronous `throw` or via an `'error'`
17071707
event on the `Http2Stream`, `Http2Session` or HTTP/2 Server objects, depending
17081708
on where and when the error occurs.
17091709

1710+
### Invalid character handling in header names and values
1711+
1712+
The HTTP/2 implementation applies stricter handling of invalid characters in
1713+
HTTP header names and values than the HTTP/1 implementation.
1714+
1715+
Header field names are *case-insensitive* and are transmitted over the wire
1716+
strictly as lower-case strings. The API provided by Node.js allows header
1717+
names to be set as mixed-case strings (e.g. `Content-Type`) but will convert
1718+
those to lower-case (e.g. `content-type`) upon transmission.
1719+
1720+
Header field-names *must only* contain one or more of the following ASCII
1721+
characters: `a`-`z`, `A`-`Z`, `0`-`9`, `!`, `#`, `$`, `%`, `&`, `'`, `*`, `+`,
1722+
`-`, `.`, `^`, `_`, `` (backtick), `|`, and `~`.
1723+
1724+
Using invalid characters within an HTTP header field name will cause the
1725+
stream to be closed with a protocol error being reported.
1726+
1727+
Header field values are handled with more leniency but *should* not contain
1728+
new-line or carriage return characters and *should* be limited to US-ASCII
1729+
characters, per the requirements of the HTTP specification.
1730+
17101731
### Push streams on the client
17111732

17121733
To receive pushed streams on the client, set a listener for the `'stream'`

0 commit comments

Comments
 (0)