summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Porzelt <tp@cryosphere.de>2009-09-11 18:27:43 +0200
committerThomas Porzelt <tp@cryosphere.de>2009-09-11 18:27:43 +0200
commit572ab4496e7abd3d775b2634609bf2f8f0d0791c (patch)
treec9d4da21b668fc0f90f82ebd4c36fbad9fc67f7a
parent9df7f495ccdde85b8ececb67a5c16852818b03bd (diff)
downloadweighttp-572ab4496e7abd3d775b2634609bf2f8f0d0791c.tar.gz
weighttp-572ab4496e7abd3d775b2634609bf2f8f0d0791c.zip
fix state machine bug which would lead to failed request even though there was no error
-rw-r--r--src/client.c8
-rw-r--r--src/weighttp.c2
-rw-r--r--src/weighttp.h2
3 files changed, 7 insertions, 5 deletions
diff --git a/src/client.c b/src/client.c
index 098cca4..9b6f25c 100644
--- a/src/client.c
+++ b/src/client.c
@@ -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;
diff --git a/src/weighttp.c b/src/weighttp.c
index 565564c..8385c16 100644
--- a/src/weighttp.c
+++ b/src/weighttp.c
@@ -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++) {
diff --git a/src/weighttp.h b/src/weighttp.h
index ad47465..2ebbf12 100644
--- a/src/weighttp.h
+++ b/src/weighttp.h
@@ -57,4 +57,6 @@ struct Config {
struct addrinfo *saddr;
};
+uint64_t str_to_uint64(char *str);
+
#endif