net/http: correct use of byte slice in js syscall

syscall/js does not allow []byte to be used in direct inputs to
its JavaScript manipulation methods since
bafe466a95.
Unfortunately, this use of a byte slice was missed, so any
uses of the WASM Roundtripper with a body will panic.
This ensures the byte slice is appropriately converted
before being passed to syscall.

Fixes #26349
This commit is contained in:
Johan Brandhorst 2018-07-12 12:18:04 +01:00
parent 3df1f00bfc
commit 3914bda2ff
1 changed files with 3 additions and 1 deletions

View File

@ -60,7 +60,9 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) {
return nil, err
}
req.Body.Close()
opt.Set("body", body)
a := js.TypedArrayOf(body)
defer a.Release()
opt.Set("body", a)
}
respPromise := js.Global().Call("fetch", req.URL.String(), opt)
var (