diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-10-14 02:26:13 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-10-14 02:26:13 +0000 |
commit | 998cf8d6222607113fbd8fa8563d507a808ee869 (patch) | |
tree | 2e3f8dfbf46c60a659b75f715a65b8266f5377a0 /src/or/buffers.c | |
parent | 11b76b9ca5b39eeeb4fcff1593db2efe14cc5827 (diff) | |
download | tor-998cf8d6222607113fbd8fa8563d507a808ee869.tar.gz tor-998cf8d6222607113fbd8fa8563d507a808ee869.zip |
Try to extract as many descriptors as possible from truncated http responses. (when DIR_PURPOSE_FETCH_ROUTERDESC)
svn:r5249
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r-- | src/or/buffers.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 093eb60e6a..15f5976ec5 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -788,13 +788,16 @@ fetch_from_buf(char *string, size_t string_len, buf_t *buf) * - If a headers or body doesn't fit in the arg, return -1. * (We ensure that the headers or body don't exceed max len, * _even if_ we're planning to discard them.) + * - If force_complete is true, then succeed even if not all of the + * content has arrived. * * Else, change nothing and return 0. */ int fetch_from_buf_http(buf_t *buf, char **headers_out, size_t max_headerlen, - char **body_out, size_t *body_used, size_t max_bodylen) + char **body_out, size_t *body_used, size_t max_bodylen, + int force_complete) { char *headers, *body, *p; size_t headerlen, bodylen, contentlen; @@ -840,8 +843,10 @@ fetch_from_buf_http(buf_t *buf, /* if content-length is malformed, then our body length is 0. fine. */ log_fn(LOG_DEBUG,"Got a contentlen of %d.",(int)contentlen); if (bodylen < contentlen) { - log_fn(LOG_DEBUG,"body not all here yet."); - return 0; /* not all there yet */ + if (!force_complete) { + log_fn(LOG_DEBUG,"body not all here yet."); + return 0; /* not all there yet */ + } } if (bodylen > contentlen) { bodylen = contentlen; |