Updated the sendHttpQuery method to now return an error code which tells the line corresponding to the return of the failure
This commit is contained in:
parent
32e32e46d2
commit
e3cdaafd88
@ -73,7 +73,7 @@ boolean HttpClient::connectByHostOrIp()
|
||||
return _connectionStatus == SUCCESSFUL;
|
||||
}
|
||||
|
||||
boolean HttpClient::sendHttpQuery(const char *resource, HttpRequestMethod method, Dictionary<DictionaryHelper::StringEntity> *getData, Dictionary<DictionaryHelper::StringEntity> *postData, Dictionary<DictionaryHelper::StringEntity> *headerData)
|
||||
int HttpClient::sendHttpQuery(const char *resource, HttpRequestMethod method, Dictionary<DictionaryHelper::StringEntity> *getData, Dictionary<DictionaryHelper::StringEntity> *postData, Dictionary<DictionaryHelper::StringEntity> *headerData)
|
||||
{
|
||||
if(resource != NULL) //We overwrite the resource if it has been already defined
|
||||
{
|
||||
@ -88,7 +88,7 @@ boolean HttpClient::sendHttpQuery(const char *resource, HttpRequestMethod method
|
||||
return sendHttpQuery(method, getData, postData, headerData);
|
||||
}
|
||||
|
||||
boolean HttpClient::sendHttpQuery(HttpRequestMethod method, Dictionary<DictionaryHelper::StringEntity> *getData, Dictionary<DictionaryHelper::StringEntity> *postData, Dictionary<DictionaryHelper::StringEntity> *headerData)
|
||||
int HttpClient::sendHttpQuery(HttpRequestMethod method, Dictionary<DictionaryHelper::StringEntity> *getData, Dictionary<DictionaryHelper::StringEntity> *postData, Dictionary<DictionaryHelper::StringEntity> *headerData)
|
||||
{
|
||||
//We reset this two flags
|
||||
_httpCode = HTTP_CODE::UNDEFINED_CODE;
|
||||
@ -101,7 +101,7 @@ boolean HttpClient::sendHttpQuery(HttpRequestMethod method, Dictionary<Dictionar
|
||||
|
||||
if(!connected() || _connectionStatus == FAILED)
|
||||
{
|
||||
if(_retries == _maxRetries) return false;
|
||||
if(_retries == _maxRetries) return -__LINE__;
|
||||
|
||||
if(_connectionStatus == FAILED)
|
||||
{
|
||||
@ -116,16 +116,16 @@ boolean HttpClient::sendHttpQuery(HttpRequestMethod method, Dictionary<Dictionar
|
||||
Serial.printf("We start a new connection : %s port %u\nretries : %u\n", _pAddress, _port, _retries);
|
||||
#endif
|
||||
|
||||
connectByHostOrIp();
|
||||
|
||||
if(_connectionStatus == FAILED)
|
||||
if(!connectByHostOrIp())
|
||||
{
|
||||
#ifdef DEBUG_HTTP_CLIENT
|
||||
Serial.printf("Failed to reconnect\n");
|
||||
#endif
|
||||
stop();
|
||||
return false;
|
||||
return -__LINE__;
|
||||
}
|
||||
else
|
||||
_retries = 0;
|
||||
}
|
||||
|
||||
if(connected())
|
||||
@ -156,12 +156,12 @@ boolean HttpClient::sendHttpQuery(HttpRequestMethod method, Dictionary<Dictionar
|
||||
Serial.printf("Http verb unspecified\n", status());
|
||||
#endif
|
||||
if(!_keepAlive)stop();
|
||||
return false;
|
||||
return -__LINE__;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HttpClient::HTTP_CODE HttpClient::isReplyAvailable(uint16_t timeout)
|
||||
|
@ -25,13 +25,13 @@ class HttpClient : public WiFiClient, public HttpConstants
|
||||
HttpClient(const HttpClient &object);
|
||||
virtual ~HttpClient();
|
||||
|
||||
boolean sendHttpQuery(const char *ressource,
|
||||
int sendHttpQuery(const char *ressource,
|
||||
HttpRequestMethod method = HttpRequestMethod::GET,
|
||||
Dictionary<DictionaryHelper::StringEntity> *getData = NULL,
|
||||
Dictionary<DictionaryHelper::StringEntity> *postData = NULL,
|
||||
Dictionary<DictionaryHelper::StringEntity> *headerData = NULL);
|
||||
|
||||
boolean sendHttpQuery(HttpRequestMethod method = HttpRequestMethod::GET,
|
||||
int sendHttpQuery(HttpRequestMethod method = HttpRequestMethod::GET,
|
||||
Dictionary<DictionaryHelper::StringEntity> *getData = NULL,
|
||||
Dictionary<DictionaryHelper::StringEntity> *postData = NULL,
|
||||
Dictionary<DictionaryHelper::StringEntity> *headerData = NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user