mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/http: make Client propagate Request.Cancel over redirected requests
On HTTP redirect, the HTTP client creates a new request and don't copy over the Cancel channel. This prevents any redirected request from being cancelled. Fixes #14053 Change-Id: I467cdd4aadcae8351b6e9733fc582b7985b8b9d3 Reviewed-on: https://go-review.googlesource.com/18810 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
33a784e1f7
commit
f8f4cfa5be
2 changed files with 18 additions and 1 deletions
|
|
@ -445,6 +445,7 @@ func (c *Client) doFollowingRedirects(ireq *Request, shouldRedirect func(int) bo
|
|||
for redirect := 0; ; redirect++ {
|
||||
if redirect != 0 {
|
||||
nreq := new(Request)
|
||||
nreq.Cancel = ireq.Cancel
|
||||
nreq.Method = ireq.Method
|
||||
if ireq.Method == "POST" || ireq.Method == "PUT" {
|
||||
nreq.Method = "GET"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue