Merge pull request #49226 from Faless/net/4.x_empty_chunk_fix

[Net] Fix HTTPRquest store_buffer error.
This commit is contained in:
Rémi Verschelde 2021-05-31 16:48:56 +02:00 committed by GitHub
commit ff648e2504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -375,17 +375,19 @@ bool HTTPRequest::_update_connection() {
} }
PackedByteArray chunk = client->read_response_body_chunk(); PackedByteArray chunk = client->read_response_body_chunk();
downloaded.add(chunk.size());
if (file) { if (chunk.size()) {
const uint8_t *r = chunk.ptr(); downloaded.add(chunk.size());
file->store_buffer(r, chunk.size()); if (file) {
if (file->get_error() != OK) { const uint8_t *r = chunk.ptr();
call_deferred("_request_done", RESULT_DOWNLOAD_FILE_WRITE_ERROR, response_code, response_headers, PackedByteArray()); file->store_buffer(r, chunk.size());
return true; if (file->get_error() != OK) {
call_deferred("_request_done", RESULT_DOWNLOAD_FILE_WRITE_ERROR, response_code, response_headers, PackedByteArray());
return true;
}
} else {
body.append_array(chunk);
} }
} else {
body.append_array(chunk);
} }
if (body_size_limit >= 0 && downloaded.get() > body_size_limit) { if (body_size_limit >= 0 && downloaded.get() > body_size_limit) {