curl: Be less strict when considering status codes as errors
authorTobias Brunner <tobias@strongswan.org>
Wed, 11 Nov 2015 14:20:00 +0000 (15:20 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 12 Nov 2015 13:40:37 +0000 (14:40 +0100)
For file:// URIs the code is 0 on success. We now do the same libcurl
would do with CURLOPT_FAILONERROR enabled.

Fixes #1203.

src/libstrongswan/plugins/curl/curl_fetcher.c

index 7653c19..9207f11 100644 (file)
@@ -123,7 +123,7 @@ METHOD(fetcher_t, fetch, status_t,
                curl_easy_setopt(this->curl, CURLOPT_HTTPHEADER, this->headers);
        }
 
-       DBG2(DBG_LIB, "  sending http request to '%s'...", uri);
+       DBG2(DBG_LIB, "  sending request to '%s'...", uri);
        curl_status = curl_easy_perform(this->curl);
        switch (curl_status)
        {
@@ -137,10 +137,10 @@ METHOD(fetcher_t, fetch, status_t,
                        {
                                *this->result = result;
                        }
-                       status = (result >= 200 && result < 300) ? SUCCESS : FAILED;
+                       status = (result < 400) ? SUCCESS : FAILED;
                        break;
                default:
-                       DBG1(DBG_LIB, "libcurl http request failed [%d]: %s", curl_status,
+                       DBG1(DBG_LIB, "libcurl request failed [%d]: %s", curl_status,
                                 error);
                        status = FAILED;
                        break;