mirror of https://github.com/golang/go.git
Don't specify DialContext by default on js/wasm for DefaultTransport
This commit is contained in:
parent
911ba26f91
commit
23ee196fce
1
AUTHORS
1
AUTHORS
|
|
@ -1015,6 +1015,7 @@ Nathan Youngman <git@nathany.com>
|
|||
Nathaniel Cook <nvcook42@gmail.com>
|
||||
Naveen Kumar Sangi <naveenkumarsangi@protonmail.com>
|
||||
Neelesh Chandola <neelesh.c98@gmail.com>
|
||||
Neil Alexander <neilalexander@neilalexander.dev>
|
||||
Neil Lyons <nwjlyons@googlemail.com>
|
||||
Netflix, Inc.
|
||||
Neuman Vong <neuman.vong@gmail.com>
|
||||
|
|
|
|||
|
|
@ -1812,6 +1812,7 @@ Naveen Kumar Sangi <naveenkumarsangi@protonmail.com>
|
|||
Neeilan Selvalingam <neeilan96@gmail.com>
|
||||
Neelesh Chandola <neelesh.c98@gmail.com>
|
||||
Nehal J Wani <nehaljw.kkd1@gmail.com>
|
||||
Neil Alexander <neilalexander@neilalexander.dev>
|
||||
Neil Lyons <nwjlyons@googlemail.com>
|
||||
Neuman Vong <neuman.vong@gmail.com>
|
||||
Neven Sajko <nsajko@gmail.com>
|
||||
|
|
|
|||
|
|
@ -35,24 +35,6 @@ import (
|
|||
"golang.org/x/net/http/httpproxy"
|
||||
)
|
||||
|
||||
// DefaultTransport is the default implementation of Transport and is
|
||||
// used by DefaultClient. It establishes network connections as needed
|
||||
// and caches them for reuse by subsequent calls. It uses HTTP proxies
|
||||
// as directed by the $HTTP_PROXY and $NO_PROXY (or $http_proxy and
|
||||
// $no_proxy) environment variables.
|
||||
var DefaultTransport RoundTripper = &Transport{
|
||||
Proxy: ProxyFromEnvironment,
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).DialContext,
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}
|
||||
|
||||
// DefaultMaxIdleConnsPerHost is the default value of Transport's
|
||||
// MaxIdleConnsPerHost.
|
||||
const DefaultMaxIdleConnsPerHost = 2
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package http
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// DefaultTransport is the default implementation of Transport and is
|
||||
// used by DefaultClient. It uses HTTP proxies as directed by the
|
||||
// $HTTP_PROXY and $NO_PROXY (or $http_proxy and $no_proxy) environment
|
||||
// variables. No default dialer is specified as the Fetch API will be
|
||||
// used in RoundTrip if not specified.
|
||||
var DefaultTransport RoundTripper = &Transport{
|
||||
Proxy: ProxyFromEnvironment,
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !js || !wasm
|
||||
// +build !js !wasm
|
||||
|
||||
package http
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DefaultTransport is the default implementation of Transport and is
|
||||
// used by DefaultClient. It establishes network connections as needed
|
||||
// and caches them for reuse by subsequent calls. It uses HTTP proxies
|
||||
// as directed by the $HTTP_PROXY and $NO_PROXY (or $http_proxy and
|
||||
// $no_proxy) environment variables.
|
||||
var DefaultTransport RoundTripper = &Transport{
|
||||
Proxy: ProxyFromEnvironment,
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).DialContext,
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}
|
||||
Loading…
Reference in New Issue