You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The http.ProxyFromEnvironment function does not return an error if the environment variables contain incorrect values. Worse, it returns <nil> / <nil>. Because of this, the http.Client{} silently ignores the value of the variables defining the proxy.
The problem is that in the package x/net/http/httpproxy function httpproxy.FromEnvironment().ProxyFunc() simply ignores the errors that the url.Parse() returns.
http.ProxyFromEnvironment is used when building the default client client := &http.Client{} and it is not clear how to report an error in this case
The value of the environment variable in my example is correct from the point of view of for example curl. The password can contain a percent sign. On the other hand, in URLs, the percentage means something completely different...
What did you expect to see?
Silently ignoring the error
What did you see instead?
An error returned explicitly
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Go Playground
The
http.ProxyFromEnvironment
function does not return an error if the environment variables contain incorrect values. Worse, it returns <nil> / <nil>. Because of this, thehttp.Client{}
silently ignores the value of the variables defining the proxy.The problem is that in the package
x/net/http/httpproxy
functionhttpproxy.FromEnvironment().ProxyFunc()
simply ignores the errors that theurl.Parse()
returns.go/src/vendor/golang.org/x/net/http/httpproxy/proxy.go
Lines 118 to 125 in 658b5e6
go/src/vendor/golang.org/x/net/http/httpproxy/proxy.go
Lines 208 to 215 in 658b5e6
I see two problems here:
http.ProxyFromEnvironment
is used when building the default clientclient := &http.Client{}
and it is not clear how to report an error in this caseWhat did you expect to see?
Silently ignoring the error
What did you see instead?
An error returned explicitly
The text was updated successfully, but these errors were encountered: