1
0
mirror of https://github.com/golang/go synced 2024-11-24 12:10:03 -07:00

net/http: only disable fetch in test

This commit is contained in:
Zxilly 2024-09-05 23:11:52 +08:00
parent 1b5ae45181
commit fb4bdb64e0
No known key found for this signature in database
GPG Key ID: 47AB1DEC841BC6A2

View File

@ -12,8 +12,8 @@ import (
"io"
"net/http/internal/ascii"
"strconv"
"strings"
"syscall/js"
"testing"
)
var uint8Array = js.Global().Get("Uint8Array")
@ -53,8 +53,7 @@ var jsFetchMissing = js.Global().Get("fetch").IsUndefined()
//
// TODO(go.dev/issue/60810): See if it's viable to test the Fetch API
// code path.
var jsFetchDisabled = js.Global().Get("process").Type() == js.TypeObject &&
strings.HasPrefix(js.Global().Get("process").Get("argv0").String(), "node")
var jsFetchDisabled = testing.Testing()
// RoundTrip implements the [RoundTripper] interface using the WHATWG Fetch API.
func (t *Transport) RoundTrip(req *Request) (*Response, error) {