|
2 | 2 | <!-- YAML
|
3 | 3 | added: v8.4.0
|
4 | 4 | changes:
|
| 5 | + - version: REPLACEME |
| 6 | + pr-url: https://github.com/nodejs/node/pull/34664 |
| 7 | + description: Requests with the `host` header (with or without |
| 8 | + `:authority`) can now be sent/received. |
5 | 9 | - version: v10.10.0
|
6 | 10 | pr-url: https://github.com/nodejs/node/pull/22466
|
7 | 11 | description: HTTP/2 is now Stable. Previously, it had been Experimental.
|
@@ -2530,7 +2534,7 @@ For incoming headers:
|
2530 | 2534 | `access-control-max-age`, `access-control-request-method`, `content-encoding`,
|
2531 | 2535 | `content-language`, `content-length`, `content-location`, `content-md5`,
|
2532 | 2536 | `content-range`, `content-type`, `date`, `dnt`, `etag`, `expires`, `from`,
|
2533 |
| - `if-match`, `if-modified-since`, `if-none-match`, `if-range`, |
| 2537 | + `host`, `if-match`, `if-modified-since`, `if-none-match`, `if-range`, |
2534 | 2538 | `if-unmodified-since`, `last-modified`, `location`, `max-forwards`,
|
2535 | 2539 | `proxy-authorization`, `range`, `referer`,`retry-after`, `tk`,
|
2536 | 2540 | `upgrade-insecure-requests`, `user-agent` or `x-content-type-options` are
|
@@ -2909,8 +2913,10 @@ added: v8.4.0
|
2909 | 2913 |
|
2910 | 2914 | * {string}
|
2911 | 2915 |
|
2912 |
| -The request authority pseudo header field. It can also be accessed via |
2913 |
| -`req.headers[':authority']`. |
| 2916 | +The request authority pseudo header field. Because HTTP/2 allows requests |
| 2917 | +to set either `:authority` or `host`, this value is derived from |
| 2918 | +`req.headers[':authority']` if present. Otherwise, it is derived from |
| 2919 | +`req.headers['host']`. |
2914 | 2920 |
|
2915 | 2921 | #### `request.complete`
|
2916 | 2922 | <!-- YAML
|
@@ -3709,6 +3715,18 @@ following additional properties:
|
3709 | 3715 | * `type` {string} Either `'server'` or `'client'` to identify the type of
|
3710 | 3716 | `Http2Session`.
|
3711 | 3717 |
|
| 3718 | +## Note on `:authority` and `host` |
| 3719 | + |
| 3720 | +HTTP/2 requires requests to have either the `:authority` pseudo-header |
| 3721 | +or the `host` header. Prefer `:authority` when constructing an HTTP/2 |
| 3722 | +request directly, and `host` when converting from HTTP/1 (in proxies, |
| 3723 | +for instance). |
| 3724 | + |
| 3725 | +The compatibility API falls back to `host` if `:authority` is not |
| 3726 | +present. See [`request.authority`][] for more information. However, |
| 3727 | +if you don't use the compatibility API (or use `req.headers` directly), |
| 3728 | +you need to implement any fall-back behaviour yourself. |
| 3729 | + |
3712 | 3730 | [ALPN Protocol ID]: https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids
|
3713 | 3731 | [ALPN negotiation]: #http2_alpn_negotiation
|
3714 | 3732 | [Compatibility API]: #http2_compatibility_api
|
@@ -3749,6 +3767,7 @@ following additional properties:
|
3749 | 3767 | [`net.Socket.prototype.unref()`]: net.html#net_socket_unref
|
3750 | 3768 | [`net.Socket`]: net.html#net_class_net_socket
|
3751 | 3769 | [`net.connect()`]: net.html#net_net_connect
|
| 3770 | +[`request.authority`]: #http2_request_authority |
3752 | 3771 | [`request.socket`]: #http2_request_socket
|
3753 | 3772 | [`request.socket.getPeerCertificate()`]: tls.html#tls_tlssocket_getpeercertificate_detailed
|
3754 | 3773 | [`response.end()`]: #http2_response_end_data_encoding_callback
|
|
0 commit comments