forked from quic-go/quic-go
http3: correctly handle closed clients (#3684)
* http3: use a mock roundTripCloser in tests * http3: correctly handle failed clients Specifically, * immediately remove a client when a request errored * if that error was an idle error, and the client was a reused client (from an earlier request that already completed the handshake), re-dial the connection
This commit is contained in:
@@ -68,7 +68,9 @@ type client struct {
|
||||
logger utils.Logger
|
||||
}
|
||||
|
||||
func newClient(hostname string, tlsConf *tls.Config, opts *roundTripperOpts, conf *quic.Config, dialer dialFunc) (*client, error) {
|
||||
var _ roundTripCloser = &client{}
|
||||
|
||||
func newClient(hostname string, tlsConf *tls.Config, opts *roundTripperOpts, conf *quic.Config, dialer dialFunc) (roundTripCloser, error) {
|
||||
if conf == nil {
|
||||
conf = defaultQuicConfig.Clone()
|
||||
} else if len(conf.Versions) == 0 {
|
||||
@@ -434,3 +436,15 @@ func (c *client) doRequest(req *http.Request, str quic.Stream, opt RoundTripOpt,
|
||||
|
||||
return res, requestError{}
|
||||
}
|
||||
|
||||
func (c *client) HandshakeComplete() bool {
|
||||
if c.conn == nil {
|
||||
return false
|
||||
}
|
||||
select {
|
||||
case <-c.conn.HandshakeComplete().Done():
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user