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: HEAD request doesn't populate Response.ContentLength #4126

Closed
bradfitz opened this issue Sep 21, 2012 · 3 comments
Closed

net/http: HEAD request doesn't populate Response.ContentLength #4126

bradfitz opened this issue Sep 21, 2012 · 3 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

If a handler replies to a HEAD request with a Content-Length field, the *Response
contains the "Content-Length: 1234" header, but the ContentLength field is
zero.

The docs say:

type Response struct {
...
    // ContentLength records the length of the associated content.  The
    // value -1 indicates that the length is unknown.  Unless RequestMethod
    // is "HEAD", values >= 0 indicate that the given number of bytes may
    // be read from Body.
    ContentLength int64
}

... suggesting that we should be setting it when we know it.

Related, Response.Write should write the correct length.  Currently the one in the
header map is being ignored in favor of the zero.
@rsc
Copy link
Contributor

rsc commented Oct 6, 2012

Comment 1:

Labels changed: added go1.1.

@bradfitz
Copy link
Contributor Author

bradfitz commented Dec 4, 2012

Comment 2:

https://golang.org/cl/6869053

Status changed to Started.

@bradfitz
Copy link
Contributor Author

bradfitz commented Dec 6, 2012

Comment 3:

This issue was closed by revision 53d091c.

Status changed to Fixed.

@bradfitz bradfitz self-assigned this Dec 6, 2012
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
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