Skip to content

Commit

Permalink
Fix a mistake in in the chunked transfer encoding parsing
Browse files Browse the repository at this point in the history
let's hope it's correct now
  • Loading branch information
Morilli committed Aug 4, 2020
1 parent 4161e67 commit 298f718
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions socket_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,16 @@ HttpResponse* receive_http_body(SOCKET* socket, char* request, char* host)
already_received -= body_position - start_of_chunk;
if (already_received >= chunk_size + 2) {
memcpy(&body->data[body->length], body_position, chunk_size);
body->length += chunk_size;
start_of_chunk = body_position + chunk_size + 2;
already_received -= chunk_size + 2;
} else {
memcpy(&body->data[body->length], body_position, already_received);
body->length += already_received;
receive_data(*socket, (char*) &body->data[body->length], chunk_size - already_received);
body->length += chunk_size - already_received;
receive_data(*socket, (char*) &(uint16_t) {0}, 2);
start_of_chunk = body_position + already_received;
already_received = 0;
}
start_of_chunk = body_position + chunk_size + 2;
body->length += chunk_size;
}
while (!strstr(start_of_chunk + 3, "\r\n")) recv(*socket, (char*) &(uint64_t) {0}, 8, 0);
} else {
Expand Down

0 comments on commit 298f718

Please sign in to comment.