[Libevent-users] evhttp changes for large requests

Scott Lamb slamb at slamb.org
Sun Feb 10 14:51:21 EST 2008


Scott Lamb wrote:
> (1) Use a 64-bit counter for tracking the Content-Length:. Patch 
> attached. (Somehow this patch isn't working, though? curl complains that 
> it's stopping at 2^31-1 bytes. I may debug later.)

Ahh. My tired eyes missed the most important assignment. Working patch 
attached.
-------------- next part --------------
evhttp: use a 64-bit Content-Length: counter even on 32-bit platforms

From: Scott Lamb <slamb at slamb.org>

Signed-off-by: Scott Lamb <slamb at slamb.org>
---

 libevent/evhttp.h |    2 +-
 libevent/http.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libevent/evhttp.h b/libevent/evhttp.h
index 20a33b9..a47a2f0 100644
--- a/libevent/evhttp.h
+++ b/libevent/evhttp.h
@@ -204,7 +204,7 @@ struct {
 	char *response_code_line;	/* Readable response */
 
 	struct evbuffer *input_buffer;	/* read data */
-	int ntoread;
+	int64_t ntoread;
 	int chunked;
 
 	struct evbuffer *output_buffer;	/* outgoing post or data */
diff --git a/libevent/http.c b/libevent/http.c
index 712a899..07d1567 100644
--- a/libevent/http.c
+++ b/libevent/http.c
@@ -707,7 +707,7 @@ evhttp_handle_chunked_read(struct evhttp_request *req, struct evbuffer *buf)
 				event_free(p);
 				continue;
 			}
-			req->ntoread = strtol(p, &endp, 16);
+			req->ntoread = strtoll(p, &endp, 16);
 			error = *p == '\0' || (*endp != '\0' && *endp != ' ');
 			event_free(p);
 			if (error) {


More information about the Libevent-users mailing list