add libscgi (SCGI Client)

This commit is contained in:
Anthony Minessale
2012-05-09 14:05:03 -05:00
parent 5a059ef630
commit 6bb33d7683
5 changed files with 902 additions and 0 deletions

39
libs/libscgi/testclient.c Normal file
View File

@@ -0,0 +1,39 @@
#include <scgi.h>
int main(int argc, char *argv[])
{
char buf[16336] = "";
ssize_t len;
scgi_handle_t handle = { 0 };
char *ip;
int port = 0;
if (argc < 2) {
fprintf(stderr, "usage: testclient <ip> <port>");
}
ip = argv[1];
port = atoi(argv[2]);
scgi_add_param(&handle, "REQUEST_METHOD", "POST");
scgi_add_param(&handle, "REQUEST_URI", "/deepthought");
scgi_add_param(&handle, "TESTING", "TRUE");
scgi_add_param(&handle, "TESTING", "TRUE");
scgi_add_body(&handle, "What is the answer to life?");
scgi_connect(&handle, ip, port, 10000);
scgi_send_request(&handle);
while((len = scgi_recv(&handle, buf, sizeof(buf))) > 0) {
printf("READ [%s]\n", buf);
}
scgi_disconnect(&handle);
}