Skip to content

net/http: HTTP Client Stops Reading Body After Numerous Requests #66992

Closed as not planned
@maxinmos

Description

@maxinmos

Go version

go version go1.20 linux/amd64

Output of go env in your module/workspace:

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOENV="/home/me/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/me/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/me/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/me/sdk/go1.20"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/me/sdk/go1.20/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/me/projects/server/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2801465050=/tmp/go-build -gno-record-gcc-switches"

What did you do?

When using the http.Client in Go to download large files from the same host repeatedly. Notably, these requests take a considerable amount of time due to the download of large files.

`
client = &http.Client{}

res, err := client.Do(req)
if err != nil {
return
}
defer res.Body.Close()

`

What did you see happen?

The client hangs indefinitely when reading the response body after a significant number of requests. In the same process, If the http.Client is used to make requests to a different host, the response body is still successfully read, suggesting that the issue might be specific to requests made to the same host within the same process.

What did you expect to see?

The default http.Client should continue reading the response body for each request, regardless of the number of previous requests made to the same host

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions