diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2017-02-07 10:21:17 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2017-02-07 11:01:53 +0100 |
commit | 833994b2949cbdd191dfdb095bb96913a7b3b03a (patch) | |
tree | a4e8c3de548bbb08cceafea2e9d76c2c423225f3 | |
parent | 6bfaa0f12c65947ab0f124ec4c75345bd1332b77 (diff) |
HTTPClient properly handle partial data in non-blocking mode
Use block to send DVector::Write out of scope in
HTTPClient::read_response_body_chunk()
-rw-r--r-- | core/io/http_client.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 63c8abbbad..fd06d27c1f 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -566,11 +566,13 @@ PoolByteArray HTTPClient::read_response_body_chunk() { int to_read = MIN(body_left,read_chunk_size); PoolByteArray ret; ret.resize(to_read); - PoolByteArray::Write w = ret.write(); int _offset = 0; while (to_read > 0) { int rec=0; - err = _get_http_data(w.ptr()+_offset,to_read,rec); + { + PoolByteArray::Write w = ret.write(); + err = _get_http_data(w.ptr()+_offset,to_read,rec); + } if (rec>0) { body_left-=rec; to_read-=rec; |