Description
(related to #21389)
What version of Go are you using (go version
)?
I checked go version go1.10 linux/amd64
and go version go1.9.4 linux/amd64
, which behave the same.
Does this issue reproduce with the latest release?
Yeah.
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ubuntu/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ubuntu/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build665138149=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I set WriteTimeout
to some value, which was smaller than the time handler took to handle the request.
https://gist.github.com/WGH-/90bbfe656e63f6fa457db84f91384c41
curl '18.196.145.219:8080/foo?t=1.5s' -v
What did you expect to see?
Well, the documentation clearly states "It is reset whenever a new request's header is read.", after all. So strictly speaking, everything is working as intended.
However, I expected that WriteTimeout
would only timeout write calls that're taking too long, or at least that it would start ticking at the first write. It would make much more sense this way.
What did you see instead?
As soon as server tries to write anything, even it hasn't written anything before, assuming timeout is passed, it will close the connection.
curl: (52) Empty reply from server