From 9247be05cf686dc98dd504f8f9fb0f07da1a29d1 Mon Sep 17 00:00:00 2001 From: "Brian M. Carlson" Date: Thu, 12 Sep 2013 00:30:01 +0000 Subject: 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 Reviewed-by: Jonathan Nieder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- http-backend.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'http-backend.c') diff --git a/http-backend.c b/http-backend.c index f50e77fb2..5102d974a 100644 --- a/http-backend.c +++ b/http-backend.c @@ -564,9 +564,11 @@ int main(int argc, char **argv) if (strcmp(method, c->method)) { const char *proto = getenv("SERVER_PROTOCOL"); - if (proto && !strcmp(proto, "HTTP/1.1")) + if (proto && !strcmp(proto, "HTTP/1.1")) { http_status(405, "Method Not Allowed"); - else + hdr_str("Allow", !strcmp(c->method, "GET") ? + "GET, HEAD" : c->method); + } else http_status(400, "Bad Request"); hdr_nocache(); end_headers(); -- cgit v1.2.1