You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
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:
@@ -500,20 +500,24 @@ ByteArray HTTPClient::read_response_body_chunk() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
ByteArray ret;
|
||||||
|
ret.resize(MAX(body_left,tmp_read.size()));
|
||||||
|
ByteArray::Write w = ret.write();
|
||||||
|
int _offset = 0;
|
||||||
|
while (body_left > 0) {
|
||||||
ByteArray::Write r = tmp_read.write();
|
ByteArray::Write r = tmp_read.write();
|
||||||
int rec=0;
|
int rec=0;
|
||||||
err = connection->get_partial_data(r.ptr(),MIN(body_left,tmp_read.size()),rec);
|
err = connection->get_partial_data(r.ptr(),MIN(body_left,tmp_read.size()),rec);
|
||||||
if (rec>0) {
|
if (rec>0) {
|
||||||
ByteArray ret;
|
copymem(w.ptr()+_offset,r.ptr(),rec);
|
||||||
ret.resize(rec);
|
|
||||||
ByteArray::Write w = ret.write();
|
|
||||||
copymem(w.ptr(),r.ptr(),rec);
|
|
||||||
body_left-=rec;
|
body_left-=rec;
|
||||||
|
_offset += rec;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (body_left==0) {
|
if (body_left==0) {
|
||||||
status=STATUS_CONNECTED;
|
status=STATUS_CONNECTED;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user