From 9755b61c6a23544a6f5f4e0291578bee7871fa6f Mon Sep 17 00:00:00 2001 From: hicay Date: Fri, 4 Dec 2026 19:03:32 +0100 Subject: [PATCH] doc: document different duplicate header rules in http2 The node:http2 and node:http modules use different lists of incoming headers that discard duplicates. For example, node:http joins duplicate date, if-match, and range headers, but node:http2 discards them. For the server header, the behavior is the opposite. Add a note after the node:http2 list. The note tells users about the difference. It also tells them to use the raw headers when they must get all values. Signed-off-by: hicay --- doc/api/http2.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/api/http2.md b/doc/api/http2.md index 5d45b0fef70..42249105506 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -3750,6 +3750,12 @@ For incoming headers: * For duplicate `cookie` headers, the values are joined together with '; '. * For all other headers, the values are joined together with ', '. +The `node:http` module uses different rules for [`message.headers`][]. +For example, `node:http` joins duplicate `date`, `if-match`, and `range` +headers, but `node:http2` discards them. For duplicate `server` headers, the +behavior is the opposite. If your code serves HTTP/1 and HTTP/2 and must get +all values of a header, use the [HTTP/2 Raw Headers][]. + ```mjs import { createServer } from 'node:http2'; const server = createServer(); @@ -5474,6 +5480,7 @@ you need to implement any fall-back behavior yourself. [`http2.createServer()`]: #http2createserveroptions-onrequesthandler [`http2stream.pushStream()`]: #http2streampushstreamheaders-options-callback [`import()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import +[`message.headers`]: http.md#messageheaders [`net.Server.close()`]: net.md#serverclosecallback [`net.Socket.bufferSize`]: net.md#socketbuffersize [`net.Socket.prototype.ref()`]: net.md#socketref