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.Write includes Content-Length header on 204s #16942

Closed
bradfitz opened this issue Aug 31, 2016 · 5 comments
Closed

net/http: Response.Write includes Content-Length header on 204s #16942

bradfitz opened this issue Aug 31, 2016 · 5 comments

Comments

@bradfitz
Copy link
Contributor

Apparently we send a Content-Length header on a 204 response:

https://play.golang.org/p/bxy_rEBy-s

A 204 can't have a body anyway, so the Content-Length is useless and misleading. (It might be a protocol violation? Haven't checked.)

@bradfitz bradfitz added this to the Go1.8 milestone Aug 31, 2016
@bradfitz bradfitz self-assigned this Aug 31, 2016
@freeformz
Copy link

https://tools.ietf.org/html/rfc7230#section-3.3.2

...
 A server MUST NOT send a Content-Length header field in any response
   with a status code of 1xx (Informational) or 204 (No Content).
...

@bradfitz
Copy link
Contributor Author

Oh, we're fine actually. This is a bug in Response.Write. It's correct on the network:

https://play.golang.org/p/ettdRyiOtn

@bradfitz bradfitz changed the title net/http: don't write Content-Length header on 204 response net/http: Response.Write includes Content-Length header on 204s Aug 31, 2016
@0xmohit
Copy link
Contributor

0xmohit commented Sep 1, 2016

Athough this appears to be specifically about 204, an existing test expects Content-Length with a status code of 1xx.

@bradfitz
Copy link
Contributor Author

bradfitz commented Sep 1, 2016

@0xmohit, that test can be changed.

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Sep 1, 2017
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

4 participants