http-parser.c

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

commit 06402d67537f095c04285081c5ae12efc1afd317
parent 2019d7fcaa03ae6bada5dcbca56857953f5c938b
Author: finwo <finwo@pm.me>
Date:   Tue, 24 Oct 2023 20:08:49 +0200

Print states during response parsing

Diffstat:
Msrc/http-parser.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/http-parser.c b/src/http-parser.c @@ -655,8 +655,10 @@ void http_parser_response_data(struct http_parser_message *response, const struc while(1) { switch(response->_state) { case HTTP_PARSER_STATE_PANIC: + printf("_state: panic\n"); return; case HTTP_PARSER_STATE_INIT: + printf("_state: init\n"); // Wait for more data if not line break found index = strstr(response->body->data, "\r\n"); @@ -684,6 +686,8 @@ void http_parser_response_data(struct http_parser_message *response, const struc break; case HTTP_PARSER_STATE_HEADER: + printf("_state: header\n"); + if (!http_parser_message_read_header(response)) { if ( http_parser_header_get(response, "content-length") || @@ -697,6 +701,7 @@ void http_parser_response_data(struct http_parser_message *response, const struc break; case HTTP_PARSER_STATE_BODY: + printf("_state: body\n"); // Detect chunked encoding if (response->chunksize == -1) { @@ -727,6 +732,8 @@ void http_parser_response_data(struct http_parser_message *response, const struc break; case HTTP_PARSER_STATE_BODY_CHUNKED: + printf("_state: body (chunked)\n"); + res = http_parser_message_read_chunked(response); if (res == 0) { @@ -742,6 +749,7 @@ void http_parser_response_data(struct http_parser_message *response, const struc break; case HTTP_PARSER_STATE_DONE: + printf("_state: done\n"); // Temporary buffer > direct buffer if (response->buf) {