diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2014-07-11 07:23:31 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2014-07-11 07:23:31 +0200 |
commit | 81c63b0eed39432878f78727f60a1e7499645199 (patch) | |
tree | 82387d8fecd1c20788fd8bd784a9b0bde091fb6b /src/libstrongswan/plugins/curl/curl_fetcher.c | |
parent | c5ebfc7b9c16551fe825dc1d79c3f7e2f096f6c9 (diff) | |
download | vyos-strongswan-81c63b0eed39432878f78727f60a1e7499645199.tar.gz vyos-strongswan-81c63b0eed39432878f78727f60a1e7499645199.zip |
Imported Upstream version 5.2.0
Diffstat (limited to 'src/libstrongswan/plugins/curl/curl_fetcher.c')
-rw-r--r-- | src/libstrongswan/plugins/curl/curl_fetcher.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/libstrongswan/plugins/curl/curl_fetcher.c b/src/libstrongswan/plugins/curl/curl_fetcher.c index 644f27709..620cf74f3 100644 --- a/src/libstrongswan/plugins/curl/curl_fetcher.c +++ b/src/libstrongswan/plugins/curl/curl_fetcher.c @@ -50,6 +50,11 @@ struct private_curl_fetcher_t { fetcher_callback_t cb; /** + * Variable that receives the response code + */ + u_int *result; + + /** * Timeout for a transfer */ long timeout; @@ -82,6 +87,7 @@ METHOD(fetcher_t, fetch, status_t, { char error[CURL_ERROR_SIZE], *enc_uri; status_t status; + long result = 0; cb_data_t data = { .cb = this->cb, .user = userdata, @@ -102,7 +108,7 @@ METHOD(fetcher_t, fetch, status_t, goto out; } curl_easy_setopt(this->curl, CURLOPT_ERRORBUFFER, error); - curl_easy_setopt(this->curl, CURLOPT_FAILONERROR, TRUE); + curl_easy_setopt(this->curl, CURLOPT_FAILONERROR, FALSE); curl_easy_setopt(this->curl, CURLOPT_NOSIGNAL, TRUE); if (this->timeout) { @@ -123,7 +129,13 @@ METHOD(fetcher_t, fetch, status_t, status = NOT_SUPPORTED; break; case CURLE_OK: - status = SUCCESS; + curl_easy_getinfo(this->curl, CURLINFO_RESPONSE_CODE, + &result); + if (this->result) + { + *this->result = result; + } + status = (result >= 200 && result < 300) ? SUCCESS : FAILED; break; default: DBG1(DBG_LIB, "libcurl http request failed: %s", error); @@ -188,6 +200,11 @@ METHOD(fetcher_t, set_option, bool, this->cb = va_arg(args, fetcher_callback_t); break; } + case FETCH_RESPONSE_CODE: + { + this->result = va_arg(args, u_int*); + break; + } case FETCH_SOURCEIP: { char buf[64]; |