Skip to content

Commit 2084ad6

Browse files
lpincajuanarbol
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 cc55e84 commit 2084ad6

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
@@ -883,7 +883,7 @@ header-related http module methods. The keys of the returned object are the
883883
header names and the values are the respective header values. All header names
884884
are lowercase.
885885

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

895-
const headers = response.getHeaders();
895+
const headers = request.getHeaders();
896896
// headers === { foo: 'bar', 'cookie': ['foo=bar', 'bar=baz'] }
897897
```
898898

@@ -2336,7 +2336,7 @@ Key-value pairs of header names and values. Header names are lower-cased.
23362336
// { 'user-agent': 'curl/7.22.0',
23372337
// host: '127.0.0.1:8000',
23382338
// accept: '*/*' }
2339-
console.log(request.getHeaders());
2339+
console.log(request.headers);
23402340
```
23412341

23422342
Duplicates in raw headers are handled in the following ways, depending on the
@@ -2535,15 +2535,15 @@ Accept: text/plain
25352535
To parse the URL into its parts:
25362536

25372537
```js
2538-
new URL(request.url, `http://${request.getHeaders().host}`);
2538+
new URL(request.url, `http://${request.headers.host}`);
25392539
```
25402540

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

25442544
```console
25452545
$ node
2546-
> new URL(request.url, `http://${request.getHeaders().host}`)
2546+
> new URL(request.url, `http://${request.headers.host}`)
25472547
URL {
25482548
href: 'http://localhost:3000/status?name=ryan',
25492549
origin: 'http://localhost:3000',

0 commit comments

Comments
 (0)