Skip to content

Commit

Permalink
Merge pull request #53 from treydock/timeouts
Browse files Browse the repository at this point in the history
Support changing TLS handshake timeout
  • Loading branch information
stmcginnis authored Jan 29, 2020
2 parents 8eccafd + cfef2fb commit 1119f8b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"net/http/httputil"

"strings"
"time"

"github.com/stmcginnis/gofish/common"
"github.com/stmcginnis/gofish/redfish"
Expand Down Expand Up @@ -56,6 +57,9 @@ type ClientConfig struct {
// Insecure controls whether to enforce SSL certificate validity.
Insecure bool

// Controls TLS handshake timeout
TLSHandshakeTimeout int

// HTTPClient is the optional client to connect with.
HTTPClient *http.Client

Expand All @@ -76,6 +80,10 @@ func Connect(config ClientConfig) (c *APIClient, err error) {
dumpWriter: config.DumpWriter,
}

if config.TLSHandshakeTimeout == 0 {
config.TLSHandshakeTimeout = 10
}

if config.HTTPClient == nil {
defaultTransport := http.DefaultTransport.(*http.Transport)
transport := &http.Transport{
Expand All @@ -84,7 +92,7 @@ func Connect(config ClientConfig) (c *APIClient, err error) {
MaxIdleConns: defaultTransport.MaxIdleConns,
IdleConnTimeout: defaultTransport.IdleConnTimeout,
ExpectContinueTimeout: defaultTransport.ExpectContinueTimeout,
TLSHandshakeTimeout: defaultTransport.TLSHandshakeTimeout,
TLSHandshakeTimeout: time.Duration(config.TLSHandshakeTimeout) * time.Second,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: config.Insecure,
},
Expand Down

0 comments on commit 1119f8b

Please sign in to comment.