File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ class Connection {
5656 * @var RequestInfo::redirectCount
5757 * Member 'redirectCount' contains the number of redirects followed. See
5858 * CURLINFO_REDIRECT_COUNT
59+ * @var RequestInfo::curlCode
60+ * Member 'curlCode' contains the cURL code (cast to int). See
61+ * libcurl-errors
62+ * @var RequestInfo::curlError
63+ * Member 'curlError' contains the cURL error as a string, if any. See
64+ * CURLOPT_ERRORBUFFER
5965 */
6066 typedef struct {
6167 double totalTime;
@@ -65,7 +71,9 @@ class Connection {
6571 double preTransferTime;
6672 double startTransferTime;
6773 double redirectTime;
68- int redirectCount;
74+ long redirectCount;
75+ int curlCode;
76+ std::string curlError;
6977 } RequestInfo;
7078 /* *
7179 * @struct Info
@@ -231,6 +239,7 @@ class Connection {
231239 std::string keyPassword;
232240 std::string uriProxy;
233241 std::string unixSocketPath;
242+ char curlErrorBuf[CURL_ERROR_SIZE];
234243 RestClient::Response performCurlRequest (const std::string& uri);
235244};
236245}; // namespace RestClient
Original file line number Diff line number Diff line change @@ -359,6 +359,10 @@ RestClient::Connection::performCurlRequest(const std::string& uri) {
359359 curl_easy_setopt (this ->curlHandle , CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
360360 curl_easy_setopt (this ->curlHandle , CURLOPT_USERPWD, authString.c_str ());
361361 }
362+ /* * set error buffer */
363+ curl_easy_setopt (this ->curlHandle , CURLOPT_ERRORBUFFER,
364+ this ->curlErrorBuf );
365+
362366 /* * set user agent */
363367 curl_easy_setopt (this ->curlHandle , CURLOPT_USERAGENT,
364368 this ->GetUserAgent ().c_str ());
@@ -441,6 +445,7 @@ RestClient::Connection::performCurlRequest(const std::string& uri) {
441445 }
442446
443447 res = curl_easy_perform (this ->curlHandle );
448+ this ->lastRequest .curlCode = res;
444449 if (res != CURLE_OK) {
445450 switch (res) {
446451 case CURLE_OPERATION_TIMEDOUT:
@@ -461,6 +466,8 @@ RestClient::Connection::performCurlRequest(const std::string& uri) {
461466 ret.code = static_cast <int >(http_code);
462467 }
463468
469+ this ->lastRequest .curlError = std::string (this ->curlErrorBuf );
470+
464471 curl_easy_getinfo (this ->curlHandle , CURLINFO_TOTAL_TIME,
465472 &this ->lastRequest .totalTime );
466473 curl_easy_getinfo (this ->curlHandle , CURLINFO_NAMELOOKUP_TIME,
You can’t perform that action at this time.
0 commit comments