net.http_proxy : Use a url when using a proxy instead of only the path#25228
net.http_proxy : Use a url when using a proxy instead of only the path#25228spytheman merged 6 commits intovlang:masterfrom
Conversation
|
Connected to Huly®: V_0.6-24668 |
|
I changed the test to only run if the user has a http_proxy/HTTP_PROXY/https_proxy/HTTPS_PROXY env var set. If it set, then it attempts to receive a custom header back from https://httpbin.org/headers (just echoing the header into the Response). with this current commit in http_proxy.v on line 92: //Before:
s := req.build_request_headers(req.method, host_name, port, path)
//After:
s := req.build_request_headers(req.method, host_name, port, '${host.scheme}://${host_name}${port_part}${path}')I can confirm that the test request to httpbin.org receives a 200 status code compared to before. |
|
I am thinking of installing |
spytheman
left a comment
There was a problem hiding this comment.
Excellent work.
Thank you 🙇🏻.
(Re-submitted the PR, I didn't branch my work appropriately and broke history. #25169 )
Objective:
Change the
net.http_proxy.http_domethod to construct a url for the request instead of just the path:GET http://google.com/get HTTP/1.1instead ofGET /get HTTP/1.1It is to follow the RFC 7230 standard section 5.3.2:
The change is only in http_proxy.v so it should only happen when using a proxy.
This change allowed a proxied http request to work for me.
My reproducing case:
@spytheman
That is a good question, and I thought about that during tests, but assumed a real proxy request attempt in testing would be problematic. From what I know, free public proxy servers change a lot so theyre not reliable. Having anyone reproducing the test that pings some random proxy server sounds a bit iffy. So a more internal solution makes more sense.
Only thing I can think of is if maybe vlang.io had an endpoint serving as a proxy and have it protected with an authentication key of sorts. If the user doesnt have the auth key detected in a compile-time check, skip the test. Without authentication, I'd worry about scrapers.
We could test via running a proxy server service within the test, but that would need a user's custom port open and it'd treat it as localhost which defeats a bit of the purpose. What do you think?