@@ -883,7 +883,7 @@ header-related http module methods. The keys of the returned object are the
883
883
header names and the values are the respective header values. All header names
884
884
are lowercase.
885
885
886
- The object returned by the ` response .getHeaders()` method _ does not_
886
+ The object returned by the ` request .getHeaders()` method _ does not_
887
887
prototypically inherit from the JavaScript ` Object ` . This means that typical
888
888
` Object ` methods such as ` obj.toString() ` , ` obj.hasOwnProperty() ` , and others
889
889
are not defined and _ will not work_ .
@@ -892,7 +892,7 @@ are not defined and _will not work_.
892
892
request .setHeader (' Foo' , ' bar' );
893
893
request .setHeader (' Cookie' , [' foo=bar' , ' bar=baz' ]);
894
894
895
- const headers = response .getHeaders ();
895
+ const headers = request .getHeaders ();
896
896
// headers === { foo: 'bar', 'cookie': ['foo=bar', 'bar=baz'] }
897
897
```
898
898
@@ -2336,7 +2336,7 @@ Key-value pairs of header names and values. Header names are lower-cased.
2336
2336
// { 'user-agent': 'curl/7.22.0',
2337
2337
// host: '127.0.0.1:8000',
2338
2338
// accept: '*/*' }
2339
- console .log (request .getHeaders () );
2339
+ console .log (request .headers );
2340
2340
```
2341
2341
2342
2342
Duplicates in raw headers are handled in the following ways, depending on the
@@ -2535,15 +2535,15 @@ Accept: text/plain
2535
2535
To parse the URL into its parts:
2536
2536
2537
2537
``` js
2538
- new URL (request .url , ` http://${ request .getHeaders () .host } ` );
2538
+ new URL (request .url , ` http://${ request .headers .host } ` );
2539
2539
```
2540
2540
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' ` :
2543
2543
2544
2544
``` console
2545
2545
$ node
2546
- > new URL(request.url, `http://${request.getHeaders () .host}` )
2546
+ > new URL(request.url, ` http://${request.headers .host} ` )
2547
2547
URL {
2548
2548
href: 'http://localhost:3000/status?name=ryan',
2549
2549
origin: 'http://localhost:3000',
0 commit comments