You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.1 KiB

#include <stdio.h>
#include <lighttpd/base.h>
#include <lighttpd/config_parser.h>
int request_test(void) {
liChunkQueue *cq;
liRequest req;
liHandlerResult res;
cq = li_chunkqueue_new();
li_request_init(&req, cq);
li_chunkqueue_append_mem(cq, CONST_STR_LEN(
"GET / HTTP/1.1\r\n"
res = li_http_request_parse(NULL, NULL, &req.parser_ctx);
if (res != LI_HANDLER_GO_ON) {
fprintf(stderr, "Parser return %i", res);
assert(req.http_method == LI_HTTP_METHOD_GET);
assert(cq->length == 3);
return res == LI_HANDLER_GO_ON ? 0 : 1;
int main(void) {
liServer *srv;
guint32 ip, netmask;
assert(li_parse_ipv4("", &ip, &netmask, NULL));
printf("parsed ip: %s\n", inet_ntoa(*(struct in_addr*) &ip));
printf("parsed netmask: %s\n", inet_ntoa(*(struct in_addr*) &netmask));
guint8 ipv6[16];
guint network;
GString *s;
assert(li_parse_ipv6("::ffff:", ipv6, &network, NULL));
s = li_ipv6_tostring(ipv6);
printf("parsed ipv6: %s/%u\n", s->str, network);
return 0;
srv = li_server_new();
return 0;