aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2013-06-20 11:58:24 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2013-06-20 11:58:24 -0700
commit5b0bf9db8e0d735551ecec40cc374121b6e6a6ba (patch)
tree00ad0b20d77c7735571e75d00648c3ce4c685157 /src/pkg
parent3e710c0ba5da11da873c44bd9ca29786aefd1363 (diff)
downloadgo-5b0bf9db8e0d735551ecec40cc374121b6e6a6ba.tar.xz
net/http: fix confusing shadowing in ProxyFromEnvironment
The old code worked, somewhat on accident, but was confusing, and had a useless assignment to the inner err. It worked because url.Parse parses just about anything, so the outer err was always nil, so it always fell through to the bottom return statement, even without the "err = nil" line. Instead, just have two return statements, and add a comment. R=golang-dev, r CC=golang-dev https://golang.org/cl/10448044
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/net/http/transport.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pkg/net/http/transport.go b/src/pkg/net/http/transport.go
index 41ac7dea14..bd2106593b 100644
--- a/src/pkg/net/http/transport.go
+++ b/src/pkg/net/http/transport.go
@@ -109,9 +109,11 @@ func ProxyFromEnvironment(req *Request) (*url.URL, error) {
}
proxyURL, err := url.Parse(proxy)
if err != nil || !strings.HasPrefix(proxyURL.Scheme, "http") {
- if u, err := url.Parse("http://" + proxy); err == nil {
- proxyURL = u
- err = nil
+ // proxy was bogus. Try prepending "http://" to it and
+ // see if that parses correctly. If not, we fall
+ // through and complain about the original one.
+ if proxyURL, err := url.Parse("http://" + proxy); err == nil {
+ return proxyURL, nil
}
}
if err != nil {