diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-08-08 12:07:25 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-09-05 13:57:51 -0400 |
commit | f28e314b0d5a6d4c677b87378cea70dc6524546b (patch) | |
tree | a119ec5ccaa8343618cacb3bacc125da69d20c60 /src/or/proto_http.c | |
parent | cddac959e7fb5729956a5250351e0fa1289d719f (diff) | |
download | tor-f28e314b0d5a6d4c677b87378cea70dc6524546b.tar.gz tor-f28e314b0d5a6d4c677b87378cea70dc6524546b.zip |
Make buf_pullup() expose the pulled-up data.
This lets us drop the testing-only function buf_get_first_chunk_data(),
and lets us implement proto_http and proto_socks without looking at
buf_t internals.
Diffstat (limited to 'src/or/proto_http.c')
-rw-r--r-- | src/or/proto_http.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/or/proto_http.c b/src/or/proto_http.c index a47644a30a..3977de1866 100644 --- a/src/or/proto_http.c +++ b/src/or/proto_http.c @@ -4,7 +4,6 @@ * Copyright (c) 2007-2017, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -#define BUFFERS_PRIVATE // XXXX remove. #define PROTO_HTTP_PRIVATE #include "or.h" #include "buffers.h" @@ -48,12 +47,12 @@ fetch_from_buf_http(buf_t *buf, char **body_out, size_t *body_used, size_t max_bodylen, int force_complete) { - char *headers; + const char *headers; size_t headerlen, bodylen, contentlen=0; int crlf_offset; int r; - if (!buf->head) + if (buf_datalen(buf) == 0) return 0; crlf_offset = buf_find_string_offset(buf, "\r\n\r\n", 4); @@ -67,11 +66,10 @@ fetch_from_buf_http(buf_t *buf, } /* Okay, we have a full header. Make sure it all appears in the first * chunk. */ - if ((int)buf->head->datalen < crlf_offset + 4) - buf_pullup(buf, crlf_offset+4); headerlen = crlf_offset + 4; + size_t headers_in_chunk = 0; + buf_pullup(buf, headerlen, &headers, &headers_in_chunk); - headers = buf->head->data; bodylen = buf_datalen(buf) - headerlen; log_debug(LD_HTTP,"headerlen %d, bodylen %d.", (int)headerlen, (int)bodylen); |