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: Content-Type is set even with empty body #20784
Comments
Sure, seems fine to change. It's harmless as-is and not wrong, but not sending it saves some bandwidth at least. Feel free to send a change + test: see https://tip.golang.org/doc/contribute.html |
CL https://golang.org/cl/46631 mentions this issue. |
@bradfitz Yes, it's alright in most cases, but some clients don't expect this header when they encounter a response with a empty blank. I find this when resolving this caddy issue. |
Change https://golang.org/cl/80135 mentions this issue: |
This change was originally made in https://golang.org/cl/46631, however, that change was applited to net/http/h2_bundle.go instead of x/net/http2. Updates golang/go#20784 Change-Id: I947fa4c19f3efc400856573768140bece28276a2 Reviewed-on: https://go-review.googlesource.com/80135 Run-TryBot: Tom Bergan <tombergan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Change https://golang.org/cl/80078 mentions this issue: |
Update http2 to x/net git rev db473f6b23. (And un-skip TestWriteHeader0_h2 added in CL 80077, now fixed.) Includes: http2: remove afterReqBodyWriteError wrapper https://golang.org/cl/75252 http2: fix transport data race on reused *http.Request objects https://golang.org/cl/75530 http2: require either ECDSA or RSA ciphersuite https://golang.org/cl/30721 http2: don't log about timeouts reading client preface on new connections https://golang.org/cl/79498 http2: don't crash in Transport on server's DATA following bogus HEADERS https://golang.org/cl/80056 http2: panic on invalid WriteHeader status code https://golang.org/cl/80076 http2: fix race on ClientConn.maxFrameSize https://golang.org/cl/79238 http2: don't autodetect Content-Type when the response has an empty body https://golang.org/cl/80135 Fixes #18776 Updates #20784 Fixes #21316 Fixes #22721 Fixes #22880 Change-Id: Ie86e24e0ee2582a5a82afe5de3c7c801528be069 Reviewed-on: https://go-review.googlesource.com/80078 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tom Bergan <tombergan@google.com>
Change https://golang.org/cl/82016 mentions this issue: |
Change https://golang.org/cl/82017 mentions this issue: |
Go 1.10 no longer sets implicit Content-Type on empty output. Updates golang/go#20784 Change-Id: I3f13f76b94b58869481218ea2e1805f5f4175fd7 Reviewed-on: https://go-review.googlesource.com/82017 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Updates #20784 Change-Id: Ic07c78a86da5026e407ac9ecb3117d320c198048 Reviewed-on: https://go-review.googlesource.com/82016 Reviewed-by: Andrew Bonventre <andybons@golang.org>
Change https://golang.org/cl/93695 mentions this issue: |
Updates #20784 Change-Id: Ic07c78a86da5026e407ac9ecb3117d320c198048 Reviewed-on: https://go-review.googlesource.com/93695 Reviewed-by: Andrew Bonventre <andybons@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This change was originally made in https://golang.org/cl/46631, however, that change was applited to net/http/h2_bundle.go instead of x/net/http2. Updates golang/go#20784 Change-Id: I947fa4c19f3efc400856573768140bece28276a2 Reviewed-on: https://go-review.googlesource.com/80135 Run-TryBot: Tom Bergan <tombergan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Update http2 to x/net git rev db473f6b23. (And un-skip TestWriteHeader0_h2 added in CL 80077, now fixed.) Includes: http2: remove afterReqBodyWriteError wrapper https://golang.org/cl/75252 http2: fix transport data race on reused *http.Request objects https://golang.org/cl/75530 http2: require either ECDSA or RSA ciphersuite https://golang.org/cl/30721 http2: don't log about timeouts reading client preface on new connections https://golang.org/cl/79498 http2: don't crash in Transport on server's DATA following bogus HEADERS https://golang.org/cl/80056 http2: panic on invalid WriteHeader status code https://golang.org/cl/80076 http2: fix race on ClientConn.maxFrameSize https://golang.org/cl/79238 http2: don't autodetect Content-Type when the response has an empty body https://golang.org/cl/80135 Fixes golang/go#18776 Updates golang/go#20784 Fixes golang/go#21316 Fixes golang/go#22721 Fixes golang/go#22880 Change-Id: Ie86e24e0ee2582a5a82afe5de3c7c801528be069 Reviewed-on: https://go-review.googlesource.com/80078 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tom Bergan <tombergan@google.com>
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +1948b7f Wed May 31 10:28:05 2017 +0000 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tw/golib"
GORACE=""
GOROOT="/home/tw/goroot"
GOTOOLDIR="/home/tw/goroot/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build555764928=/tmp/go-build -gno-record-gcc-switches"
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
What did you do?
What did you expect to see?
Content-Type should not be set with empty content.
What did you see instead?
Content-Type is set automatically by Go http server.
I suppose this patch should work:
Any thoughts ?
The text was updated successfully, but these errors were encountered: