summaryrefslogtreecommitdiff
path: root/http-backend.c
diff options
context:
space:
mode:
authorBrian M. Carlson <sandals@crustytoothpaste.net>2013-09-12 00:30:01 +0000
committerJunio C Hamano <gitster@pobox.com>2013-09-12 08:44:44 -0700
commit9247be05cf686dc98dd504f8f9fb0f07da1a29d1 (patch)
treef689ed3320df6a2a69796929e5cf3f19c855d5f2 /http-backend.c
parente45bda876ae2e39ac1e11ba1609f2c363ad4959a (diff)
downloadgit-9247be05cf686dc98dd504f8f9fb0f07da1a29d1.tar.gz
http-backend: provide Allow header for 405bc/http-backend-allow-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>
Diffstat (limited to 'http-backend.c')
-rw-r--r--http-backend.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/http-backend.c b/http-backend.c
index f50e77fb28..5102d974aa 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();