Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Corrected the documentation to point to request.getHeaders() instead …
…of request.headers
  • Loading branch information
kcak11 authored Apr 7, 2022
commit 98d3417a3bd565eba5db137dd91e1f222e91de71
8 changes: 4 additions & 4 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ Key-value pairs of header names and values. Header names are lower-cased.
// { 'user-agent': 'curl/7.22.0',
// host: '127.0.0.1:8000',
// accept: '*/*' }
console.log(request.headers);
console.log(request.getHeaders());
```

Duplicates in raw headers are handled in the following ways, depending on the
Expand Down Expand Up @@ -2388,15 +2388,15 @@ Accept: text/plain
To parse the URL into its parts:

```js
new URL(request.url, `http://${request.headers.host}`);
new URL(request.url, `http://${request.getHeaders().host}`);
```

When `request.url` is `'/status?name=ryan'` and
`request.headers.host` is `'localhost:3000'`:
`request.getHeaders().host` is `'localhost:3000'`:

```console
$ node
> new URL(request.url, `http://${request.headers.host}`)
> new URL(request.url, `http://${request.getHeaders().host}`)
URL {
href: 'http://localhost:3000/status?name=ryan',
origin: 'http://localhost:3000',
Expand Down