fix state machine bug which would lead to failed request even though there was no error

This commit is contained in:
Thomas Porzelt 2009-09-11 18:27:43 +02:00
parent 9df7f495cc
commit 572ab4496e
3 changed files with 7 additions and 5 deletions

View File

@ -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;

View File

@ -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++) {

View File

@ -57,4 +57,6 @@ struct Config {
struct addrinfo *saddr;
};
uint64_t str_to_uint64(char *str);
#endif