diff options
-rw-r--r-- | lib/http_client.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/http_client.c b/lib/http_client.c index e78cb59d..b509c839 100644 --- a/lib/http_client.c +++ b/lib/http_client.c @@ -328,7 +328,8 @@ static http_ret_t http_process_chunked_data( struct http_request *req, const cha } /* Turns out writing a proper chunked-encoding state machine is not - that simple. :-( */ + that simple. :-( I've tested this one feeding it byte by byte so + I hope it's solid now. */ chunk = req->cbuf; eos = req->cbuf + req->cblen; while( TRUE ) @@ -357,6 +358,7 @@ static http_ret_t http_process_chunked_data( struct http_request *req, const cha if( clen == 0 ) return CR_EOF; + /* Wait for the whole chunk to arrive. */ if( s + clen > eos ) break; if( http_process_data( req, s, clen ) != CR_OK ) @@ -644,10 +646,13 @@ static gboolean http_handle_headers( struct http_request *req ) g_free( req->request ); g_free( req->reply_headers ); + g_free( req->sbuf ); req->request = new_request; req->request_length = strlen( new_request ); req->bytes_read = req->bytes_written = req->inpa = 0; req->reply_headers = req->reply_body = NULL; + req->sbuf = req->cbuf = NULL; + req->sblen = req->cblen = 0; return FALSE; } |