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: treat HEAD methods less specially #5454

Closed
bradfitz opened this issue May 13, 2013 · 5 comments
Closed

net/http: treat HEAD methods less specially #5454

bradfitz opened this issue May 13, 2013 · 5 comments
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.

Comments

@bradfitz
Copy link
Contributor

Right now, a ResponseWriter Write will return ErrBodyNotAllowed for a HEAD request.

While some applications may want to check Request.Method == "HEAD" to avoid
some computation, the majority would prefer to be lazy.

For instance, see issue #5451 and the proposed fix
(https://golang.org/cl/9388043/) to shut up some bogus warnings:

        if err := godocHTML.Execute(w, page); err != nil && err != http.ErrBodyNotAllowed {
                log.Printf("godocHTML.Execute: %s", err)
    }

That means applications have to care about HEAD vs GET.

The server's default behavior should shield users from caring about HEAD and just do the
right thing, which means:

-- don't return ErrBodyNotAllowed for HEAD requests. (we'll still return it for other
cases)
-- still do Content-Type sniffing on first 512 bytes.
-- still count Content-Length and send that header, for bodies <= 2KB

Currently we don't do any of those 3, which means our response headers to HEAD requests
aren't the same as our responses to GET requests, unless the app goes out of its way to
do so, which most don't, since HEAD requests are rare.
@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 1:

Anything you want to do for Go1.2?

@bradfitz
Copy link
Contributor Author

Comment 2:

I still want to do what comment #0 says.
Volunteers welcome, otherwise I'll get to it sometime.

Labels changed: added suggested.

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 6, 2013

Comment 3:

Status changed to Started.

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 7, 2013

Comment 4:

https://golang.org/cl/12583043

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 7, 2013

Comment 5:

This issue was closed by revision ebe91d1.

Status changed to Fixed.

@bradfitz bradfitz added fixed Suggested Issues that may be good for new contributors looking for work to do. labels Aug 7, 2013
@bradfitz bradfitz self-assigned this Aug 7, 2013
@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.
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

3 participants