Skip to content

Commit fb55e91

Browse files
committed
fix #1368
1 parent 54b16b1 commit fb55e91

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ void HTTPClient::begin(String host, uint16_t port, String url, bool https, Strin
193193
*/
194194
void HTTPClient::end(void) {
195195
if(connected()) {
196+
if(_tcp->available() > 0) {
197+
DEBUG_HTTPCLIENT("[HTTP-Client][end] still data in buffer (%d), clean up.\n", _tcp->available());
198+
while(_tcp->available() > 0) {
199+
_tcp->read();
200+
}
201+
}
196202
if(_reuse && _canReuse) {
197203
DEBUG_HTTPCLIENT("[HTTP-Client][end] tcp keep open for reuse\n");
198204
} else {
@@ -711,6 +717,9 @@ bool HTTPClient::connect(void) {
711717

712718
if(connected()) {
713719
DEBUG_HTTPCLIENT("[HTTP-Client] connect. already connected, try reuse!\n");
720+
while(_tcp->available() > 0) {
721+
_tcp->read();
722+
}
714723
return true;
715724
}
716725

0 commit comments

Comments
 (0)