Skip to content

Commit 4d6b46e

Browse files
lpincaRafaelGSS
authored andcommitted
doc: fix errors in http.md
Fixes: #44567 PR-URL: #44587 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Mestery <[email protected]>
1 parent 10891e6 commit 4d6b46e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/api/http.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ header-related http module methods. The keys of the returned object are the
889889
header names and the values are the respective header values. All header names
890890
are lowercase.
891891

892-
The object returned by the `response.getHeaders()` method _does not_
892+
The object returned by the `request.getHeaders()` method _does not_
893893
prototypically inherit from the JavaScript `Object`. This means that typical
894894
`Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`, and others
895895
are not defined and _will not work_.
@@ -898,7 +898,7 @@ are not defined and _will not work_.
898898
request.setHeader('Foo', 'bar');
899899
request.setHeader('Cookie', ['foo=bar', 'bar=baz']);
900900

901-
const headers = response.getHeaders();
901+
const headers = request.getHeaders();
902902
// headers === { foo: 'bar', 'cookie': ['foo=bar', 'bar=baz'] }
903903
```
904904

@@ -2367,7 +2367,7 @@ Key-value pairs of header names and values. Header names are lower-cased.
23672367
// { 'user-agent': 'curl/7.22.0',
23682368
// host: '127.0.0.1:8000',
23692369
// accept: '*/*' }
2370-
console.log(request.getHeaders());
2370+
console.log(request.headers);
23712371
```
23722372

23732373
Duplicates in raw headers are handled in the following ways, depending on the
@@ -2566,15 +2566,15 @@ Accept: text/plain
25662566
To parse the URL into its parts:
25672567

25682568
```js
2569-
new URL(request.url, `http://${request.getHeaders().host}`);
2569+
new URL(request.url, `http://${request.headers.host}`);
25702570
```
25712571

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

25752575
```console
25762576
$ node
2577-
> new URL(request.url, `http://${request.getHeaders().host}`)
2577+
> new URL(request.url, `http://${request.headers.host}`)
25782578
URL {
25792579
href: 'http://localhost:3000/status?name=ryan',
25802580
origin: 'http://localhost:3000',

0 commit comments

Comments
 (0)