mirror of
https://github.com/golang/go.git
synced 2026-01-29 07:02:05 +03: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:
@@ -11,6 +11,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http/internal/ascii"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall/js"
|
||||
@@ -195,6 +196,13 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) {
|
||||
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{
|
||||
Status: fmt.Sprintf("%d %s", code, StatusText(code)),
|
||||
StatusCode: code,
|
||||
|
||||
Reference in New Issue
Block a user