From mboxrd@z Thu Jan 1 00:00:00 1970 From: "brian m. carlson" Subject: [PATCH] http-backend: provide Allow header for 405 Date: Sun, 8 Sep 2013 18:15:06 +0000 Message-ID: <1378664106-95936-1-git-send-email-sandals@crustytoothpaste.net> Cc: mhagger@alum.mit.edu, peff@peff.net, jkoleszar@google.com, gitster@pobox.com To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sun Sep 08 20:15:23 2013 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VIjW6-0003Oy-4n for gcvg-git-2@plane.gmane.org; Sun, 08 Sep 2013 20:15:22 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751105Ab3IHSPR (ORCPT ); Sun, 8 Sep 2013 14:15:17 -0400 Received: from castro.crustytoothpaste.net ([173.11.243.49]:60140 "EHLO castro.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751015Ab3IHSPQ (ORCPT ); Sun, 8 Sep 2013 14:15:16 -0400 Received: from vauxhall.crustytoothpaste.net (unknown [172.16.2.247]) by castro.crustytoothpaste.net (Postfix) with ESMTPSA id 6AFEC28072; Sun, 8 Sep 2013 18:15:15 +0000 (UTC) X-Mailer: git-send-email 1.8.4.236.g382490f.dirty Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 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 --- http-backend.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/http-backend.c b/http-backend.c index 0324417..8c61084 100644 --- a/http-backend.c +++ b/http-backend.c @@ -594,8 +594,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"); + hdr_str("Allow", !strcmp("GET", c->method) ? + "GET, HEAD" : c->method); + } else http_status(400, "Bad Request"); hdr_nocache(); -- 1.8.4.rc3