fetcher_callback_t cb;
/**
+ * Variable that receives the response code
+ */
+ u_int *result;
+
+ /**
* Timeout for a transfer
*/
long timeout;
{
char error[CURL_ERROR_SIZE], *enc_uri;
status_t status;
+ long result = 0;
cb_data_t data = {
.cb = this->cb,
.user = userdata,
status = NOT_SUPPORTED;
break;
case CURLE_OK:
+ if (this->result)
+ {
+ curl_easy_getinfo(this->curl, CURLINFO_RESPONSE_CODE,
+ &result);
+ *this->result = result;
+ }
status = SUCCESS;
break;
default:
- DBG1(DBG_LIB, "libcurl http request failed: %s", error);
+ if (this->result)
+ { /* don't log an error in this case */
+ curl_easy_getinfo(this->curl, CURLINFO_RESPONSE_CODE,
+ &result);
+ *this->result = result;
+ }
+ else
+ {
+ DBG1(DBG_LIB, "libcurl http request failed: %s", error);
+ }
status = FAILED;
break;
}
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];