mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 09:44:38 +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:
@@ -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'];
|
||||
@@ -922,6 +923,16 @@ class WireHttp extends Wire {
|
||||
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);
|
||||
|
||||
|
Reference in New Issue
Block a user