mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/http: update Response.Request.URL after redirects on GOOS=js
Fixes #71346 Change-Id: Id4053626e621faf50bb88a10ca0d540f393c8e01 Reviewed-on: https://go-review.googlesource.com/c/go/+/720860 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
This commit is contained in:
parent
7aa9ca729f
commit
87269224cb
1 changed files with 8 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http/internal/ascii"
|
"net/http/internal/ascii"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall/js"
|
"syscall/js"
|
||||||
|
|
@ -195,6 +196,13 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) {
|
||||||
uncompressed = true
|
uncompressed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if result.Get("redirected").Bool() {
|
||||||
|
u, err := url.Parse(result.Get("url").String())
|
||||||
|
if err == nil {
|
||||||
|
req = req.Clone(req.ctx)
|
||||||
|
req.URL = u
|
||||||
|
}
|
||||||
|
}
|
||||||
respCh <- &Response{
|
respCh <- &Response{
|
||||||
Status: fmt.Sprintf("%d %s", code, StatusText(code)),
|
Status: fmt.Sprintf("%d %s", code, StatusText(code)),
|
||||||
StatusCode: code,
|
StatusCode: code,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue