commit 81f3ec7d02246ab56d7fcc57ce18d546a3fe4b6f
parent 6dc65c6ce9c4a41c034aa1f21d9ff2a1573efde4
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 22 Jul 2023 17:27:20 +0200
Make compatibility serving a full feature.
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/main.c b/main.c
@@ -187,19 +187,24 @@ handlerequest(int sock, char *req, int rlen, char *base, char *ohost,
 	if (c)
 		c[0] = '\0';
 
+	memmove(recvc, recvb, rlen+1);
 	/*
 	 * Try to guess if we have some HTTP-like protocol compatibility
 	 * mode.
 	 */
 	if (!nocgi && recvb[0] != '/' && (c = strchr(recvb, ' '))) {
-		*c = '\0';
+		*c++ = '\0';
 		if (strchr(recvb, '/'))
 			goto dothegopher;
 		if (snprintf(path, sizeof(path), "%s/%s", base, recvb) <= sizeof(path)) {
 			if (realpath(path, (char *)rpath)) {
-				if (stat(rpath, &dir)) {
-					handlecgi(sock, rpath, port, base, NULL, NULL, ohost,
-						clienth, serverh, istls, req, NULL);
+				if (stat(rpath, &dir) == 0) {
+					if (loglvl & FILES)
+						logentry(clienth, clientp, recvc, "compatibility serving");
+
+					handlecgi(sock, rpath, port, base, "", "", ohost,
+						clienth, serverh, istls, req, "");
+					return;
 				}
 			}
 		}