fix state machine bug which would lead to failed request even though there was no error
This commit is contained in:
parent
9df7f495cc
commit
572ab4496e
@ -249,7 +249,7 @@ void client_state_machine(Client *client) {
|
||||
if (client->state == CLIENT_END)
|
||||
goto start;
|
||||
else
|
||||
break;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* disconnect */
|
||||
@ -343,7 +343,7 @@ static uint8_t client_parse(Client *client) {
|
||||
|
||||
if (strncmp(str, "Content-Length: ", sizeof("Content-Length: ")-1) == 0) {
|
||||
/* content length header */
|
||||
client->content_length = atoi(str + sizeof("Content-Length: ") - 1);
|
||||
client->content_length = str_to_uint64(str + sizeof("Content-Length: ") - 1);
|
||||
} else if (strncmp(str, "Connection: ", sizeof("Connection: ")-1) == 0) {
|
||||
/* connection header */
|
||||
str += sizeof("Connection: ") - 1;
|
||||
@ -375,8 +375,8 @@ static uint8_t client_parse(Client *client) {
|
||||
//printf("parse (BODY)\n");
|
||||
/* do nothing, just consume the data */
|
||||
/*printf("content-l: %"PRIu64", header: %d, recevied: %"PRIu64"\n",
|
||||
client->content_length, client->header_size, client->bytes_received);
|
||||
client->buffer_offset = 0;*/
|
||||
client->content_length, client->header_size, client->bytes_received);*/
|
||||
client->buffer_offset = 0;
|
||||
|
||||
if (client->content_length == -1)
|
||||
return 0;
|
||||
|
@ -139,7 +139,7 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
|
||||
return req;
|
||||
}
|
||||
|
||||
static uint64_t str_to_uint64(char *str) {
|
||||
uint64_t str_to_uint64(char *str) {
|
||||
uint64_t i;
|
||||
|
||||
for (i = 0; *str; str++) {
|
||||
|
@ -57,4 +57,6 @@ struct Config {
|
||||
struct addrinfo *saddr;
|
||||
};
|
||||
|
||||
uint64_t str_to_uint64(char *str);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user