summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Helbling2017-06-29 14:49:27 +0200
committerChristian Helbling2017-06-29 14:49:27 +0200
commitf4b9ee7bd58b146996d25b1663d7e64b22b97847 (patch)
tree71cd04c22303360e8afab54078bc1febe6f99861
parentfdc59a09ab47bd5566eefff7fd88d34980044f78 (diff)
downloaditools-f4b9ee7bd58b146996d25b1663d7e64b22b97847.tar.gz
itools-f4b9ee7bd58b146996d25b1663d7e64b22b97847.tar.bz2
itools-f4b9ee7bd58b146996d25b1663d7e64b22b97847.zip
it_url: add option compression to use gzip or deflate (handled by curl)
-rw-r--r--it_url.class6
1 files changed, 5 insertions, 1 deletions
diff --git a/it_url.class b/it_url.class
index 2b1ee18..3525117 100644
--- a/it_url.class
+++ b/it_url.class
@@ -104,6 +104,7 @@ function is_reachable($timeout = 5)
* @param $p['files'] [fieldname => filename] of files to upload
* @param $p['retries'] Number of retries if download fails, default 1
* @param $p['retrysleep'] Number of seconds to wait before retry, fractions ok
+ * @param $p['compression'] use compression (uses curl to do that)
* @return contents of resulting page, considering redirects, excluding headers, or false on error
*/
function get($p=null, $timeout=5)
@@ -124,7 +125,7 @@ function get($p=null, $timeout=5)
else # called statically
$url = new it_url($p['url']);
- if ($url->protocol == 'http' && !$p['curl'] && !$p['files']) # only curl can do file upload or non-http protocols
+ if ($url->protocol == 'http' && !$p['curl'] && !$p['files'] && !$p['compression']) # only curl can do file upload or non-http protocols
$result = $url->request($p);
else
$result = $url->request_curl($p);
@@ -298,6 +299,9 @@ static function curl_opts($p=array())
if ($p['data'])
$add[CURLOPT_POSTFIELDS] = $p['data'];
+ if ($p['compression'])
+ $add[CURLOPT_ENCODING] = "";
+
return (array)$add + array(
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,