Closed as not planned
Description
Go version
go1.22.5 darwin/arm64
Output of go env
in your module/workspace:
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/valera/Library/Caches/go-build'
GOENV='/Users/valera/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=' -mod=readonly'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/valera/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/valera/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/valera/GolandProjects/awesomeProject/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/t6/h2wwp5cx7rd7rk695g55_5tc0000gn/T/go-build2773577536=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
package main
import (
"net/http"
)
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
func handler(w http.ResponseWriter, r *http.Request) {
<-r.Context().Done()
println("finish") // this does not happen
}
What did you see happen?
If I send get-request with wrong Content-Length header, the server continues processing the request after the connection is lost. r.Context().Done() does not work in this case.
What did you expect to see?
r.Context().Done() returns value when the connection is closed.