Skip to content

middleware.GetHead doesn't set Allow header #1030

Description

@flimzy

The GetHead middleware is a nice convienent way to add HEAD support for all GET handlers, but it misses what to me are two vital features:

  • A 405 response will not show HEAD in the Allow: header
  • The response body is included, despite HEAD semantics prohibiting a response body. EDIT: While the middleware doesn't handle this, I've learned the stdlib's http server does. So this is not as important as I thought--my tests with httptest.ResponseRecorder were in effect returning false positives as a result.

I've forked a copy of the GetHead middleware for my own app, and fixed these two oversights, but would love to contribute them upstream if they'd be accepted in a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions