http-backend: provide Allow header for 405

The HTTP 1.1 standard requires an Allow header for 405 Method Not Allowed: The response MUST include an Allow header containing a list of valid methods for the requested resource. So provide such a header when we return a 405 to the user agent. Signed-off-by: Brian M. Carlson <sandals@crustytoothpaste.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian M. Carlson committed Sep 12, 2013 at 00:30 UTC 9247be05cf686dc98dd504f8f9fb0f07da1a29d1
1 file changed +4 -2
http-backend.c
+4 -2
@@ -564,9 +564,11 @@ int main(int argc, char **argv)
564
565 if (strcmp(method, c->method)) {
566 const char *proto = getenv("SERVER_PROTOCOL");
567 - if (proto && !strcmp(proto, "HTTP/1.1"))
567 + if (proto && !strcmp(proto, "HTTP/1.1")) {
568 http_status(405, "Method Not Allowed");
569 - else
569 + hdr_str("Allow", !strcmp(c->method, "GET") ?
570 + "GET, HEAD" : c->method);
571 + } else
572 http_status(400, "Bad Request");
573 hdr_nocache();
574 end_headers();