http-parser.c

Small C library to parse HTTP requests
Log | Files | Refs | README | LICENSE

commit 6fb4316fe750acec13f85425916e1fa657324265
parent 52bda53de10d31e886a996c2722fe396a0700217
Author: finwo <finwo@pm.me>
Date:   Sat,  9 Nov 2019 21:08:46 +0100

Slightly more info in the readme

Diffstat:
MREADME.md | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md @@ -6,10 +6,22 @@ parsing the http request into a method, headers and body. ## Basic usage ```c - static void onRequest(struct http_parser_event *ev) { // The request has been received // Answer the request directly or pass it to a route handler of sorts + + // Fetching the request + // Has been wrapped in http_parser_event to support more features in the future + struct http_parser_request *request = ev->request; + + // Basic http request data + printf("Method: %s\n", request->method); + + // Reading headers are case-insensitive due to non-compliant clients/servers + printf("Host: %s\n", http_parser_header_get(request, "host")); + + // Once you're done with the request, you'll have to free it + http_parser_request_free(request); } // Initialize a request