Skip to content

net/http: conn not closed if Transport.OnProxyConnectResponse returns non-nil err #64804

Closed
@wm775825

Description

@wm775825

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)?

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\11749\AppData\Local\go-build
set GOENV=C:\Users\11749\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=E:\envs\go_path\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=E:\envs\go_path
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=E:\envs\go120
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=E:\envs\go120\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\11749\AppData\Local\Temp\go-build881946686=/tmp/go-build -gno-record-gcc-switches

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 anywhere conn 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.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions