Skip to content

Commit

Permalink
Handle HTTP body extraction in request parsing
Browse files Browse the repository at this point in the history
This update ensures the HTTP body is correctly extracted and stored when parsing requests. It adds a check to determine the length of the body and allocates memory accordingly, improving the server's ability to handle incoming HTTP packets.

Took 8 minutes
  • Loading branch information
SeriousSamV committed Oct 28, 2024
1 parent 3bf7db9 commit 16cedec
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tiny_http/tiny_http_server_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,11 @@ http_request *parse_http_request(const uint8_t *const http_packet, const size_t
ptr += 2;
}

ptr += 2;
if (ptr < http_packet_len) {
request->body_len = http_packet_len - ptr;
request->body = (uint8_t*) strndup((char *) http_packet + ptr, request->body_len);
}

return request;
}

0 comments on commit 16cedec

Please sign in to comment.