Commit fb2caa32 authored by Russ Cox's avatar Russ Cox

net/http: fix http_proxy parsing

Fixes #2919.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5645089
parent d318ab22
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment