| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9e2aa23 commit afaa1cc
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -365,8 +365,7 @@ added: v8.4.0 | |||
| 365 | 365 | * `stream` {Http2Stream} A reference to the stream | |
| 366 | 366 | * `headers` {HTTP/2 Headers Object} An object describing the headers | |
| 367 | 367 | * `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 | ||
| 370 | 369 | ||
| 371 | 370 | The `'stream'` event is emitted when a new `Http2Stream` is created. | |
| 372 | 371 | ||
@@ -1082,7 +1081,7 @@ changes: | |||
| 1082 | 1081 | description: Allow passing headers in raw array format. | |
| 1083 | 1082 | --> | |
| 1084 | 1083 | ||
| 1085 | - * `headers` {HTTP/2 Headers Object|Array} | ||
| 1084 | + * `headers` {HTTP/2 Headers Object|HTTP/2 Raw Headers} | ||
| 1086 | 1085 | ||
| 1087 | 1086 | * `options` {Object} | |
| 1088 | 1087 | * `endStream` {boolean} `true` if the `Http2Stream` _writable_ side should | |
@@ -1683,11 +1682,12 @@ added: v8.4.0 | |||
| 1683 | 1682 | ||
| 1684 | 1683 | * `headers` {HTTP/2 Headers Object} | |
| 1685 | 1684 | * `flags` {number} | |
| 1685 | + * `rawHeaders` {HTTP/2 Raw Headers} | ||
| 1686 | 1686 | ||
| 1687 | 1687 | The `'headers'` event is emitted when an additional block of headers is received | |
| 1688 | 1688 | for a stream, such as when a block of `1xx` informational headers is received. | |
| 1689 | - The listener callback is passed the [HTTP/2 Headers Object][] and flags | ||
| 1690 | - associated with the headers. | ||
| 1689 | + The listener callback is passed the [HTTP/2 Headers Object][], flags associated | ||
| 1690 | + with the headers, and the headers in raw format (see [HTTP/2 Raw Headers][]). | ||
| 1691 | 1691 | ||
| 1692 | 1692 | ```js | |
| 1693 | 1693 | stream.on('headers', (headers, flags) => { | |
@@ -1722,11 +1722,13 @@ added: v8.4.0 | |||
| 1722 | 1722 | ||
| 1723 | 1723 | * `headers` {HTTP/2 Headers Object} | |
| 1724 | 1724 | * `flags` {number} | |
| 1725 | + * `rawHeaders` {HTTP/2 Raw Headers} | ||
| 1725 | 1726 | ||
| 1726 | 1727 | The `'response'` event is emitted when a response `HEADERS` frame has been | |
| 1727 | 1728 | received for this stream from the connected HTTP/2 server. The listener is | |
| 1728 | - invoked with two arguments: an `Object` containing the received | ||
| 1729 | - [HTTP/2 Headers Object][], and flags associated with the headers. | ||
| 1729 | + invoked with three arguments: an `Object` containing the received | ||
| 1730 | + [HTTP/2 Headers Object][], flags associated with the headers, and the headers | ||
| 1731 | + in raw format (see [HTTP/2 Raw Headers][]). | ||
| 1730 | 1732 | ||
| 1731 | 1733 | ```mjs | |
| 1732 | 1734 | import { connect } from 'node:http2'; | |
@@ -1874,7 +1876,7 @@ changes: | |||
| 1874 | 1876 | description: Allow explicitly setting date headers. | |
| 1875 | 1877 | --> | |
| 1876 | 1878 | ||
| 1877 | - * `headers` {HTTP/2 Headers Object|Array} | ||
| 1879 | + * `headers` {HTTP/2 Headers Object|HTTP/2 Raw Headers} | ||
| 1878 | 1880 | * `options` {Object} | |
| 1879 | 1881 | * `endStream` {boolean} Set to `true` to indicate that the response will not | |
| 1880 | 1882 | include payload data. | |
@@ -2358,8 +2360,7 @@ added: v8.4.0 | |||
| 2358 | 2360 | * `stream` {Http2Stream} A reference to the stream | |
| 2359 | 2361 | * `headers` {HTTP/2 Headers Object} An object describing the headers | |
| 2360 | 2362 | * `flags` {number} The associated numeric flags | |
| 2361 | - * `rawHeaders` {Array} An array containing the raw header names followed by | ||
| 2362 | - their respective values. | ||
| 2363 | + * `rawHeaders` {HTTP/2 Raw Headers} An array containing the raw headers | ||
| 2363 | 2364 | ||
| 2364 | 2365 | The `'stream'` event is emitted when a `'stream'` event has been emitted by | |
| 2365 | 2366 | an `Http2Session` associated with the server. | |
@@ -2612,8 +2613,7 @@ added: v8.4.0 | |||
| 2612 | 2613 | * `stream` {Http2Stream} A reference to the stream | |
| 2613 | 2614 | * `headers` {HTTP/2 Headers Object} An object describing the headers | |
| 2614 | 2615 | * `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 | ||
| 2617 | 2617 | ||
| 2618 | 2618 | The `'stream'` event is emitted when a `'stream'` event has been emitted by | |
| 2619 | 2619 | an `Http2Session` associated with the server. | |
@@ -3455,6 +3455,32 @@ server.on('stream', (stream, headers) => { | |||
| 3455 | 3455 | }); | |
| 3456 | 3456 | ``` | |
| 3457 | 3457 | ||
| 3458 | + #### Raw headers | ||
| 3459 | + | ||
| 3460 | + In some APIs, in addition to object format, headers can also be passed or | ||
| 3461 | + accessed as a raw flat array, preserving details of ordering and | ||
| 3462 | + duplicate keys to match the raw transmission format. | ||
| 3463 | + | ||
| 3464 | + In this format the keys and values are in the same list. It is _not_ a | ||
| 3465 | + list of tuples. So, the even-numbered offsets are key values, and the | ||
| 3466 | + odd-numbered offsets are the associated values. Duplicate headers are | ||
| 3467 | + not merged and so each key-value pair will appear separately. | ||
| 3468 | + | ||
| 3469 | + This can be useful for cases such as proxies, where existing headers | ||
| 3470 | + should be exactly forwarded as received, or as a performance | ||
| 3471 | + optimization when the headers are already available in raw format. | ||
| 3472 | + | ||
| 3473 | + ```js | ||
| 3474 | + const rawHeaders = [ | ||
| 3475 | + ':status', | ||
| 3476 | + '404', | ||
| 3477 | + 'content-type', | ||
| 3478 | + 'text/plain', | ||
| 3479 | + ]; | ||
| 3480 | + | ||
| 3481 | + stream.respond(rawHeaders); | ||
| 3482 | + ``` | ||
| 3483 | + | ||
| 3458 | 3484 | #### Sensitive headers | |
| 3459 | 3485 | ||
| 3460 | 3486 | HTTP2 headers can be marked as sensitive, which means that the HTTP/2 | |
@@ -3481,6 +3507,10 @@ this flag is set automatically. | |||
| 3481 | 3507 | This property is also set for received headers. It will contain the names of | |
| 3482 | 3508 | all headers marked as sensitive, including ones marked that way automatically. | |
| 3483 | 3509 | ||
| 3510 | + For raw headers, this should still be set as a property on the array, like | ||
| 3511 | + `rawHeadersArray[http2.sensitiveHeaders] = ['cookie']`, not as a separate key | ||
| 3512 | + and value pair within the array itself. | ||
| 3513 | + | ||
| 3484 | 3514 | ### Settings object | |
| 3485 | 3515 | ||
| 3486 | 3516 | <!-- YAML | |
@@ -4077,16 +4107,10 @@ The request method as a string. Read-only. Examples: `'GET'`, `'DELETE'`. | |||
| 4077 | 4107 | added: v8.4.0 | |
| 4078 | 4108 | --> | |
| 4079 | 4109 | ||
| 4080 | - * Type: {string\[]} | ||
| 4110 | + * Type: {HTTP/2 Raw Headers} | ||
| 4081 | 4111 | ||
| 4082 | 4112 | The raw request/response headers list exactly as they were received. | |
| 4083 | 4113 | ||
| 4084 | - The keys and values are in the same list. It is _not_ a | ||
| 4085 | - list of tuples. So, the even-numbered offsets are key values, and the | ||
| 4086 | - odd-numbered offsets are the associated values. | ||
| 4087 | - | ||
| 4088 | - Header names are not lowercased, and duplicates are not merged. | ||
| 4089 | - | ||
| 4090 | 4114 | ```js | |
| 4091 | 4115 | // Prints something like: | |
| 4092 | 4116 | // | |
@@ -4767,7 +4791,7 @@ changes: | |||
| 4767 | 4791 | ||
| 4768 | 4792 | * `statusCode` {number} | |
| 4769 | 4793 | * `statusMessage` {string} | |
| 4770 | - * `headers` {Object|Array} | ||
| 4794 | + * `headers` {HTTP/2 Headers Object|HTTP/2 Raw Headers} | ||
| 4771 | 4795 | * Returns: {http2.Http2ServerResponse} | |
| 4772 | 4796 | ||
| 4773 | 4797 | Sends a response header to the request. The status code is a 3-digit HTTP | |
@@ -4911,6 +4935,7 @@ you need to implement any fall-back behavior yourself. | |||
| 4911 | 4935 | [HTTP/1]: http.md | |
| 4912 | 4936 | [HTTP/2]: https://tools.ietf.org/html/rfc7540 | |
| 4913 | 4937 | [HTTP/2 Headers Object]: #headers-object | |
| 4938 | + [HTTP/2 Raw Headers]: #raw-headers | ||
| 4914 | 4939 | [HTTP/2 Settings Object]: #settings-object | |
| 4915 | 4940 | [HTTP/2 Unencrypted]: https://http2.github.io/faq/#does-http2-require-encryption | |
| 4916 | 4941 | [HTTPS]: https.md | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -165,6 +165,7 @@ const customTypesMap = { | |||
| 165 | 165 | 'ClientHttp2Session': 'http2.html#class-clienthttp2session', | |
| 166 | 166 | 'ClientHttp2Stream': 'http2.html#class-clienthttp2stream', | |
| 167 | 167 | 'HTTP/2 Headers Object': 'http2.html#headers-object', | |
| 168 | + 'HTTP/2 Raw Headers': 'http2.html#raw-headers', | ||
| 168 | 169 | 'HTTP/2 Settings Object': 'http2.html#settings-object', | |
| 169 | 170 | 'http2.Http2ServerRequest': 'http2.html#class-http2http2serverrequest', | |
| 170 | 171 | 'http2.Http2ServerResponse': | |
| Back | FazBrowse Home | New Git URL |
0 commit comments