Skip to content

Commit aa3d3b7

Browse files
authored
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 950a441 commit aa3d3b7

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
@@ -891,7 +891,7 @@ header-related http module methods. The keys of the returned object are the
891891
header names and the values are the respective header values. All header names
892892
are lowercase.
893893

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

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

@@ -2411,7 +2411,7 @@ Key-value pairs of header names and values. Header names are lower-cased.
24112411
// { 'user-agent': 'curl/7.22.0',
24122412
// host: '127.0.0.1:8000',
24132413
// accept: '*/*' }
2414-
console.log(request.getHeaders());
2414+
console.log(request.headers);
24152415
```
24162416

24172417
Duplicates in raw headers are handled in the following ways, depending on the
@@ -2614,15 +2614,15 @@ Accept: text/plain
26142614
To parse the URL into its parts:
26152615

26162616
```js
2617-
new URL(request.url, `http://${request.getHeaders().host}`);
2617+
new URL(request.url, `http://${request.headers.host}`);
26182618
```
26192619

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

26232623
```console
26242624
$ node
2625-
> new URL(request.url, `http://${request.getHeaders().host}`)
2625+
> new URL(request.url, `http://${request.headers.host}`)
26262626
URL {
26272627
href: 'http://localhost:3000/status?name=ryan',
26282628
origin: 'http://localhost:3000',

0 commit comments

Comments
 (0)