feat: add rawHeaders to IncomingMessage (#31853)

* Add response.rawHeaders to docs for IncomingMessage

* Remove trailing spaces

* Implement raw headers, add tests

* Fix lint issues

* Add example from NodeJS docs

* Fix lint issue in doc example

* Add missing #
This commit is contained in:
Matthew Rayermann 2022-01-24 08:46:15 -08:00 committed by GitHub
parent d1b48c0636
commit d26d337bb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 179 additions and 11 deletions

View file

@ -80,3 +80,25 @@ An `Integer` indicating the HTTP protocol major version number.
An `Integer` indicating the HTTP protocol minor version number.
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
#### `response.rawHeaders`
A `string[]` containing the raw HTTP response headers exactly as they were
received. The keys and values are in the same list. It is not a list of
tuples. So, the even-numbered offsets are key values, and the odd-numbered
offsets are the associated values. Header names are not lowercased, and
duplicates are not merged.
```javascript
// Prints something like:
//
// [ 'user-agent',
// 'this is invalid because there can be only one',
// 'User-Agent',
// 'curl/7.22.0',
// 'Host',
// '127.0.0.1:8000',
// 'ACCEPT',
// '*/*' ]
console.log(request.rawHeaders)
```