diff mbox series

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

Message ID 20211202001238.21808-2-jengelh@inai.de (mailing list archive)
State New, archived
Headers show
Series [1/2] http-backend: CGI error messages need to be output on stdout | expand

Commit Message

Jan Engelhardt Dec. 2, 2021, 12:12 a.m. UTC
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 mbox series

Patch

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))