Fixed copy process of stream of bytes for HttpClient.
===================================================== Previously if request was not chunked and longer than arbitrary chunk of 4096 bytes, rest was truncated. With this commit, we will copy everything we have in the memmory.
This commit is contained in:
parent
89fa70706f
commit
b86d1e39b9
1 changed files with 16 additions and 12 deletions
|
@ -500,20 +500,24 @@ ByteArray HTTPClient::read_response_body_chunk() {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ByteArray::Write r = tmp_read.write();
|
ByteArray ret;
|
||||||
int rec=0;
|
ret.resize(MAX(body_left,tmp_read.size()));
|
||||||
err = connection->get_partial_data(r.ptr(),MIN(body_left,tmp_read.size()),rec);
|
ByteArray::Write w = ret.write();
|
||||||
if (rec>0) {
|
int _offset = 0;
|
||||||
ByteArray ret;
|
while (body_left > 0) {
|
||||||
ret.resize(rec);
|
ByteArray::Write r = tmp_read.write();
|
||||||
ByteArray::Write w = ret.write();
|
int rec=0;
|
||||||
copymem(w.ptr(),r.ptr(),rec);
|
err = connection->get_partial_data(r.ptr(),MIN(body_left,tmp_read.size()),rec);
|
||||||
body_left-=rec;
|
if (rec>0) {
|
||||||
if (body_left==0) {
|
copymem(w.ptr()+_offset,r.ptr(),rec);
|
||||||
status=STATUS_CONNECTED;
|
body_left-=rec;
|
||||||
|
_offset += rec;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
if (body_left==0) {
|
||||||
|
status=STATUS_CONNECTED;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue