Skip to content

Commit

Permalink
Add a default handshake timeout of 5 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranza authored and garyburd committed Mar 6, 2018
1 parent e426f23 commit 196b8d0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufS
NetDial: func(net, addr string) (net.Conn, error) {
return netConn, nil
},
HandshakeTimeout: 5 * time.Second,
}
return d.Dial(u.String(), requestHeader)
}
Expand Down Expand Up @@ -106,7 +107,8 @@ func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {

// DefaultDialer is a dialer with all fields set to the default values.
var DefaultDialer = &Dialer{
Proxy: http.ProxyFromEnvironment,
Proxy: http.ProxyFromEnvironment,
HandshakeTimeout: 5 * time.Second,
}

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

if d == nil {
d = &Dialer{
Proxy: http.ProxyFromEnvironment,
Proxy: http.ProxyFromEnvironment,
HandshakeTimeout: 5 * time.Second,
}
}

Expand Down

0 comments on commit 196b8d0

Please sign in to comment.