aboutsummaryrefslogtreecommitdiff
path: root/core/io/http_client.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli2017-02-07 10:21:17 +0100
committerFabio Alessandrelli2017-02-07 11:05:14 +0100
commit1f08d17a98a42bf8a4edc1bd1deafa78054d7ca5 (patch)
treee1e652043e5579f499156a7fb1bd8d5878ffcef2 /core/io/http_client.cpp
parent34b6caa43303c46f178e0375aa50bfaf5ac903e7 (diff)
downloadgodot-1f08d17a98a42bf8a4edc1bd1deafa78054d7ca5.tar.gz
godot-1f08d17a98a42bf8a4edc1bd1deafa78054d7ca5.tar.zst
godot-1f08d17a98a42bf8a4edc1bd1deafa78054d7ca5.zip
HTTPClient properly handle partial data in non-blocking mode
Use block to send DVector::Write out of scope in HTTPClient::read_response_body_chunk() (cherry picked from commit 833994b2949cbdd191dfdb095bb96913a7b3b03a)
Diffstat (limited to '')
-rw-r--r--core/io/http_client.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 4f14a1fc4..1a5c25954 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -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;