Skip to content

Commit 54928d6

Browse files
authored
Feature/updated http2 transport (#209)
* Update http2 transport * Add ReadIdleTimeout for ping frames * Update defaults for TCP Keepalive
1 parent a09d4b5 commit 54928d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+66677
-7182
lines changed

client.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,24 @@ const (
2828
var DefaultHost = HostDevelopment
2929

3030
var (
31-
// TLSDialTimeout is the maximum amount of time a dial will wait for a connect
32-
// to complete.
33-
TLSDialTimeout = 20 * time.Second
3431
// HTTPClientTimeout specifies a time limit for requests made by the
3532
// HTTPClient. The timeout includes connection time, any redirects,
3633
// and reading the response body.
3734
HTTPClientTimeout = 60 * time.Second
35+
36+
// ReadIdleTimeout is the timeout after which a health check using a ping
37+
// frame will be carried out if no frame is received on the connection. If
38+
// zero, no health check is performed.
39+
ReadIdleTimeout = 15 * time.Second
40+
3841
// TCPKeepAlive specifies the keep-alive period for an active network
39-
// connection. If zero, keep-alives are not enabled.
40-
TCPKeepAlive = 60 * time.Second
42+
// connection. If zero, keep-alive probes are sent with a default value
43+
// (currently 15 seconds)
44+
TCPKeepAlive = 15 * time.Second
45+
46+
// TLSDialTimeout is the maximum amount of time a dial will wait for a connect
47+
// to complete.
48+
TLSDialTimeout = 20 * time.Second
4149
)
4250

4351
// DialTLS is the default dial function for creating TLS connections for
@@ -90,6 +98,7 @@ func NewClient(certificate tls.Certificate) *Client {
9098
transport := &http2.Transport{
9199
TLSClientConfig: tlsConfig,
92100
DialTLS: DialTLS,
101+
ReadIdleTimeout: ReadIdleTimeout,
93102
}
94103
return &Client{
95104
HTTPClient: &http.Client{
@@ -111,7 +120,8 @@ func NewClient(certificate tls.Certificate) *Client {
111120
// connection and disconnection as a denial-of-service attack.
112121
func NewTokenClient(token *token.Token) *Client {
113122
transport := &http2.Transport{
114-
DialTLS: DialTLS,
123+
DialTLS: DialTLS,
124+
ReadIdleTimeout: ReadIdleTimeout,
115125
}
116126
return &Client{
117127
Token: token,

go.mod

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/golang-jwt/jwt/v4 v4.4.1
99
github.com/stretchr/testify v1.7.0
1010
golang.org/x/crypto v0.0.0-20170512130425-ab89591268e0
11-
golang.org/x/net v0.0.0-20170513003010-84f0e6f92b10
12-
golang.org/x/text v0.0.0-20170512150324-19e51611da83 // indirect
11+
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b
1312
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1413
)

go.sum

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
1414
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1515
golang.org/x/crypto v0.0.0-20170512130425-ab89591268e0 h1:Kv0JVjoWyBVkLETNHnV/PxoZcMP3J7+WTc6+QQnzZmY=
1616
golang.org/x/crypto v0.0.0-20170512130425-ab89591268e0/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
17-
golang.org/x/net v0.0.0-20170513003010-84f0e6f92b10 h1:ZKvORbFCQlZvHCWzpNCaToNXamq9BJj6rIodfQM1zfY=
18-
golang.org/x/net v0.0.0-20170513003010-84f0e6f92b10/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
19-
golang.org/x/text v0.0.0-20170512150324-19e51611da83 h1:1TA+B31OuEXnREJvJGorXrP4eXsCfmfTHP4S4d4jzLQ=
20-
golang.org/x/text v0.0.0-20170512150324-19e51611da83/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
17+
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b h1:vI32FkLJNAWtGD4BwkThwEy6XS7ZLLMHkSkYfF8M0W0=
18+
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
19+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
20+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
21+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
22+
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
23+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
24+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
2125
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
2226
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
2327
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

vendor/golang.org/x/net/http/httpguts/guts.go

+50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/net/lex/httplex/httplex.go renamed to vendor/golang.org/x/net/http/httpguts/httplex.go

+7-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/net/http2/Dockerfile

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/net/http2/README

-20
This file was deleted.

vendor/golang.org/x/net/http2/ascii.go

+53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/net/http2/ciphers.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)