Skip to content

Instantly share code, notes, and snippets.

@ennorehling
Created November 29, 2013 22:22
Show Gist options
  • Save ennorehling/7712741 to your computer and use it in GitHub Desktop.
Save ennorehling/7712741 to your computer and use it in GitHub Desktop.
#include <fcgiapp.h>
#include <stdlib.h>
const char * meta[] = {
"AUTH_TYPE",
"CONTENT_LENGTH",
"CONTENT_TYPE",
"GATEWAY_INTERFACE",
"PATH_INFO",
"PATH_TRANSLATED",
"QUERY_STRING",
"REMOTE_ADDR",
"REMOTE_HOST",
"REMOTE_IDENT",
"REMOTE_USER",
"REQUEST_METHOD",
"SCRIPT_NAME",
"SERVER_NAME",
"SERVER_PORT",
"SERVER_PROTOCOL",
"SERVER_SOFTWARE",
0
};
int main(void)
{
FCGX_Request request;
int count = 0;
FCGX_Init();
FCGX_InitRequest(&request, 0, 0);
while(FCGX_Accept_r(&request) == 0) {
const char **m;
FCGX_FPrintF(request.out,
"Status: 200 OK\r\n"
"Content-type: text/html\r\n"
"\r\n"
"<title>FastCGI Hello App!</title>"
"<h1>FastCGI Hello App!</h1>"
"Request number %d running on host <i>%s</i><ul>",
++count, FCGX_GetParam("SERVER_NAME", request.envp));
for (m=meta;*m;++m) {
const char *v = FCGX_GetParam(*m, request.envp);
FCGX_FPrintF(request.out,
"<li>%s: %s</li>", *m,
v ? v : "not set");
}
FCGX_FPrintF(request.out, "</ui>");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment