Get http error code from curl
This commit is contained in:
@@ -56,10 +56,10 @@ SiaCurlError CSiaCurl::CheckHttpError(const std::string& result)
|
|||||||
return SiaCurlError::Success;
|
return SiaCurlError::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
SiaCurlError CSiaCurl::ProcessResponse(const int& res, const std::string& result, json& response) const
|
SiaCurlError CSiaCurl::ProcessResponse(const int& res, const int& httpCode, const std::string& result, json& response) const
|
||||||
{
|
{
|
||||||
SiaCurlError ret;
|
SiaCurlError ret;
|
||||||
if (res == CURLE_OK)
|
if ((res == CURLE_OK) && (httpCode == 200))
|
||||||
{
|
{
|
||||||
ret = CheckHttpError(result);
|
ret = CheckHttpError(result);
|
||||||
if (ApiSuccess(ret))
|
if (ApiSuccess(ret))
|
||||||
@@ -98,7 +98,10 @@ SiaCurlError CSiaCurl::_Get(const String& path, json& response) const
|
|||||||
curl_easy_setopt(_curlHandle, CURLOPT_WRITEDATA, &result);
|
curl_easy_setopt(_curlHandle, CURLOPT_WRITEDATA, &result);
|
||||||
const CURLcode res = curl_easy_perform(_curlHandle);
|
const CURLcode res = curl_easy_perform(_curlHandle);
|
||||||
|
|
||||||
return ProcessResponse(res, result, response);
|
long httpCode = 0;
|
||||||
|
curl_easy_getinfo(_curlHandle, CURLINFO_RESPONSE_CODE, &httpCode);
|
||||||
|
|
||||||
|
return ProcessResponse(res, httpCode, result, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSiaCurl::CheckVersion(SiaCurlError& error) const
|
bool CSiaCurl::CheckVersion(SiaCurlError& error) const
|
||||||
@@ -170,7 +173,10 @@ SiaCurlError CSiaCurl::Post(const String& path, const PostParameters& parameters
|
|||||||
curl_easy_setopt(_curlHandle, CURLOPT_WRITEDATA, &result);
|
curl_easy_setopt(_curlHandle, CURLOPT_WRITEDATA, &result);
|
||||||
const CURLcode res = curl_easy_perform(_curlHandle);
|
const CURLcode res = curl_easy_perform(_curlHandle);
|
||||||
|
|
||||||
ret = ProcessResponse(res, result, response);
|
long httpCode = 0;
|
||||||
|
curl_easy_getinfo(_curlHandle, CURLINFO_RESPONSE_CODE, &httpCode);
|
||||||
|
|
||||||
|
ret = ProcessResponse(res, httpCode, result, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -42,7 +42,7 @@ private:
|
|||||||
std::string ConstructPath(const String& relativePath) const;
|
std::string ConstructPath(const String& relativePath) const;
|
||||||
_SiaCurlError _Get(const String& path, json& response) const;
|
_SiaCurlError _Get(const String& path, json& response) const;
|
||||||
bool CheckVersion(_SiaCurlError& error) const;
|
bool CheckVersion(_SiaCurlError& error) const;
|
||||||
_SiaCurlError ProcessResponse(const int& res, const std::string& result, json& response) const;
|
_SiaCurlError ProcessResponse(const int& res, const int& httpCode, const std::string& result, json& response) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
String GetServerVersion() const;
|
String GetServerVersion() const;
|
||||||
|
Reference in New Issue
Block a user