@@ -365,8 +365,7 @@ added: v8.4.0
365365* ` stream ` {Http2Stream} A reference to the stream
366366* ` headers ` {HTTP/2 Headers Object} An object describing the headers
367367* ` flags ` {number} The associated numeric flags
368- * ` rawHeaders ` {Array} An array containing the raw header names followed by
369- their respective values.
368+ * ` rawHeaders ` {HTTP/2 Raw Headers} An array containing the raw headers
370369
371370The ` 'stream' ` event is emitted when a new ` Http2Stream ` is created.
372371
@@ -1089,7 +1088,7 @@ changes:
10891088 description: Allow passing headers in raw array format.
10901089-->
10911090
1092- * ` headers ` {HTTP/2 Headers Object|Array }
1091+ * ` headers ` {HTTP/2 Headers Object|HTTP/2 Raw Headers }
10931092
10941093* ` options ` {Object}
10951094 * ` endStream ` {boolean} ` true ` if the ` Http2Stream ` _ writable_ side should
@@ -1681,11 +1680,12 @@ added: v8.4.0
16811680
16821681* ` headers ` {HTTP/2 Headers Object}
16831682* ` flags ` {number}
1683+ * ` rawHeaders ` {HTTP/2 Raw Headers}
16841684
16851685The ` 'headers' ` event is emitted when an additional block of headers is received
16861686for a stream, such as when a block of ` 1xx ` informational headers is received.
1687- The listener callback is passed the [ HTTP/2 Headers Object] [ ] and flags
1688- associated with the headers.
1687+ The listener callback is passed the [ HTTP/2 Headers Object] [ ] , flags associated
1688+ with the headers, and the headers in raw format (see [ HTTP/2 Raw Headers ] [ ] ) .
16891689
16901690``` js
16911691stream .on (' headers' , (headers , flags ) => {
@@ -1720,11 +1720,13 @@ added: v8.4.0
17201720
17211721* ` headers ` {HTTP/2 Headers Object}
17221722* ` flags ` {number}
1723+ * ` rawHeaders ` {HTTP/2 Raw Headers}
17231724
17241725The ` 'response' ` event is emitted when a response ` HEADERS ` frame has been
17251726received for this stream from the connected HTTP/2 server. The listener is
1726- invoked with two arguments: an ` Object ` containing the received
1727- [ HTTP/2 Headers Object] [ ] , and flags associated with the headers.
1727+ invoked with three arguments: an ` Object ` containing the received
1728+ [ HTTP/2 Headers Object] [ ] , flags associated with the headers, and the headers
1729+ in raw format (see [ HTTP/2 Raw Headers] [ ] ).
17281730
17291731``` mjs
17301732import { connect } from ' node:http2' ;
@@ -1872,7 +1874,7 @@ changes:
18721874 description: Allow explicitly setting date headers.
18731875-->
18741876
1875- * ` headers ` {HTTP/2 Headers Object|Array }
1877+ * ` headers ` {HTTP/2 Headers Object|HTTP/2 Raw Headers }
18761878* ` options ` {Object}
18771879 * ` endStream ` {boolean} Set to ` true ` to indicate that the response will not
18781880 include payload data.
@@ -2356,8 +2358,7 @@ added: v8.4.0
23562358* ` stream ` {Http2Stream} A reference to the stream
23572359* ` headers ` {HTTP/2 Headers Object} An object describing the headers
23582360* ` flags ` {number} The associated numeric flags
2359- * ` rawHeaders ` {Array} An array containing the raw header names followed by
2360- their respective values.
2361+ * ` rawHeaders ` {HTTP/2 Raw Headers} An array containing the raw headers
23612362
23622363The ` 'stream' ` event is emitted when a ` 'stream' ` event has been emitted by
23632364an ` Http2Session ` associated with the server.
@@ -2612,8 +2613,7 @@ added: v8.4.0
26122613* ` stream ` {Http2Stream} A reference to the stream
26132614* ` headers ` {HTTP/2 Headers Object} An object describing the headers
26142615* ` flags ` {number} The associated numeric flags
2615- * ` rawHeaders ` {Array} An array containing the raw header names followed by
2616- their respective values.
2616+ * ` rawHeaders ` {HTTP/2 Raw Headers} An array containing the raw headers
26172617
26182618The ` 'stream' ` event is emitted when a ` 'stream' ` event has been emitted by
26192619an ` Http2Session ` associated with the server.
@@ -3456,6 +3456,32 @@ server.on('stream', (stream, headers) => {
34563456});
34573457```
34583458
3459+ #### Raw headers
3460+
3461+ In some APIs, in addition to object format, headers can also be passed or
3462+ accessed as a raw flat array, preserving details of ordering and
3463+ duplicate keys to match the raw transmission format.
3464+
3465+ In this format the keys and values are in the same list. It is _ not_ a
3466+ list of tuples. So, the even-numbered offsets are key values, and the
3467+ odd-numbered offsets are the associated values. Duplicate headers are
3468+ not merged and so each key-value pair will appear separately.
3469+
3470+ This can be useful for cases such as proxies, where existing headers
3471+ should be exactly forwarded as received, or as a performance
3472+ optimization when the headers are already available in raw format.
3473+
3474+ ``` js
3475+ const rawHeaders = [
3476+ ' :status' ,
3477+ ' 404' ,
3478+ ' content-type' ,
3479+ ' text/plain' ,
3480+ ];
3481+
3482+ stream .respond (rawHeaders);
3483+ ```
3484+
34593485#### Sensitive headers
34603486
34613487HTTP2 headers can be marked as sensitive, which means that the HTTP/2
@@ -3482,6 +3508,10 @@ this flag is set automatically.
34823508This property is also set for received headers. It will contain the names of
34833509all headers marked as sensitive, including ones marked that way automatically.
34843510
3511+ For raw headers, this should still be set as a property on the array, like
3512+ ` rawHeadersArray[http2.sensitiveHeaders] = ['cookie'] ` , not as a separate key
3513+ and value pair within the array itself.
3514+
34853515### Settings object
34863516
34873517<!-- YAML
@@ -4078,16 +4108,10 @@ The request method as a string. Read-only. Examples: `'GET'`, `'DELETE'`.
40784108added: v8.4.0
40794109-->
40804110
4081- * Type: {string \[ ] }
4111+ * Type: {HTTP/2 Raw Headers }
40824112
40834113The raw request/response headers list exactly as they were received.
40844114
4085- The keys and values are in the same list. It is _ not_ a
4086- list of tuples. So, the even-numbered offsets are key values, and the
4087- odd-numbered offsets are the associated values.
4088-
4089- Header names are not lowercased, and duplicates are not merged.
4090-
40914115``` js
40924116// Prints something like:
40934117//
@@ -4768,7 +4792,7 @@ changes:
47684792
47694793* ` statusCode ` {number}
47704794* ` statusMessage ` {string}
4771- * ` headers ` {Object|Array }
4795+ * ` headers ` {HTTP/2 Headers Object|HTTP/2 Raw Headers }
47724796* Returns: {http2.Http2ServerResponse}
47734797
47744798Sends a response header to the request. The status code is a 3-digit HTTP
@@ -4912,6 +4936,7 @@ you need to implement any fall-back behavior yourself.
49124936[ HTTP/1 ] : http.md
49134937[ HTTP/2 ] : https://tools.ietf.org/html/rfc7540
49144938[ HTTP/2 Headers Object ] : #headers-object
4939+ [ HTTP/2 Raw Headers ] : #raw-headers
49154940[ HTTP/2 Settings Object ] : #settings-object
49164941[ HTTP/2 Unencrypted ] : https://http2.github.io/faq/#does-http2-require-encryption
49174942[ HTTPS ] : https.md
0 commit comments