Commit b5077f82 authored by Anthony Martin's avatar Anthony Martin Committed by Brad Fitzpatrick

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
parent c5b3a4fb
...@@ -115,9 +115,6 @@ func send(req *Request, t RoundTripper) (resp *Response, err os.Error) { ...@@ -115,9 +115,6 @@ func send(req *Request, t RoundTripper) (resp *Response, err os.Error) {
info := req.URL.RawUserinfo info := req.URL.RawUserinfo
if len(info) > 0 { if len(info) > 0 {
if req.Header == nil {
req.Header = make(Header)
}
req.Header.Set("Authorization", "Basic "+base64.URLEncoding.EncodeToString([]byte(info))) req.Header.Set("Authorization", "Basic "+base64.URLEncoding.EncodeToString([]byte(info)))
} }
return t.RoundTrip(req) return t.RoundTrip(req)
...@@ -176,6 +173,10 @@ func (c *Client) doFollowingRedirects(ireq *Request) (r *Response, err os.Error) ...@@ -176,6 +173,10 @@ func (c *Client) doFollowingRedirects(ireq *Request) (r *Response, err os.Error)
} }
var via []*Request var via []*Request
if ireq.URL == nil {
return nil, os.NewError("http: nil Request.URL")
}
req := ireq req := ireq
urlStr := "" // next relative or absolute URL to fetch (after first request) urlStr := "" // next relative or absolute URL to fetch (after first request)
for redirect := 0; ; redirect++ { for redirect := 0; ; redirect++ {
......
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