2008-07-08 16:51:03 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2008-07-01 18:56:59 +00:00
|
|
|
|
|
|
|
#include "base.h"
|
2008-07-01 20:07:54 +00:00
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
#include "http_request_parser.h"
|
2008-07-08 17:23:12 +00:00
|
|
|
#include "config_parser.h"
|
2008-07-01 18:56:59 +00:00
|
|
|
|
|
|
|
int request_test() {
|
2008-07-01 20:07:54 +00:00
|
|
|
chunkqueue *cq;
|
|
|
|
request *req;
|
|
|
|
http_request_ctx ctx;
|
|
|
|
handler_t res;
|
|
|
|
|
|
|
|
cq = chunkqueue_new();
|
|
|
|
req = request_new();
|
|
|
|
|
|
|
|
http_request_parser_init(&ctx, req, cq);
|
|
|
|
|
|
|
|
chunkqueue_append_mem(cq, CONST_STR_LEN(
|
|
|
|
"GET / HTTP/1.1\r\n"
|
|
|
|
"\r\n"
|
|
|
|
));
|
|
|
|
|
|
|
|
res = http_request_parse(NULL, NULL, &ctx);
|
|
|
|
if (res != HANDLER_GO_ON) {
|
2008-07-19 10:56:44 +00:00
|
|
|
fprintf(stderr, "Parser return %i", res);
|
2008-07-01 20:07:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2008-07-01 18:56:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2008-07-17 19:39:29 +00:00
|
|
|
server *srv;
|
2008-07-08 16:51:03 +00:00
|
|
|
GTimeVal start, end;
|
|
|
|
gboolean result;
|
|
|
|
|
2008-07-17 19:39:29 +00:00
|
|
|
srv = server_new();
|
|
|
|
|
2008-07-08 16:51:03 +00:00
|
|
|
/* config parser test */
|
2008-07-18 14:52:19 +00:00
|
|
|
GList *cpd_stack = NULL;
|
2008-07-08 16:51:03 +00:00
|
|
|
g_get_current_time(&start);
|
2008-07-18 14:52:19 +00:00
|
|
|
result = config_parser_file(srv, &cpd_stack, "../test.conf");
|
2008-07-08 16:51:03 +00:00
|
|
|
g_get_current_time(&end);
|
|
|
|
|
|
|
|
printf("parsed config in %ld seconds %ld milliseconds and %ld microseconds\n",
|
|
|
|
end.tv_sec - start.tv_sec,
|
|
|
|
(end.tv_usec - start.tv_usec) / 1000,
|
|
|
|
(end.tv_usec - start.tv_usec) % 1000
|
|
|
|
);
|
|
|
|
|
2008-07-01 20:07:54 +00:00
|
|
|
return request_test();
|
2008-07-01 18:56:59 +00:00
|
|
|
}
|