From b31d22bfc0c2bf3515348291e1f3650934b5a65b Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 23 Jun 2020 14:27:49 +0200 Subject: [PATCH 1/2] httpclient: fix error meaning --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 8 ++++---- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 85d27d5c6c..44a413b450 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -679,7 +679,7 @@ int HTTPClient::sendRequest(const char * type, const uint8_t * payload, size_t s // connect to server if(!connect()) { - return returnError(HTTPC_ERROR_CONNECTION_REFUSED); + return returnError(HTTPC_ERROR_CONNECTION_FAILED); } addHeader(F("Content-Length"), String(payload && size > 0 ? size : 0)); @@ -793,7 +793,7 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size) // connect to server if(!connect()) { - return returnError(HTTPC_ERROR_CONNECTION_REFUSED); + return returnError(HTTPC_ERROR_CONNECTION_FAILED); } if(size > 0) { @@ -1083,8 +1083,8 @@ const String& HTTPClient::getString(void) String HTTPClient::errorToString(int error) { switch(error) { - case HTTPC_ERROR_CONNECTION_REFUSED: - return F("connection refused"); + case HTTPC_ERROR_CONNECTION_FAILED: + return F("connection failed"); case HTTPC_ERROR_SEND_HEADER_FAILED: return F("send header failed"); case HTTPC_ERROR_SEND_PAYLOAD_FAILED: diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h index 1ab26c8de7..6b03c7daa0 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h @@ -48,7 +48,8 @@ #define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (5000) /// HTTP client errors -#define HTTPC_ERROR_CONNECTION_REFUSED (-1) +#define HTTPC_ERROR_CONNECTION_REFUSED (-1) // backward compatibility +#define HTTPC_ERROR_CONNECTION_FAILED (-1) #define HTTPC_ERROR_SEND_HEADER_FAILED (-2) #define HTTPC_ERROR_SEND_PAYLOAD_FAILED (-3) #define HTTPC_ERROR_NOT_CONNECTED (-4) From 42d9a8b58a0b9ff2589e184eebb8538b3e45ba85 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Wed, 24 Jun 2020 23:08:12 +0200 Subject: [PATCH 2/2] deprecate HTTPC_ERROR_CONNECTION_REFUSED --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h index 6b03c7daa0..acca34c12f 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h @@ -48,7 +48,6 @@ #define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (5000) /// HTTP client errors -#define HTTPC_ERROR_CONNECTION_REFUSED (-1) // backward compatibility #define HTTPC_ERROR_CONNECTION_FAILED (-1) #define HTTPC_ERROR_SEND_HEADER_FAILED (-2) #define HTTPC_ERROR_SEND_PAYLOAD_FAILED (-3) @@ -61,6 +60,8 @@ #define HTTPC_ERROR_STREAM_WRITE (-10) #define HTTPC_ERROR_READ_TIMEOUT (-11) +constexpr int HTTPC_ERROR_CONNECTION_REFUSED __attribute__((deprecated)) = HTTPC_ERROR_CONNECTION_FAILED; + /// size for the stream handling #define HTTP_TCP_BUFFER_SIZE (1460)