Skip to content

Commit

Permalink
Merge pull request #1445 from Links2004/master
Browse files Browse the repository at this point in the history
fix #1368
  • Loading branch information
Links2004 committed Jan 16, 2016
2 parents 3873627 + 4247b64 commit 371c788
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ void HTTPClient::begin(String host, uint16_t port, String url, bool https, Strin
*/
void HTTPClient::end(void) {
if(connected()) {
if(_tcp->available() > 0) {
DEBUG_HTTPCLIENT("[HTTP-Client][end] still data in buffer (%d), clean up.\n", _tcp->available());
while(_tcp->available() > 0) {
_tcp->read();
}
}
if(_reuse && _canReuse) {
DEBUG_HTTPCLIENT("[HTTP-Client][end] tcp keep open for reuse\n");
} else {
Expand Down Expand Up @@ -711,6 +717,9 @@ bool HTTPClient::connect(void) {

if(connected()) {
DEBUG_HTTPCLIENT("[HTTP-Client] connect. already connected, try reuse!\n");
while(_tcp->available() > 0) {
_tcp->read();
}
return true;
}

Expand Down

0 comments on commit 371c788

Please sign in to comment.