Description
On WASM, the standard http.Transfer
RoundTripper is not exposed for external use. Buildflags for wasm replace the standard implementation of RoundTripper with a special version that uses the browser Fetch API. The special JS RoundTripper does not seem to use or honor any of the documented settings provided by http.Transport
, such as Dial
or DialContext
. But the way the special JS RoundTripper is implemented as methods on http.Transport
, it prevents using the standard RoundTripper.
There are use cases for using the normal RoundTripper, for instance for testing and simulation in the browser. The normal RoundTripper is compiled and included in the binary anyway, and works perfectly well, but is masked by the browser version.
What version of Go are you using (go version
)?
go1.11
What operating system and processor architecture are you using (go env
)?
GOOS=js
GOARCH=wasm
What did you do?
I tried to configure a http.Client
to use a transport with a custom dial function:
https://play.golang.org/p/dnyTivQ643J
This works on all other platforms including the playground, but on WASM, the same, special Roundtripper is always used and there is no way to use the standard Roundtripper.
What did you expect to see?
Get https://api.ipify.org/: expected error, all ok
What did you see instead?
On WASM:
192.0.2.77
Done.
On other platforms, I get the expected result