Merge pull request #7750 from Faless/2.1.x_fix_7697

HTTPClient properly handle partial data in non-blocking mode
This commit is contained in:
Rémi Verschelde 2017-02-12 23:19:10 +01:00 committed by GitHub
commit 11b95cda45
1 changed files with 4 additions and 2 deletions

View File

@ -566,11 +566,13 @@ ByteArray HTTPClient::read_response_body_chunk() {
int to_read = MIN(body_left,read_chunk_size);
ByteArray ret;
ret.resize(to_read);
ByteArray::Write w = ret.write();
int _offset = 0;
while (to_read > 0) {
int rec=0;
err = _get_http_data(w.ptr()+_offset,to_read,rec);
{
ByteArray::Write w = ret.write();
err = _get_http_data(w.ptr()+_offset,to_read,rec);
}
if (rec>0) {
body_left-=rec;
to_read-=rec;