summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2023-08-07 09:44:56 -0600
committercflip <cflip@cflip.net>2023-08-07 09:44:56 -0600
commit89c62ba0739421b44c2f6d54a89011d81bf9e57c (patch)
treea87cdf1dcacf248bad5d0b2d62c507ab943e5640 /file.c
parent555f21649b909fd37a6153843249d72ca80ac427 (diff)
Improve HTTP request parsing and pass cookies to CGI scriptsHEADmaster
The HTTP request parser has been mostly rewritten, and now it is able to parse header lines. This makes it possible to get the cookie string from the request and pass it to CGI scripts, which was needed for the cflip forum to retain login status. It is now possible to run the forum through cfws, log in and submit threads and posts!
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/file.c b/file.c
index 4e42c58..e1c209a 100644
--- a/file.c
+++ b/file.c
@@ -126,6 +126,9 @@ static void cgi_setup_env(const char *filepath, const struct http_request *req)
if (req->query_str)
setenv("QUERY_STRING", req->query_str, 1);
+ if (req->cookie)
+ setenv("HTTP_COOKIE", req->cookie, 1);
+
if (req->body) {
static char intbuf[20];
static char *content_type = "application/x-www-form-urlencoded";
@@ -196,6 +199,7 @@ int file_read_cgi(const char *filepath, const char *program, const struct http_r
write(sockfd, buffer, bytes_read);
unsetenv("QUERY_STRING");
+ unsetenv("HTTP_COOKIE");
unsetenv("CONTENT");
unsetenv("CONTENT_LENGTH");