2001-09-09 22:24:39 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <avl/avl.h>
|
2018-11-02 07:20:04 -04:00
|
|
|
#include <igloo/httpp.h>
|
2001-09-09 22:24:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
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) {
|
2018-10-31 07:29:07 -04:00
|
|
|
case igloo_httpp_req_none:
|
2003-03-14 21:10:19 -05:00
|
|
|
printf(" none\n");
|
|
|
|
break;
|
2018-10-31 07:29:07 -04:00
|
|
|
case igloo_httpp_req_unknown:
|
2003-03-14 21:10:19 -05:00
|
|
|
printf(" unknown\n");
|
|
|
|
break;
|
2018-10-31 07:29:07 -04:00
|
|
|
case igloo_httpp_req_get:
|
2003-03-14 21:10:19 -05:00
|
|
|
printf(" get\n");
|
|
|
|
break;
|
2018-10-31 07:29:07 -04:00
|
|
|
case igloo_httpp_req_post:
|
2003-03-14 21:10:19 -05:00
|
|
|
printf(" post\n");
|
|
|
|
break;
|
2018-10-31 07:29:07 -04:00
|
|
|
case igloo_httpp_req_head:
|
2003-03-14 21:10:19 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|