curl: Log error code too
authorTobias Brunner <tobias@strongswan.org>
Fri, 11 Jul 2014 13:40:15 +0000 (15:40 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 9 Sep 2014 08:56:14 +0000 (10:56 +0200)
It seems libcurl does not always return an error message.

src/libstrongswan/plugins/curl/curl_fetcher.c

index 620cf74..7653c19 100644 (file)
@@ -86,6 +86,7 @@ METHOD(fetcher_t, fetch, status_t,
        private_curl_fetcher_t *this, char *uri, void *userdata)
 {
        char error[CURL_ERROR_SIZE], *enc_uri;
+       CURLcode curl_status;
        status_t status;
        long result = 0;
        cb_data_t data = {
@@ -123,7 +124,8 @@ METHOD(fetcher_t, fetch, status_t,
        }
 
        DBG2(DBG_LIB, "  sending http request to '%s'...", uri);
-       switch (curl_easy_perform(this->curl))
+       curl_status = curl_easy_perform(this->curl);
+       switch (curl_status)
        {
                case CURLE_UNSUPPORTED_PROTOCOL:
                        status = NOT_SUPPORTED;
@@ -138,7 +140,8 @@ METHOD(fetcher_t, fetch, status_t,
                        status = (result >= 200 && result < 300) ? SUCCESS : FAILED;
                        break;
                default:
-                       DBG1(DBG_LIB, "libcurl http request failed: %s", error);
+                       DBG1(DBG_LIB, "libcurl http request failed [%d]: %s", curl_status,
+                                error);
                        status = FAILED;
                        break;
        }