Fix HTTPClient _get_http_data bug after #21976.

This commit is contained in:
Fabio Alessandrelli 2018-09-15 21:10:45 +02:00
parent 2cf024ed91
commit 26677d5e0c

View file

@ -668,11 +668,11 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received
// We can't use StreamPeer.get_data, since when reaching EOF we will get an // We can't use StreamPeer.get_data, since when reaching EOF we will get an
// error without knowing how many bytes we received. // error without knowing how many bytes we received.
Error err = ERR_FILE_EOF; Error err = ERR_FILE_EOF;
int read; int read = 0;
int left = p_bytes; int left = p_bytes;
r_received = 0; r_received = 0;
while (left > 0) { while (left > 0) {
err = connection->get_partial_data(p_buffer, left, read); err = connection->get_partial_data(p_buffer + r_received, left, read);
if (err == OK) { if (err == OK) {
r_received += read; r_received += read;
} else if (err == ERR_FILE_EOF) { } else if (err == ERR_FILE_EOF) {