http-parser.c

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

commit 1fc4ddd00a3933cf76c4a2a6d0c6df5abd681356
parent 06402d67537f095c04285081c5ae12efc1afd317
Author: finwo <finwo@pm.me>
Date:   Tue, 24 Oct 2023 20:14:11 +0200

Print log on response_data panic

Diffstat:
Msrc/http-parser.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/http-parser.c b/src/http-parser.c @@ -647,6 +647,7 @@ void http_parser_response_data(struct http_parser_message *response, const struc const char *aContentLength; const char *aChunkSize; int res; + int x; // Add event data to buffer if (!response->body) response->body = calloc(1, sizeof(struct buf)); @@ -669,7 +670,10 @@ void http_parser_response_data(struct http_parser_message *response, const struc response->version = calloc(1, 4); response->statusMessage = calloc(1, 8192); aStatus = calloc(1, 4); - if (sscanf(response->body->data, "HTTP/%3s %3s %8191c", response->version, aStatus, response->statusMessage) != 3) { + x = sscanf(response->body->data, "HTTP/%3s %3s %8191c", response->version, aStatus, response->statusMessage); + if (x != 3) { + printf("x: %d\n", x); + printf("bdy: %s\n", response->body->data); response->_state = HTTP_PARSER_STATE_PANIC; return; }