]> granicus.if.org Git - libevent/commitdiff
Correctly count req->body_size on http usage without Content-Length
authorNick Mathewson <nickm@torproject.org>
Mon, 25 Oct 2010 20:09:11 +0000 (16:09 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 25 Oct 2010 20:09:11 +0000 (16:09 -0400)
There was a dumb bug where we would look at the length of the input
buffer immediately _after_ we drained it.

http.c

diff --git a/http.c b/http.c
index 526244ae81941b1843c2cf99e6d0eb941f6926cf..ce120bcc02783d970d6f4cee1151f8db7d32eee4 100644 (file)
--- a/http.c
+++ b/http.c
@@ -874,8 +874,8 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req)
                }
        } else if (req->ntoread < 0) {
                /* Read until connection close. */
-               evbuffer_add_buffer(req->input_buffer, buf);
                req->body_size += evbuffer_get_length(buf);
+               evbuffer_add_buffer(req->input_buffer, buf);
        } else if (req->chunk_cb != NULL ||
            evbuffer_get_length(buf) >= (size_t)req->ntoread) {
                /* We've postponed moving the data until now, but we're