@@ -891,7 +891,7 @@ header-related http module methods. The keys of the returned object are the
891
891
header names and the values are the respective header values. All header names
892
892
are lowercase.
893
893
894
- The object returned by the ` response .getHeaders()` method _ does not_
894
+ The object returned by the ` request .getHeaders()` method _ does not_
895
895
prototypically inherit from the JavaScript ` Object ` . This means that typical
896
896
` Object ` methods such as ` obj.toString() ` , ` obj.hasOwnProperty() ` , and others
897
897
are not defined and _ will not work_ .
@@ -900,7 +900,7 @@ are not defined and _will not work_.
900
900
request .setHeader (' Foo' , ' bar' );
901
901
request .setHeader (' Cookie' , [' foo=bar' , ' bar=baz' ]);
902
902
903
- const headers = response .getHeaders ();
903
+ const headers = request .getHeaders ();
904
904
// headers === { foo: 'bar', 'cookie': ['foo=bar', 'bar=baz'] }
905
905
```
906
906
@@ -2411,7 +2411,7 @@ Key-value pairs of header names and values. Header names are lower-cased.
2411
2411
// { 'user-agent': 'curl/7.22.0',
2412
2412
// host: '127.0.0.1:8000',
2413
2413
// accept: '*/*' }
2414
- console .log (request .getHeaders () );
2414
+ console .log (request .headers );
2415
2415
```
2416
2416
2417
2417
Duplicates in raw headers are handled in the following ways, depending on the
@@ -2614,15 +2614,15 @@ Accept: text/plain
2614
2614
To parse the URL into its parts:
2615
2615
2616
2616
``` js
2617
- new URL (request .url , ` http://${ request .getHeaders () .host } ` );
2617
+ new URL (request .url , ` http://${ request .headers .host } ` );
2618
2618
```
2619
2619
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' ` :
2622
2622
2623
2623
``` console
2624
2624
$ node
2625
- > new URL(request.url, `http://${request.getHeaders () .host}` )
2625
+ > new URL(request.url, ` http://${request.headers .host} ` )
2626
2626
URL {
2627
2627
href: 'http://localhost:3000/status?name=ryan',
2628
2628
origin: 'http://localhost:3000',
0 commit comments