summaryrefslogtreecommitdiff
path: root/tests/fcgi-auth.c
blob: 456b71dc834e5bd313513ffa61d5e8e6ebf85606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "first.h"

#if defined(HAVE_FASTCGI_FCGI_STDIO_H)
# include <fastcgi/fcgi_stdio.h>
#elif defined(HAVE_FCGI_STDIO_H)
# include <fcgi_stdio.h>
#else
# error Missing fcgi_stdio.h
#endif

#include <stdlib.h>
#include <string.h>

int main (void) {

	while (FCGI_Accept() >= 0) {

		/* Status: 200 OK to allow access is implied
		 * if Status header is not included in response */

		char *p = getenv("QUERY_STRING");
		if (p != NULL && 0 == strcmp(p, "var")) {
			printf("Variable-X-LIGHTTPD-FCGI-AUTH: LighttpdTestContent\r\n");
		} else if (p == NULL || 0 != strcmp(p, "ok")) {
			printf("Status: 403 Forbidden\r\n");
		}

		printf("\r\n");
	}

	return 0;
}