handle request cancelations while waiting for handshake completion

This commit is contained in:
Marten Seemann
2020-01-26 11:08:36 +07:00
parent 639925628d
commit af1e8f4c78
3 changed files with 23 additions and 2 deletions

View File

@@ -101,7 +101,6 @@ func (c *client) dial() error {
}
}()
<-c.session.HandshakeComplete().Done()
return nil
}
@@ -151,6 +150,13 @@ func (c *client) RoundTrip(req *http.Request) (*http.Response, error) {
return nil, c.handshakeErr
}
// wait for the handshake to complete
select {
case <-c.session.HandshakeComplete().Done():
case <-req.Context().Done():
return nil, req.Context().Err()
}
str, err := c.session.OpenStreamSync(req.Context())
if err != nil {
return nil, err