diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2015-12-17 19:36:43 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2015-12-17 20:21:44 +0000 |
| commit | 18227bb7b6ce14c2736543777f1d5cebeff11abd (patch) | |
| tree | 6d3444eb85c0612b0324d3b6a535e16d3382f8cb /src/net/http/client.go | |
| parent | 761ac75a948e14fcd8472684effedf75f3fc316e (diff) | |
| download | go-18227bb7b6ce14c2736543777f1d5cebeff11abd.tar.xz | |
net/http: be more consistent about Request.Method "" vs "GET"
Patch from Russ.
No bug identified, but I didn't search exhaustively. The new code is
easier to read.
Fixes #13621
Change-Id: Ifda936e4101116fa254ead950b5fe06adb14e977
Reviewed-on: https://go-review.googlesource.com/17981
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/net/http/client.go')
| -rw-r--r-- | src/net/http/client.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/net/http/client.go b/src/net/http/client.go index c3f849e962..dd099bb316 100644 --- a/src/net/http/client.go +++ b/src/net/http/client.go @@ -179,10 +179,11 @@ 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 == "" || req.Method == "GET" || req.Method == "HEAD" { + method := valueOrDefault(req.Method, "GET") + if method == "" || method == "GET" || method == "HEAD" { return c.doFollowingRedirects(req, shouldRedirectGet) } - if req.Method == "POST" || req.Method == "PUT" { + if method == "POST" || method == "PUT" { return c.doFollowingRedirects(req, shouldRedirectPost) } return c.send(req) |
