net/http: conn not closed if Transport.OnProxyConnectResponse returns non-nil err #64804
Labels
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Go version
go 1.20 and 1.21, no matter what minor version or arch is.
What operating system and processor architecture are you using (
go env
)?What did you do?
issue #54299 introduced Transport.OnProxyConnectResponse to find out how a CONNECT request to a proxy failed. (HTTP 403, etc).
So i customized my OnProxyConnectResponse to produce a non-nil error and then it returned the error.
However, there is no call to
conn.Close
before it returns, which is present at anywhereconn
is in scope and return happens. And this may cause resource leak.What did you expect to see?
When OnProxyConnectResponse returns with a non-nil error,
conn.Close
should be called before return.What did you see instead?
When OnProxyConnectResponse returns with a non-nil error, there is no
conn.Close
before return.The text was updated successfully, but these errors were encountered: