summaryrefslogtreecommitdiff
path: root/tests/fcgi-auth.c
blob: d340b2e8dc6eb9e51fceab8bd77849f09fe777a3 (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
33
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_FASTCGI_FASTCGI_H
#include <fastcgi/fcgi_stdio.h>
#else
#include <fcgi_stdio.h>
#endif
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

int main (void) {
	char* p;

	while (FCGI_Accept() >= 0) {
		/* wait for fastcgi authorizer request */

		printf("Content-type: text/html\r\n");

		if (((p = getenv("QUERY_STRING")) == NULL) ||
		    strcmp(p, "ok") != 0) {
			printf("Status: 403 Forbidden\r\n\r\n");
		} else {
			printf("\r\n");
			/* default Status is 200 - allow access */
		}

		printf("foobar\r\n");
	}

	return 0;
}