git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] http-backend: give a hint that web browser access is not supported

From
Jan Engelhardt <jengelh@inai.de>
Date
Dec 2, 2021, 00:12 UTC
Message-ID
<20211202001238.21808-2-jengelh@inai.de>
In-Reply-To
<20211202001238.21808-1-jengelh@inai.de>
Add a paragraph that browsing to http-backend is not something
that should normally be done
 a webserver is configured to unconditionally pass requests
to git-http-backend, without any diversion to a gitweb frontend,
it is helpful to at least be told this.
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
---
 http-backend.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git http-backend.c http-backend.c
index 8f1b69d127..06e17d45a4 100644
--- http-backend.c
+++ http-backend.c
@@ -775,8 +775,15 @@ int cmd_main(int argc, const char **argv)
 		regfree(&re);
 	}
 
-	if (!cmd)
-		not_found(&hdr, "Request not supported: '%s'", dir);
+	if (!cmd) {
+		const char *hint = "";
+		if (strcmp(method, "GET") == 0)
+			hint = "You cannot use regular web browsing to access "
+			       "this URL. Only git operations like "
+			       "clone/ls-remote/etc. will work.\n";
+		not_found(&hdr, "%s request not supported on '%s'.\n%s",
+			  method, dir, hint);
+	}
 
 	setup_path();
 	if (!enter_repo(dir, 0))
-- 
2.34.0
Previous: Jan EngelhardtNext: Junio C Hamano
Message 2 of 3 in “http-backend: CGI error messages need to be output on stdout”
  1. 1/2 http-backend: CGI error messages need to be output on stdoutJan Engelhardt, Dec 2, 2021
  2. 2/2 http-backend: give a hint that web browser access is not supportedJan Engelhardt, Dec 2, 2021
  3. Junio C HamanoDec 2, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.