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;
|
||||
}
|
||||
|
||||
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;
|
||||
if (res == CURLE_OK)
|
||||
if ((res == CURLE_OK) && (httpCode == 200))
|
||||
{
|
||||
ret = CheckHttpError(result);
|
||||
if (ApiSuccess(ret))
|
||||
@@ -98,7 +98,10 @@ SiaCurlError CSiaCurl::_Get(const String& path, json& response) const
|
||||
curl_easy_setopt(_curlHandle, CURLOPT_WRITEDATA, &result);
|
||||
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
|
||||
@@ -170,7 +173,10 @@ SiaCurlError CSiaCurl::Post(const String& path, const PostParameters& parameters
|
||||
curl_easy_setopt(_curlHandle, CURLOPT_WRITEDATA, &result);
|
||||
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;
|
||||
|
@@ -42,7 +42,7 @@ private:
|
||||
std::string ConstructPath(const String& relativePath) const;
|
||||
_SiaCurlError _Get(const String& path, json& response) 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:
|
||||
String GetServerVersion() const;
|
||||
|
@@ -23,7 +23,7 @@ wept saxophone dialect depth update jaunt loincloth asleep lush gnome laptop upp
|
||||
* Work Test
|
||||
names amaze when afraid inmate hull hexagon etched niece rudely tudor unopened acidic swagger emit shrugged noises tycoon leech tubes shrugged bulb inexact plywood tuesday rims cease excess aces
|
||||
|
||||
* Work Test2
|
||||
* Work Test2
|
||||
ornament alkaline gasp pepper upkeep ablaze number sizes toyed sawmill looking bygones dwarf nerves session cake jerseys niche arrow howls omission verification identity waffle pockets giving hiding river acoustic
|
||||
*/
|
||||
|
||||
|
Reference in New Issue
Block a user