1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 01:34:31 +02:00

Add PR #134 which expands CURL options that can be specified in WireHttp $options array. Some of the PR was already added for the sendCURL in a prior commit, so this commit adds the remaining part in downloadCURL(). Slightly modified to read $options['curl']['setopt'] rather than $options['curl'], for compatibilty with what's already in sendCURL().

Co-authored-by: chriswthomson <chris.thomson@nbcommunication.com>
This commit is contained in:
Ryan Cramer
2021-05-07 12:57:28 -04:00
parent f290da2a7f
commit 2190a6ef37

View File

@@ -906,6 +906,7 @@ class WireHttp extends Wire {
$this->resetResponse();
$fromURL = str_replace(' ', '%20', $fromURL);
$setopts = null;
$proxy = '';
if(!empty($options['proxy'])) $proxy = $options['proxy'];
@@ -921,6 +922,16 @@ class WireHttp extends Wire {
curl_setopt($curl, CURLOPT_FILE, $fp); // write curl response to file
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
if($proxy) curl_setopt($curl, CURLOPT_PROXY, $proxy);
// custom CURL options provided in $options array
if(!empty($options['curl']) && !empty($options['curl']['setopt'])) {
$setopts = $options['curl']['setopt'];
} else if(!empty($options['curl_setopt'])) {
$setopts = $options['curl_setopt'];
}
if(is_array($setopts)) {
curl_setopt_array($curl, $options['curl']);
}
$result = curl_exec($curl);
if($result) $this->httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);