From 7d7824701fe5e22f08555d3e1ce3180a922b2151 Mon Sep 17 00:00:00 2001 From: Jeroen88 Date: Wed, 5 Jun 2019 14:00:00 +0200 Subject: [PATCH] Fix persistance issue found, see ESP8266 issue #6152 (#2851) --- libraries/HTTPClient/src/HTTPClient.cpp | 3 +++ libraries/HTTPClient/src/HTTPClient.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index 8b832988..ab632342 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -1080,6 +1080,8 @@ int HTTPClient::handleHeaderResponse() return HTTPC_ERROR_NOT_CONNECTED; } + _canReuse = !_useHTTP10; + String transferEncoding; _returnCode = -1; _size = -1; @@ -1098,6 +1100,7 @@ int HTTPClient::handleHeaderResponse() if(headerLine.startsWith("HTTP/1.")) { _returnCode = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt(); + _canReuse = (_returnCode != '0'); } else if(headerLine.indexOf(':')) { String headerName = headerLine.substring(0, headerLine.indexOf(':')); String headerValue = headerLine.substring(headerLine.indexOf(':') + 1); diff --git a/libraries/HTTPClient/src/HTTPClient.h b/libraries/HTTPClient/src/HTTPClient.h index 745f6e64..45f6e3f4 100644 --- a/libraries/HTTPClient/src/HTTPClient.h +++ b/libraries/HTTPClient/src/HTTPClient.h @@ -217,7 +217,7 @@ protected: String _host; uint16_t _port = 0; int32_t _connectTimeout = -1; - bool _reuse = false; + bool _reuse = true; uint16_t _tcpTimeout = HTTPCLIENT_DEFAULT_TCP_TIMEOUT; bool _useHTTP10 = false; bool _secure = false;