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

Comments

Projects
None yet
4 participants
@bradfitz
Copy link
Member

commented Aug 31, 2016

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

This comment has been minimized.

Copy link
Contributor

commented Aug 31, 2016

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

This comment has been minimized.

Copy link
Member Author

commented Aug 31, 2016

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member Author

commented Sep 1, 2016

@0xmohit, that test can be changed.

@gopherbot

This comment has been minimized.

Copy link

commented Sep 1, 2016

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

@gopherbot gopherbot closed this in 88ccb3c Sep 1, 2016

@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.
You can’t perform that action at this time.