@@ -889,7 +889,7 @@ header-related http module methods. The keys of the returned object are the
889
889
header names and the values are the respective header values. All header names
890
890
are lowercase.
891
891
892
- The object returned by the ` response .getHeaders()` method _ does not_
892
+ The object returned by the ` request .getHeaders()` method _ does not_
893
893
prototypically inherit from the JavaScript ` Object ` . This means that typical
894
894
` Object ` methods such as ` obj.toString() ` , ` obj.hasOwnProperty() ` , and others
895
895
are not defined and _ will not work_ .
@@ -898,7 +898,7 @@ are not defined and _will not work_.
898
898
request .setHeader (' Foo' , ' bar' );
899
899
request .setHeader (' Cookie' , [' foo=bar' , ' bar=baz' ]);
900
900
901
- const headers = response .getHeaders ();
901
+ const headers = request .getHeaders ();
902
902
// headers === { foo: 'bar', 'cookie': ['foo=bar', 'bar=baz'] }
903
903
```
904
904
@@ -2367,7 +2367,7 @@ Key-value pairs of header names and values. Header names are lower-cased.
2367
2367
// { 'user-agent': 'curl/7.22.0',
2368
2368
// host: '127.0.0.1:8000',
2369
2369
// accept: '*/*' }
2370
- console .log (request .getHeaders () );
2370
+ console .log (request .headers );
2371
2371
```
2372
2372
2373
2373
Duplicates in raw headers are handled in the following ways, depending on the
@@ -2566,15 +2566,15 @@ Accept: text/plain
2566
2566
To parse the URL into its parts:
2567
2567
2568
2568
``` js
2569
- new URL (request .url , ` http://${ request .getHeaders () .host } ` );
2569
+ new URL (request .url , ` http://${ request .headers .host } ` );
2570
2570
```
2571
2571
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' ` :
2574
2574
2575
2575
``` console
2576
2576
$ node
2577
- > new URL(request.url, `http://${request.getHeaders () .host}` )
2577
+ > new URL(request.url, ` http://${request.headers .host} ` )
2578
2578
URL {
2579
2579
href: 'http://localhost:3000/status?name=ryan',
2580
2580
origin: 'http://localhost:3000',
0 commit comments