2001-09-09 22:24:39 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <avl/avl.h>
|
|
|
|
#include "httpp.h"
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
char buff[8192];
|
|
|
|
int readed;
|
2018-10-12 07:27:17 -04:00
|
|
|
igloo_http_parser_t parser;
|
|
|
|
igloo_avl_node *node;
|
|
|
|
igloo_http_var_t *var;
|
2003-03-14 21:10:19 -05:00
|
|
|
|
2018-10-12 06:55:24 -04:00
|
|
|
igloo_httpp_initialize(&parser, NULL);
|
2003-03-14 21:10:19 -05:00
|
|
|
|
|
|
|
readed = fread(buff, 1, 8192, stdin);
|
2018-10-12 06:55:24 -04:00
|
|
|
if (igloo_httpp_parse(&parser, buff, readed)) {
|
2003-03-14 21:10:19 -05:00
|
|
|
printf("Parse succeeded...\n\n");
|
|
|
|
printf("Request was ");
|
|
|
|
switch (parser.req_type) {
|
|
|
|
case httpp_req_none:
|
|
|
|
printf(" none\n");
|
|
|
|
break;
|
|
|
|
case httpp_req_unknown:
|
|
|
|
printf(" unknown\n");
|
|
|
|
break;
|
|
|
|
case httpp_req_get:
|
|
|
|
printf(" get\n");
|
|
|
|
break;
|
|
|
|
case httpp_req_post:
|
|
|
|
printf(" post\n");
|
|
|
|
break;
|
|
|
|
case httpp_req_head:
|
|
|
|
printf(" head\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf("Version was 1.%d\n", parser.version);
|
|
|
|
|
2018-10-12 06:55:24 -04:00
|
|
|
node = igloo_avl_get_first(parser.vars);
|
2003-03-14 21:10:19 -05:00
|
|
|
while (node) {
|
2018-10-12 07:27:17 -04:00
|
|
|
var = (igloo_http_var_t *)node->key;
|
2003-03-14 21:10:19 -05:00
|
|
|
|
|
|
|
if (var)
|
|
|
|
printf("Iterating variable(s): %s = %s\n", var->name, var->value);
|
|
|
|
|
2018-10-12 06:55:24 -04:00
|
|
|
node = igloo_avl_get_next(node);
|
2003-03-14 21:10:19 -05:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("Parse failed...\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Destroying parser...\n");
|
|
|
|
httpp_destroy(&parser);
|
|
|
|
|
|
|
|
return 0;
|
2001-09-09 22:24:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|