diff options
| author | Dmitri Shuralyov <dmitshur@golang.org> | 2019-04-29 00:23:16 -0400 |
|---|---|---|
| committer | Dmitri Shuralyov <dmitshur@golang.org> | 2019-04-29 15:23:10 +0000 |
| commit | db1514cbf242fccbb9e17ecae280ec5e829b1ed6 (patch) | |
| tree | b3702111c8b46e32b6b275eec2ceeacf95499c79 /src | |
| parent | a27ede0ba9cd038582ea459f3c0e8419af4a2b88 (diff) | |
| download | go-db1514cbf242fccbb9e17ecae280ec5e829b1ed6.tar.xz | |
net/http: remove "number:" from Response.Status string
The behavior of Value.String method on non-string JavaScript types has
changed after CL 169757.
Update the implementation of Transport.RoundTrip method to construct the
Response.Status string without relying on result.Get("status").String(),
since that now returns strings like "<number: 200>" instead of "200".
Fixes #31736
Change-Id: I27b3e6cc95aa65fd1918b1400e88478a154aad12
Reviewed-on: https://go-review.googlesource.com/c/go/+/174218
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/http/roundtrip_js.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/net/http/roundtrip_js.go b/src/net/http/roundtrip_js.go index 21d19515fa..7d965f844f 100644 --- a/src/net/http/roundtrip_js.go +++ b/src/net/http/roundtrip_js.go @@ -138,10 +138,11 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { body = &arrayReader{arrayPromise: result.Call("arrayBuffer")} } + code := result.Get("status").Int() select { case respCh <- &Response{ - Status: result.Get("status").String() + " " + StatusText(result.Get("status").Int()), - StatusCode: result.Get("status").Int(), + Status: fmt.Sprintf("%d %s", code, StatusText(code)), + StatusCode: code, Header: header, ContentLength: contentLength, Body: body, |
