1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4 #ifdef HAVE_FASTCGI_FASTCGI_H
5 #include <fastcgi/fcgi_stdio.h>
6 #else
7 #include <fcgi_stdio.h>
8 #endif
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <string.h>
12 
main(void)13 int main (void) {
14 	int num_requests = 2;
15 
16 	while (num_requests > 0 &&
17 	       FCGI_Accept() >= 0) {
18 		char* p;
19 
20 		if (NULL != (p = getenv("QUERY_STRING"))) {
21 			if (0 == strcmp(p, "lf")) {
22 				printf("Status: 200 OK\n\n");
23 			} else if (0 == strcmp(p, "crlf")) {
24 				printf("Status: 200 OK\r\n\r\n");
25 			} else if (0 == strcmp(p, "slow-lf")) {
26 				printf("Status: 200 OK\n");
27 				fflush(stdout);
28 				printf("\n");
29 			} else if (0 == strcmp(p,"slow-crlf")) {
30 				printf("Status: 200 OK\r\n");
31 				fflush(stdout);
32 				printf("\r\n");
33 			} else if (0 == strcmp(p, "die-at-end")) {
34 				printf("Status: 200 OK\r\n\r\n");
35 				num_requests--;
36 			} else {
37 				printf("Status: 200 OK\r\n\r\n");
38 			}
39 		} else {
40 			printf("Status: 500 Internal Foo\r\n\r\n");
41 		}
42 
43 		if (0 == strcmp(p, "path_info")) {
44 			printf("%s", getenv("PATH_INFO"));
45 		} else if (0 == strcmp(p, "script_name")) {
46 			printf("%s", getenv("SCRIPT_NAME"));
47 		} else {
48 			printf("test123");
49 		}
50 	}
51 
52 	return 0;
53 }
54