Skip to content

Commit 064062b

Browse files
net/http: fix build errors on js/wasm target
The in-progress WASM port does not yet have sufficient automatic testing performed against it, so these errors slipped through when adding the new Fetch API backed http.Roundtripper. Updates #25506
1 parent 41dd2eb commit 064062b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/net/http/roundtrip_js.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import (
1212
"io"
1313
"io/ioutil"
1414
"os"
15-
"path"
1615
"strconv"
16+
"strings"
1717
"syscall/js"
1818
)
1919

2020
// RoundTrip implements the RoundTripper interface using the WHATWG Fetch API.
21-
func (*Transport) RoundTrip(req *Request) (*Response, error) {
21+
func (t *Transport) RoundTrip(req *Request) (*Response, error) {
2222
if useFakeNetwork() {
2323
return t.roundTrip(req)
2424
}
@@ -134,10 +134,12 @@ func (*Transport) RoundTrip(req *Request) (*Response, error) {
134134
}
135135
}
136136

137+
var errClosed = errors.New("net/http: reader is closed")
138+
137139
// useFakeNetwork is used to determine whether the request is made
138140
// by a test and should be made to use the fake in-memory network.
139141
func useFakeNetwork() bool {
140-
return len(os.Args) > 0 && path.Base(os.Args[0]) == "node"
142+
return len(os.Args) > 0 && strings.HasSuffix(os.Args[0], ".test")
141143
}
142144

143145
// streamReader implements an io.ReadCloser wrapper for ReadableStream.

0 commit comments

Comments
 (0)