client: Close connection on error

This commit is contained in:
Adnan Maolood 2021-03-20 12:49:27 -04:00
parent 5141eaafaa
commit d5af32e121
1 changed files with 3 additions and 0 deletions

View File

@ -131,6 +131,9 @@ func (c *Client) Do(ctx context.Context, req *Request) (*Response, error) {
conn.Close()
return nil, ctx.Err()
case r := <-res:
if r.err != nil {
conn.Close()
}
return r.resp, r.err
}
}