{"thread":{"id":"34912","subject":"[PATCH v2] http-backend: provide Allow header for 405","startedAt":"2013-09-12T00:30:01Z","lastAt":"2013-09-12T04:46:37Z","messageCount":3,"participants":["brian m. carlson","Jonathan Nieder","Jeff King"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"227499","messageId":"1378945801-122021-1-git-send-email-sandals@crustytoothpaste.net","threadId":"34912","inReplyTo":null,"subject":"[PATCH v2] http-backend: provide Allow header for 405","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2013-09-12T00:30:01Z","receivedAt":"2013-09-12T00:30:01Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The HTTP 1.1 standard requires an Allow header for 405 Method Not Allowed:\n\n  The response MUST include an Allow header containing a list of valid methods\n  for the requested resource.\n\nSo provide such a header when we return a 405 to the user agent.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n http-backend.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/http-backend.c b/http-backend.c\nindex 0324417..8c464bd 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -594,9 +594,11 @@ int main(int argc, char **argv)\n \n \t\t\tif (strcmp(method, c->method)) {\n \t\t\t\tconst char *proto = getenv(\"SERVER_PROTOCOL\");\n-\t\t\t\tif (proto && !strcmp(proto, \"HTTP/1.1\"))\n+\t\t\t\tif (proto && !strcmp(proto, \"HTTP/1.1\")) {\n \t\t\t\t\thttp_status(405, \"Method Not Allowed\");\n-\t\t\t\telse\n+\t\t\t\t\thdr_str(\"Allow\", !strcmp(c->method, \"GET\") ?\n+\t\t\t\t\t\t\"GET, HEAD\" : c->method);\n+\t\t\t\t} else\n \t\t\t\t\thttp_status(400, \"Bad Request\");\n \t\t\t\thdr_nocache();\n \t\t\t\tend_headers();\n-- \n1.8.4.rc3\n"},{"id":"227500","messageId":"20130912003343.GH4326@google.com","threadId":"34912","inReplyTo":"1378945801-122021-1-git-send-email-sandals@crustytoothpaste.net","subject":"Re: [PATCH v2] http-backend: provide Allow header for 405","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-09-12T00:33:43Z","receivedAt":"2013-09-12T00:33:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"brian m. carlson wrote:\n\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n\nThanks again for noticing.\n\nFor what it's worth,\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n"},{"id":"227506","messageId":"20130912044637.GA1356@sigill.intra.peff.net","threadId":"34912","inReplyTo":"1378945801-122021-1-git-send-email-sandals@crustytoothpaste.net","subject":"Re: [PATCH v2] http-backend: provide Allow header for 405","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-09-12T04:46:37Z","receivedAt":"2013-09-12T04:46:37Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 12, 2013 at 12:30:01AM +0000, brian m. carlson wrote:\n\n> The HTTP 1.1 standard requires an Allow header for 405 Method Not Allowed:\n> \n>   The response MUST include an Allow header containing a list of valid methods\n>   for the requested resource.\n> \n> So provide such a header when we return a 405 to the user agent.\n> \n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n\nThanks, this looks good to me.\n\n-Peff\n"}]}