curl: Enable following redirects
The maximum number of redirects can be limited. The functionality can also be disabled. Fixes #2366.
This commit is contained in:
parent
791cfe82a1
commit
67402ec77b
|
@ -36,6 +36,7 @@ plugins = \
|
||||||
plugins/bypass-lan.opt \
|
plugins/bypass-lan.opt \
|
||||||
plugins/certexpire.opt \
|
plugins/certexpire.opt \
|
||||||
plugins/coupling.opt \
|
plugins/coupling.opt \
|
||||||
|
plugins/curl.opt \
|
||||||
plugins/dhcp.opt \
|
plugins/dhcp.opt \
|
||||||
plugins/dnscert.opt \
|
plugins/dnscert.opt \
|
||||||
plugins/duplicheck.opt \
|
plugins/duplicheck.opt \
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
charon.plugins.curl.redir = -1
|
||||||
|
Maximum number of redirects followed by the plugin, set to 0 to disable
|
||||||
|
following redirects, set to -1 for no limit.
|
|
@ -58,6 +58,11 @@ struct private_curl_fetcher_t {
|
||||||
* Timeout for a transfer
|
* Timeout for a transfer
|
||||||
*/
|
*/
|
||||||
long timeout;
|
long timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of redirects to follow
|
||||||
|
*/
|
||||||
|
long redir;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,6 +121,8 @@ METHOD(fetcher_t, fetch, status_t,
|
||||||
curl_easy_setopt(this->curl, CURLOPT_TIMEOUT, this->timeout);
|
curl_easy_setopt(this->curl, CURLOPT_TIMEOUT, this->timeout);
|
||||||
}
|
}
|
||||||
curl_easy_setopt(this->curl, CURLOPT_CONNECTTIMEOUT, CONNECT_TIMEOUT);
|
curl_easy_setopt(this->curl, CURLOPT_CONNECTTIMEOUT, CONNECT_TIMEOUT);
|
||||||
|
curl_easy_setopt(this->curl, CURLOPT_FOLLOWLOCATION, TRUE);
|
||||||
|
curl_easy_setopt(this->curl, CURLOPT_MAXREDIRS, this->redir);
|
||||||
curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, (void*)curl_cb);
|
curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, (void*)curl_cb);
|
||||||
curl_easy_setopt(this->curl, CURLOPT_WRITEDATA, &data);
|
curl_easy_setopt(this->curl, CURLOPT_WRITEDATA, &data);
|
||||||
if (this->headers)
|
if (this->headers)
|
||||||
|
@ -260,6 +267,8 @@ curl_fetcher_t *curl_fetcher_create()
|
||||||
},
|
},
|
||||||
.curl = curl_easy_init(),
|
.curl = curl_easy_init(),
|
||||||
.cb = fetcher_default_callback,
|
.cb = fetcher_default_callback,
|
||||||
|
.redir = lib->settings->get_int(lib->settings, "%s.plugins.curl.redir",
|
||||||
|
-1, lib->ns),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!this->curl)
|
if (!this->curl)
|
||||||
|
|
Loading…
Reference in New Issue