HTTPClient doesn't support proxies (Vapor 2 did)
Closed this issue · 1 comments
I'm using the latest Engine 3.0.0 RC 2.4.
In the following line we use req.url.path
as URI:
var httpHead = HTTPRequestHead(version: req.version, method: req.method, uri: req.url.path)
But when I want to connect to a proxy server, I should pass to the uri
argument the full URL of the resource that I want my proxy to forward me to. But I can't.
In Vapor 2 we used a different struct for URI, which stored all the components separately, so when we were setting path
to the full URL it worked just fine. The full URI would be something like http://example.com:8080/http://example.com:8080
, and it's part
component hence would be just http://example.com:8080
.
If I do the same with Swift.URL
, the path
returns /http://example.com:8080
, which is rejected by the proxy server for obvious reasons.
I could substitute the aforementioned line for:
var httpHead = HTTPRequestHead(version: req.version, method: req.method, uri: String(req.url.path.dropFirst()))
But that will probably break something.
It would be great if the user could pass the URI directly. Maybe we could add a flag to the HTTPRequest
struct that determines whether we pass a path or a full URL when creating an HTTPRequestHead
?
Oh, I see it is fixed in #272. Nevermind. Thank you for your hard work!