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: double Content-Length in Response.Write on POST/PUT Request #8180

Closed
bradfitz opened this issue Jun 10, 2014 · 4 comments
Closed
Milestone

Comments

@bradfitz
Copy link
Contributor

From golang-dev:

"""
Matthew Endsley:

I was testing the go1.3rc1 release on our codebase and found it failed one of our test
cases involving http responses.

It appears that in some cases, http.Response.Write will emit 2 Content-Length headers. A
short example the reproduces the behavior can be found here:
http://play.golang.org/p/qsH1MeVSHu

In go 1.2 this generated the following output:
HTTP/1.1 200 OK
Content-Length: 0

In go1.3rc1 I'm getting the following:
HTTP/1.1 200 OK
Content-Length: 0
Content-Length: 0

For reference, on current tip (087e446f2c41) I see the same output as go1.3rc1

As a side note, this issue only occurs if response.Request.Method is "POST".
If the request method is "GET" the duplicate Content-Length is not emitted.
"""



The problem was introduced in revision b2ebbbcfc615 for fixing issue #5381. The net/http
Server doesn't use this code, but it is a regression from 1.2.  In the earlier fix, I
didn't take care of the case where PUT/POST were special-cased in transfer.go ages ago
in revision 4d792b5bea35 for HTTP Requests, but the transfer code deals with both
Requests and Responses, so a Content-Length of length 0 was always being sent for
Responses too.  That code deserves a second look in Go 1.4, but will fix minimally for
now.
@bradfitz
Copy link
Contributor Author

Comment 1:

https://golang.org/cl/105040043/

@bradfitz
Copy link
Contributor Author

Comment 2:

This issue was closed by revision 1e6a19b.

Status changed to Fixed.

@gopherbot
Copy link

Comment 3:

CL https://golang.org/cl/102300046 mentions this issue.

@rsc
Copy link
Contributor

rsc commented Jun 11, 2014

Comment 4:

This issue was closed by revision 666a2a092e50.

@bradfitz bradfitz self-assigned this Jun 11, 2014
@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
rsc added a commit that referenced this issue May 11, 2015
««« CL 105040043 / ef8878dbed3b
net/http: fix double Content-Length in response

Fixes #8180

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/105040043
»»»

TBR=bradfitz
R=golang-codereviews
CC=bradfitz, golang-codereviews, iant
https://golang.org/cl/102300046
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants