Add cookie stuff
authorJeremy Tan <[email protected]>
Mon, 30 Sep 2013 07:24:17 +0000 (15:24 +0800)
committerJeremy Tan <[email protected]>
Mon, 30 Sep 2013 07:24:17 +0000 (15:24 +0800)
server-configs/nginx/fastcgi_params
testing/cookie-test/readme.txt [new file with mode: 0644]
testing/cookie-test/test.c [new file with mode: 0644]

index 51aa692..b5b9858 100644 (file)
@@ -2,6 +2,7 @@ fastcgi_param   QUERY_STRING            $query_string;
 fastcgi_param  REQUEST_METHOD          $request_method;
 fastcgi_param  CONTENT_TYPE            $content_type;
 fastcgi_param  CONTENT_LENGTH          $content_length;
+fastcgi_param  COOKIE_STRING           $http_cookie;
 
 fastcgi_param  SCRIPT_FILENAME         $request_filename;
 fastcgi_param  SCRIPT_NAME             $fastcgi_script_name;
diff --git a/testing/cookie-test/readme.txt b/testing/cookie-test/readme.txt
new file mode 100644 (file)
index 0000000..fb52249
--- /dev/null
@@ -0,0 +1,7 @@
+compile with:
+gcc test.c -lfcgi -o test
+
+Run with:
+spawn-fcgi -p9005 -n ./test
+
+nginx must be configured to pass $http_cookie as an evironment variable named COOKIE
\ No newline at end of file
diff --git a/testing/cookie-test/test.c b/testing/cookie-test/test.c
new file mode 100644 (file)
index 0000000..7f88239
--- /dev/null
@@ -0,0 +1,10 @@
+#include <fcgi_stdio.h>
+#include <stdlib.h>
+int main() {
+       while (FCGI_Accept() >= 0) {
+               printf("Content-type: text\r\n");
+               printf("Set-Cookie: name=value with spaces; and a semicolon\r\n");
+               printf("Set-Cookie: name2=value2\r\n\r\n");
+               printf("Cookie:%s\n", getenv("COOKIE_STRING"));
+       }
+}

UCC git Repository :: git.ucc.asn.au