From 2190a6ef37e25be9cb3bfee14436af90ff31edb9 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 7 May 2021 12:57:28 -0400 Subject: [PATCH] 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 --- wire/core/WireHttp.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wire/core/WireHttp.php b/wire/core/WireHttp.php index 16c219dd..443643a2 100644 --- a/wire/core/WireHttp.php +++ b/wire/core/WireHttp.php @@ -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);