summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_url.class16
1 files changed, 10 insertions, 6 deletions
diff --git a/it_url.class b/it_url.class
index 3ee41d4..59ee4af 100644
--- a/it_url.class
+++ b/it_url.class
@@ -109,7 +109,7 @@ static function _postprocess($data, $p)
* @param $p['followlocation']Follow redirects [true]
* @param $p['retries'] Number of retries if download fails, default 1
* @param $p['retrysleep'] Number of seconds to wait before retry (additional to fetchsleep), fractions ok
- * @param $p['compression'] use compression (uses curl to do that)
+ * @param $p['accept_encoding'] Contents of the "Accept-Encoding: " header. Enables decoding of the response. Set to null to disable, "" (default) for all supported encodings.
* @param $p['postprocess'] function called with content and $p which has it_error. returns content or null
* @return Content of resulting page (considering redirects, excluding headers or false on error) or array (empty on error) if 'assoc' => true
*/
@@ -189,7 +189,12 @@ static function _default_headers($url, $p)
static function curl_opts($p=array())
{
- $p += array('totaltimeout' => "999999", 'timeout' => 5, 'followlocation' => true);
+ $p += [
+ 'totaltimeout' => "999999",
+ 'timeout' => 5,
+ 'followlocation' => true,
+ 'accept_encoding' => '', # set header to accept any supported encoding and enable automatic decompression
+ ];
$add = [];
foreach ($p['headers'] as $header => $value)
@@ -202,9 +207,6 @@ static function curl_opts($p=array())
if ($p['data'])
$add += [ CURLOPT_POSTFIELDS => $p['data'] ];
- if ($p['compression'])
- $add += [ CURLOPT_ENCODING => "" ];
-
if ($p['pass'] || $p['user'])
$add += [ CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $p['user'] . ':' . $p['pass'] ];
@@ -225,6 +227,9 @@ static function curl_opts($p=array())
if ($p['verbose'] || EDC('curlverbose'))
$add += [ CURLOPT_VERBOSE => true ];
+ if (isset($p['accept_encoding']))
+ $add += [CURLOPT_ENCODING => $p['accept_encoding']]; # NOTE: the curl library renamed the option to CURLOPT_ACCEPT_ENCODING, in php both are possible, CURLOPT_ENCODING is documented
+
return $add + [
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
@@ -236,7 +241,6 @@ static function curl_opts($p=array())
CURLOPT_CUSTOMREQUEST => $p['method'] ?: null,
CURLOPT_NOBODY => $p['method'] == 'HEAD',
CURLOPT_SAFE_UPLOAD => true, # disable special meaning of @value in POST forms (security)
- CURLOPT_ACCEPT_ENCODING => "", # set Header to accept any supported encoding and enable automatic decompression
CURLOPT_CAPATH => '/etc/ssl/certs/',
CURLOPT_SSL_VERIFYPEER => !$p['allow_insecure_ssl'],