2012-05-10 09:23:23 -04:00
|
|
|
#include <scgi.h>
|
|
|
|
|
2012-05-23 10:37:54 -04:00
|
|
|
static void callback(scgi_socket_t server_sock, scgi_socket_t *client_sock, struct sockaddr_in *addr)
|
2012-05-10 09:23:23 -04:00
|
|
|
{
|
|
|
|
scgi_handle_t handle = { 0 };
|
|
|
|
|
2012-05-23 12:31:17 -04:00
|
|
|
if (scgi_parse(*client_sock, &handle) == SCGI_SUCCESS) {
|
2012-05-10 09:23:23 -04:00
|
|
|
scgi_param_t *pp;
|
|
|
|
|
2012-05-23 10:37:54 -04:00
|
|
|
*client_sock = SCGI_SOCK_INVALID;
|
|
|
|
|
2012-05-10 09:23:23 -04:00
|
|
|
for(pp = handle.params; pp; pp = pp->next) {
|
|
|
|
printf("HEADER: [%s] VALUE: [%s]\n", pp->name, pp->value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (handle.body) {
|
|
|
|
printf("\n\nBODY:\n%s\n\n", handle.body);
|
|
|
|
}
|
|
|
|
|
2012-05-23 10:37:54 -04:00
|
|
|
scgi_disconnect(&handle);
|
2012-05-10 09:23:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
char *ip;
|
|
|
|
int port = 0;
|
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
fprintf(stderr, "usage: testserver <ip> <port>\n");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ip = argv[1];
|
|
|
|
port = atoi(argv[2]);
|
|
|
|
|
|
|
|
|
|
|
|
scgi_listen(ip, port, callback);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|