Skip to content

Commit

Permalink
Feature/updated http2 transport (#209)
Browse files Browse the repository at this point in the history
* Update http2 transport
* Add ReadIdleTimeout for ping frames
* Update defaults for TCP Keepalive
  • Loading branch information
sideshow authored Apr 18, 2022
1 parent a09d4b5 commit 54928d6
Show file tree
Hide file tree
Showing 76 changed files with 66,677 additions and 7,182 deletions.
22 changes: 16 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,24 @@ const (
var DefaultHost = HostDevelopment

var (
// TLSDialTimeout is the maximum amount of time a dial will wait for a connect
// to complete.
TLSDialTimeout = 20 * time.Second
// HTTPClientTimeout specifies a time limit for requests made by the
// HTTPClient. The timeout includes connection time, any redirects,
// and reading the response body.
HTTPClientTimeout = 60 * time.Second

// ReadIdleTimeout is the timeout after which a health check using a ping
// frame will be carried out if no frame is received on the connection. If
// zero, no health check is performed.
ReadIdleTimeout = 15 * time.Second

// TCPKeepAlive specifies the keep-alive period for an active network
// connection. If zero, keep-alives are not enabled.
TCPKeepAlive = 60 * time.Second
// connection. If zero, keep-alive probes are sent with a default value
// (currently 15 seconds)
TCPKeepAlive = 15 * time.Second

// TLSDialTimeout is the maximum amount of time a dial will wait for a connect
// to complete.
TLSDialTimeout = 20 * time.Second
)

// DialTLS is the default dial function for creating TLS connections for
Expand Down Expand Up @@ -90,6 +98,7 @@ func NewClient(certificate tls.Certificate) *Client {
transport := &http2.Transport{
TLSClientConfig: tlsConfig,
DialTLS: DialTLS,
ReadIdleTimeout: ReadIdleTimeout,
}
return &Client{
HTTPClient: &http.Client{
Expand All @@ -111,7 +120,8 @@ func NewClient(certificate tls.Certificate) *Client {
// connection and disconnection as a denial-of-service attack.
func NewTokenClient(token *token.Token) *Client {
transport := &http2.Transport{
DialTLS: DialTLS,
DialTLS: DialTLS,
ReadIdleTimeout: ReadIdleTimeout,
}
return &Client{
Token: token,
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/golang-jwt/jwt/v4 v4.4.1
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20170512130425-ab89591268e0
golang.org/x/net v0.0.0-20170513003010-84f0e6f92b10
golang.org/x/text v0.0.0-20170512150324-19e51611da83 // indirect
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20170512130425-ab89591268e0 h1:Kv0JVjoWyBVkLETNHnV/PxoZcMP3J7+WTc6+QQnzZmY=
golang.org/x/crypto v0.0.0-20170512130425-ab89591268e0/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20170513003010-84f0e6f92b10 h1:ZKvORbFCQlZvHCWzpNCaToNXamq9BJj6rIodfQM1zfY=
golang.org/x/net v0.0.0-20170513003010-84f0e6f92b10/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/text v0.0.0-20170512150324-19e51611da83 h1:1TA+B31OuEXnREJvJGorXrP4eXsCfmfTHP4S4d4jzLQ=
golang.org/x/text v0.0.0-20170512150324-19e51611da83/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b h1:vI32FkLJNAWtGD4BwkThwEy6XS7ZLLMHkSkYfF8M0W0=
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
50 changes: 50 additions & 0 deletions vendor/golang.org/x/net/http/httpguts/guts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/net/http2/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions vendor/golang.org/x/net/http2/README

This file was deleted.

53 changes: 53 additions & 0 deletions vendor/golang.org/x/net/http2/ascii.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/net/http2/ciphers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 54928d6

Please sign in to comment.