When used with a proxy, CONNECT doesn't set an authority which causes it to send the wrong Host header
I'm using Async::HTTP::Faraday with proxy to connect to a secure host. The proxy I'm using seems to be having trouble with the CONNECT request sent by the client. In particular, it relies on the Host header value to match the host we want to reach (not the proxy).
What it's sending to the proxy
CONNECT secure.host:443 HTTP/1.1
Host: proxy.host:80
I believe the correct form should be
CONNECT secure.host:443 HTTP/1.1
Host: secure.host:443
I tracked down why this was happening and it looks like the Protocol::HTTP::Methods#connect constructs a Request which only sets a few attributes, leaving authority as nil. When Async::HTTP::Client#call gets invoked, it then defaults the request.authority to the proxy's endpoint authority.
Do you want to have a go at making a PR?
@ioquatix sure I can whip up a PR. I wasn't sure if my conclusions were correct though.
Let's start with a PR to see what exactly needs to change.
You can now specify a custom authority using the authority: keyword argument: https://socketry.github.io/protocol-http/releases/index#request%5B%5D-and-response%5B%5D-keyword-arguments.
I don't know if this solves your problem as I think what you are drawing reference to is the default authority - feel free to clarify and re-open this issue or submit a PR.