From 02a70bbd21ff7b36b7760f78aebfe257da3c6e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit?= Date: Mon, 21 Feb 2022 11:03:25 +0300 Subject: [PATCH] fixed http.end taking too long (#6277) http end takes 20-30 seconds if there is a large amount of data replacing this read loop with flush fixes that problem --- libraries/HTTPClient/src/HTTPClient.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index 1e4e8394..dca329b3 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -386,9 +386,7 @@ void HTTPClient::disconnect(bool preserveClient) if(connected()) { if(_client->available() > 0) { log_d("still data in buffer (%d), clean up.\n", _client->available()); - while(_client->available() > 0) { - _client->read(); - } + _client->flush(); } if(_reuse && _canReuse) {