Skip to content
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

net/http: response.ContentLength is only considering header key "Content-Length" case sensitive #65604

Closed
akrieg-ionos opened this issue Feb 8, 2024 · 5 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@akrieg-ionos
Copy link

Go version

go version go1.22.0 linux/amd64

Output of go env in your module/workspace:

go env
GO111MODULE='on'                                                                                                                                                                                                                                 ─╯
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/akrieg/.cache/go-build'
GOENV='/home/akrieg/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/akrieg/go/pkg/mod'
GONOPROXY='github.com/ionos-cloud'
GONOSUMDB='github.com/ionos-cloud'
GOOS='linux'
GOPATH='/home/akrieg/go'
GOPRIVATE='github.com/ionos-cloud'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/akrieg/projects/paas/paaskit/go-paaskit/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-build3927774349=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I want to use response.ContentLength attribute.

What did you see happen?

If the response header has e.g. the key content-length response.ContentLength is not set as only "Content-Length" is taken into account.

What did you expect to see?

However afaik header keys are case insensitive. So, if a response contains Content-Length or e.g. content-length as header should make no difference regarding the response.ContentLength attribute.

@seankhliao
Copy link
Member

how are you setting content length?
https://pkg.go.dev/net/http#Header documents the expected storage case, while the methods accept case insensitive input and convert accordingly.

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 8, 2024
@jeeftor
Copy link

jeeftor commented Feb 8, 2024

I'll say I noticed header-keys are case intensive as well... - I even wrote some tests to validate it :)

@akrieg-ionos
Copy link
Author

I will try to proof my hypothesis with a test. If I fail, I will close this issue.

@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Feb 9, 2024
@danp
Copy link
Contributor

danp commented Feb 11, 2024

@akrieg-ionos pretty sure any keys in header at that point would have been canonicalized:

key := http2canonicalHeader(hf.Name)

@akrieg-ionos
Copy link
Author

@danp @seankhliao @jeeftor indeed i am wrong with my hypothesis, so i close this. Sorry for the noise and thanks for the feedback. 💐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants