As the following code:
https://github.com/request/request/blob/bbb3a0bbbe173342de8462a2171765a39681b248/request.js#L294
If URI is "http://myhost:80/path", header field "host" will be set as "myhost:80".
Is it correct?
Note: before commit ff6d6c6e7a3b2c36618b5d1db662e10c929696e3, "host" header field will be set as "myhost"
Recently, most clients (including curl & wget) and browsers have started to drop the :80 & :443 port suffixes in the Host header, and include it only when it is neither of the two. Dropping the port prefix for known services is still RFC-compliant; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
Examples of other projects stripping the port suffix —
Related request issue — https://github.com/request/request/issues/515
We discovered this was an issue while working with HAProxy, when backends use host-based routing. When the Host header includes the :80 or :443 suffix, the rules would not match and we'd get a 503 response.
@mikeal ~Can I send a PR for this?~ I've sent a PR here → https://github.com/request/request/pull/2904
@zhaotian2470 This can be closed now, as v2.88.1 fixes this.
Most helpful comment
Recently, most clients (including curl & wget) and browsers have started to drop the
:80&:443port suffixes in the Host header, and include it only when it is neither of the two. Dropping the port prefix for known services is still RFC-compliant; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23Examples of other projects stripping the port suffix —
Related
requestissue — https://github.com/request/request/issues/515We discovered this was an issue while working with HAProxy, when backends use host-based routing. When the
Hostheader includes the:80or:443suffix, the rules would not match and we'd get a503response.@mikeal ~Can I send a PR for this?~ I've sent a PR here → https://github.com/request/request/pull/2904