Skip to content

Commit 196b8d0

Browse files
pcarranzagaryburd
authored andcommitted
Add a default handshake timeout of 5 seconds
1 parent e426f23 commit 196b8d0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufS
4141
NetDial: func(net, addr string) (net.Conn, error) {
4242
return netConn, nil
4343
},
44+
HandshakeTimeout: 5 * time.Second,
4445
}
4546
return d.Dial(u.String(), requestHeader)
4647
}
@@ -106,7 +107,8 @@ func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
106107

107108
// DefaultDialer is a dialer with all fields set to the default values.
108109
var DefaultDialer = &Dialer{
109-
Proxy: http.ProxyFromEnvironment,
110+
Proxy: http.ProxyFromEnvironment,
111+
HandshakeTimeout: 5 * time.Second,
110112
}
111113

112114
// Dial creates a new client connection. Use requestHeader to specify the
@@ -122,7 +124,8 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
122124

123125
if d == nil {
124126
d = &Dialer{
125-
Proxy: http.ProxyFromEnvironment,
127+
Proxy: http.ProxyFromEnvironment,
128+
HandshakeTimeout: 5 * time.Second,
126129
}
127130
}
128131

0 commit comments

Comments
 (0)