Omit default port in host?
Hi!
I was trying to hit an API with tokio-websockets, and it was failing specifically because of [the `Host` header in the upgrade request](https://github.com/Gelbpunkt/tokio-websockets/blob/b701bc08116d5efadda025a3f9f872ffccbf49f1/src/client.rs#L93-L103). Testing in Postman, if the `Host` header included a port, that API would return 400 and not allow the connection.
Looking at [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455), it says
> The request MUST contain a |Host| header field whose value contains /host/ plus optionally ":" followed by /port/ (when not using the default port).
This is definitely being a little language-lawyer-ish, but I think this implies that the `Host` header is _only_ allowed to include a port when not using the default port. At least, that API doesn't allow it.
Could this library omit the port from its `Host` header, unless the passed-in URI included an explicit port? It'd also work if the caller could override the value for `Host` itself, but I'd prefer if the library handled this quirk automatically.
关闭于 2025-02-09 1 条评论