Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpclient: fix error meaning #7401

Merged
merged 5 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
d-a-v marked this conversation as resolved.
Show resolved Hide resolved
#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)
Expand Down