Skip to content

Commit db1514c

Browse files
committed
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 <[email protected]> Reviewed-by: Richard Musiol <[email protected]>
1 parent a27ede0 commit db1514c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/net/http/roundtrip_js.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) {
138138
body = &arrayReader{arrayPromise: result.Call("arrayBuffer")}
139139
}
140140

141+
code := result.Get("status").Int()
141142
select {
142143
case respCh <- &Response{
143-
Status: result.Get("status").String() + " " + StatusText(result.Get("status").Int()),
144-
StatusCode: result.Get("status").Int(),
144+
Status: fmt.Sprintf("%d %s", code, StatusText(code)),
145+
StatusCode: code,
145146
Header: header,
146147
ContentLength: contentLength,
147148
Body: body,

0 commit comments

Comments
 (0)