fix: handle close errors
This commit is contained in:
@@ -38,7 +38,7 @@ func (rt *UtlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
|
||||
}, utls.HelloFirefox_120)
|
||||
|
||||
if err := uconn.HandshakeContext(req.Context()); err != nil {
|
||||
uconn.Close()
|
||||
_ = uconn.Close()
|
||||
return nil, fmt.Errorf("utls handshake: %w", err)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func (rt *UtlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
|
||||
t := &http2.Transport{}
|
||||
cc, err := t.NewClientConn(uconn)
|
||||
if err != nil {
|
||||
uconn.Close()
|
||||
_ = uconn.Close()
|
||||
return nil, fmt.Errorf("http2 client conn: %w", err)
|
||||
}
|
||||
return cc.RoundTrip(req)
|
||||
@@ -55,7 +55,7 @@ func (rt *UtlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
|
||||
|
||||
// Fallback to HTTP/1.1
|
||||
if err := req.Write(uconn); err != nil {
|
||||
uconn.Close()
|
||||
_ = uconn.Close()
|
||||
return nil, fmt.Errorf("http1 write: %w", err)
|
||||
}
|
||||
return http.ReadResponse(bufio.NewReader(uconn), req)
|
||||
|
||||
Reference in New Issue
Block a user