#1030·chi

middleware.GetHead doesn't set Allow header

Author: flimzyCreated Oct 28, 2025Updated Sep 16, 2026

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.