Skip to content

net/http: get-request with wrong content-length header breaks context #68571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vmanukyan99 opened this issue Jul 24, 2024 · 3 comments
Closed
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@vmanukyan99
Copy link

vmanukyan99 commented Jul 24, 2024

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.

@dmitshur
Copy link
Member

CC @neild.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 25, 2024
@dmitshur dmitshur added this to the Backlog milestone Jul 25, 2024
@seankhliao
Copy link
Member

Duplicate of #33269

@seankhliao seankhliao marked this as a duplicate of #33269 Jul 26, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants