Skip to content

Commit 1119f8b

Browse files
authored
Merge pull request #53 from treydock/timeouts
Support changing TLS handshake timeout
2 parents 8eccafd + cfef2fb commit 1119f8b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

client.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"net/http/httputil"
1616

1717
"strings"
18+
"time"
1819

1920
"github.com/stmcginnis/gofish/common"
2021
"github.com/stmcginnis/gofish/redfish"
@@ -56,6 +57,9 @@ type ClientConfig struct {
5657
// Insecure controls whether to enforce SSL certificate validity.
5758
Insecure bool
5859

60+
// Controls TLS handshake timeout
61+
TLSHandshakeTimeout int
62+
5963
// HTTPClient is the optional client to connect with.
6064
HTTPClient *http.Client
6165

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

83+
if config.TLSHandshakeTimeout == 0 {
84+
config.TLSHandshakeTimeout = 10
85+
}
86+
7987
if config.HTTPClient == nil {
8088
defaultTransport := http.DefaultTransport.(*http.Transport)
8189
transport := &http.Transport{
@@ -84,7 +92,7 @@ func Connect(config ClientConfig) (c *APIClient, err error) {
8492
MaxIdleConns: defaultTransport.MaxIdleConns,
8593
IdleConnTimeout: defaultTransport.IdleConnTimeout,
8694
ExpectContinueTimeout: defaultTransport.ExpectContinueTimeout,
87-
TLSHandshakeTimeout: defaultTransport.TLSHandshakeTimeout,
95+
TLSHandshakeTimeout: time.Duration(config.TLSHandshakeTimeout) * time.Second,
8896
TLSClientConfig: &tls.Config{
8997
InsecureSkipVerify: config.Insecure,
9098
},

0 commit comments

Comments
 (0)