| Date: Sat, 22 Jul 2023 17:14:59 +0200
First stub for new http-compatibility feature.
Diffstat:
M main.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)
--- |
| @@ -187,6 +187,25 @@ handlerequest(int sock, char *req, int rlen, char *base, char *ohost,
if (c)
c[0] = '\0';
+ /*
+ * Try to guess if we have some HTTP-like protocol compatibility
+ * mode.
+ */
+ if (!nocgi && recvb[0] != '/' && (c = strchr(recvb, " "))) {
+ *c = '\0';
+ if (strchr(recvb, '/'))
+ goto dothegopher;
+ if (snprintf(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);
+ }
+ }
+ }
+ }
+dothegopher:
+
/* Do not allow requests including "..". */
if (strstr(recvb, "..")) {
dprintf(sock, "%s", selinval); |