mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-06 05:21:22 +03:00
httpclient: fix error meaning (#7401)
* httpclient: fix error meaning * deprecate HTTPC_ERROR_CONNECTION_REFUSED
This commit is contained in:
parent
00fc716ccc
commit
52f4cc8de0
@ -679,7 +679,7 @@ int HTTPClient::sendRequest(const char * type, const uint8_t * payload, size_t s
|
|||||||
|
|
||||||
// connect to server
|
// connect to server
|
||||||
if(!connect()) {
|
if(!connect()) {
|
||||||
return returnError(HTTPC_ERROR_CONNECTION_REFUSED);
|
return returnError(HTTPC_ERROR_CONNECTION_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
addHeader(F("Content-Length"), String(payload && size > 0 ? size : 0));
|
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
|
// connect to server
|
||||||
if(!connect()) {
|
if(!connect()) {
|
||||||
return returnError(HTTPC_ERROR_CONNECTION_REFUSED);
|
return returnError(HTTPC_ERROR_CONNECTION_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(size > 0) {
|
if(size > 0) {
|
||||||
@ -1083,8 +1083,8 @@ const String& HTTPClient::getString(void)
|
|||||||
String HTTPClient::errorToString(int error)
|
String HTTPClient::errorToString(int error)
|
||||||
{
|
{
|
||||||
switch(error) {
|
switch(error) {
|
||||||
case HTTPC_ERROR_CONNECTION_REFUSED:
|
case HTTPC_ERROR_CONNECTION_FAILED:
|
||||||
return F("connection refused");
|
return F("connection failed");
|
||||||
case HTTPC_ERROR_SEND_HEADER_FAILED:
|
case HTTPC_ERROR_SEND_HEADER_FAILED:
|
||||||
return F("send header failed");
|
return F("send header failed");
|
||||||
case HTTPC_ERROR_SEND_PAYLOAD_FAILED:
|
case HTTPC_ERROR_SEND_PAYLOAD_FAILED:
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
#define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (5000)
|
#define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (5000)
|
||||||
|
|
||||||
/// HTTP client errors
|
/// HTTP client errors
|
||||||
#define HTTPC_ERROR_CONNECTION_REFUSED (-1)
|
#define HTTPC_ERROR_CONNECTION_FAILED (-1)
|
||||||
#define HTTPC_ERROR_SEND_HEADER_FAILED (-2)
|
#define HTTPC_ERROR_SEND_HEADER_FAILED (-2)
|
||||||
#define HTTPC_ERROR_SEND_PAYLOAD_FAILED (-3)
|
#define HTTPC_ERROR_SEND_PAYLOAD_FAILED (-3)
|
||||||
#define HTTPC_ERROR_NOT_CONNECTED (-4)
|
#define HTTPC_ERROR_NOT_CONNECTED (-4)
|
||||||
@ -60,6 +60,8 @@
|
|||||||
#define HTTPC_ERROR_STREAM_WRITE (-10)
|
#define HTTPC_ERROR_STREAM_WRITE (-10)
|
||||||
#define HTTPC_ERROR_READ_TIMEOUT (-11)
|
#define HTTPC_ERROR_READ_TIMEOUT (-11)
|
||||||
|
|
||||||
|
constexpr int HTTPC_ERROR_CONNECTION_REFUSED __attribute__((deprecated)) = HTTPC_ERROR_CONNECTION_FAILED;
|
||||||
|
|
||||||
/// size for the stream handling
|
/// size for the stream handling
|
||||||
#define HTTP_TCP_BUFFER_SIZE (1460)
|
#define HTTP_TCP_BUFFER_SIZE (1460)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user