diff options
| author | Anthony Martin <ality@pbrane.org> | 2011-10-14 17:09:38 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2011-10-14 17:09:38 -0700 |
| commit | b5077f82fade43dcfcc40648ffd65dc98a1515df (patch) | |
| tree | e99676cd6ba1d161bf00f3dc532d3bd306bcb71f /src/pkg/http | |
| parent | c5b3a4fb074e7a476a2841ba7ca5161636b7d9e9 (diff) | |
| download | go-b5077f82fade43dcfcc40648ffd65dc98a1515df.tar.xz | |
http: avoid panic caused by nil URL
The current code will panic if an invalid
request (one with a nil URL) is passed to
the doFollowingRedirects function.
Also, remove a redundant nil Header check.
R=bradfitz
CC=golang-dev
https://golang.org/cl/5270046
Diffstat (limited to 'src/pkg/http')
| -rw-r--r-- | src/pkg/http/client.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pkg/http/client.go b/src/pkg/http/client.go index bce9014c4b..3fa4a056ad 100644 --- a/src/pkg/http/client.go +++ b/src/pkg/http/client.go @@ -115,9 +115,6 @@ func send(req *Request, t RoundTripper) (resp *Response, err os.Error) { info := req.URL.RawUserinfo if len(info) > 0 { - if req.Header == nil { - req.Header = make(Header) - } req.Header.Set("Authorization", "Basic "+base64.URLEncoding.EncodeToString([]byte(info))) } return t.RoundTrip(req) @@ -176,6 +173,10 @@ func (c *Client) doFollowingRedirects(ireq *Request) (r *Response, err os.Error) } var via []*Request + if ireq.URL == nil { + return nil, os.NewError("http: nil Request.URL") + } + req := ireq urlStr := "" // next relative or absolute URL to fetch (after first request) for redirect := 0; ; redirect++ { |
