diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2015-12-03 18:58:05 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2015-12-03 19:53:44 +0000 |
| commit | a778ac5d76c47f6cc88846d58263c63ae8eaec86 (patch) | |
| tree | aa56890ecb48f182beadefcad23e1d0d3a48c64c /src/net/http/client.go | |
| parent | 723605e9183314e977542fdca208f4ddeb5425f7 (diff) | |
| download | go-a778ac5d76c47f6cc88846d58263c63ae8eaec86.tar.xz | |
net/http: make Client follow redirects even if Request.Method is empty
Fixes #12705
Change-Id: I69639d2b03777835b2697ff349a00ccab410aa49
Reviewed-on: https://go-review.googlesource.com/17318
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/client.go')
| -rw-r--r-- | src/net/http/client.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/net/http/client.go b/src/net/http/client.go index 47f145a0ca..3a8b284859 100644 --- a/src/net/http/client.go +++ b/src/net/http/client.go @@ -172,7 +172,7 @@ func (c *Client) send(req *Request) (*Response, error) { // // Generally Get, Post, or PostForm will be used instead of Do. func (c *Client) Do(req *Request) (resp *Response, err error) { - if req.Method == "GET" || req.Method == "HEAD" { + if req.Method == "" || req.Method == "GET" || req.Method == "HEAD" { return c.doFollowingRedirects(req, shouldRedirectGet) } if req.Method == "POST" || req.Method == "PUT" { @@ -423,6 +423,9 @@ func (c *Client) doFollowingRedirects(ireq *Request, shouldRedirect func(int) bo } method := ireq.Method + if method == "" { + method = "GET" + } urlErr := &url.Error{ Op: method[0:1] + strings.ToLower(method[1:]), URL: urlStr, |
