1
0
mirror of https://github.com/golang/go synced 2024-11-19 16:34:49 -07:00

net/http: fix http_proxy parsing

Fixes #2919.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5645089
This commit is contained in:
Russ Cox 2012-02-12 23:19:50 -05:00
parent d318ab2264
commit fb2caa3244

View File

@ -85,16 +85,16 @@ func ProxyFromEnvironment(req *Request) (*url.URL, error) {
if !useProxy(canonicalAddr(req.URL)) {
return nil, nil
}
proxyURL, err := url.ParseRequest(proxy)
proxyURL, err := url.Parse(proxy)
if err != nil {
return nil, errors.New("invalid proxy address")
}
if proxyURL.Host == "" {
proxyURL, err = url.ParseRequest("http://" + proxy)
if err != nil {
return nil, errors.New("invalid proxy address")
if u, err := url.Parse("http://" + proxy); err == nil {
proxyURL = u
err = nil
}
}
if err != nil {
return nil, fmt.Errorf("invalid proxy address %q: %v", proxy, err)
}
return proxyURL, nil
}