git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] http-backend: provide Allow header for 405
@ 2013-09-12  0:30 brian m. carlson
  2013-09-12  0:33 ` Jonathan Nieder
  2013-09-12  4:46 ` Jeff King
  0 siblings, 2 replies; 3+ messages in thread
From: brian m. carlson @ 2013-09-12  0:30 UTC (permalink / raw)
  To: git; +Cc: mhagger, jkoleszar, gitster, jrnieder, peff

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>
---
 http-backend.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/http-backend.c b/http-backend.c
index 0324417..8c464bd 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -594,9 +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");
-				else
+					hdr_str("Allow", !strcmp(c->method, "GET") ?
+						"GET, HEAD" : c->method);
+				} else
 					http_status(400, "Bad Request");
 				hdr_nocache();
 				end_headers();
-- 
1.8.4.rc3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-12  4:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-12  0:30 [PATCH v2] http-backend: provide Allow header for 405 brian m. carlson
2013-09-12  0:33 ` Jonathan Nieder
2013-09-12  4:46 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).