Open
Description
Go version
go version go1.23.4 linux/amd64
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE='pkg.go'
GOMODCACHE='/root/go/pkg/mod'
GOOS='linux'
GOPATH='/root/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/linuxbrew/.linuxbrew/Cellar/go/1.23.4/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/linuxbrew/.linuxbrew/Cellar/go/1.23.4/libexec/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/root/gotests/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 -ffile-prefix-map=/tmp/go-build670266472=/tmp/go-build -gno-record-gcc-switches'
What did you do?
I encountered a situation where http.Client.Timeout doesn't work as expected when reading response body from an incomplete/fake WebSocket handshake response. Here's a minimal reproduction:
https://go.dev/play/p/i0mxl_6BaZR
What did you see happen?
The client appears to be permanently blocked when reading the response body despite having a client timeout set. The timeout doesn't trigger as expected, and the operation hangs indefinitely.
What did you expect to see?
When reading the response body from an incomplete WebSocket handshake (where server sends handshake headers but no data afterwards), the http.Client.Timeout setting should trigger after the specified timeout duration (5 seconds in this case) while reading the body.