From f4b9ee7bd58b146996d25b1663d7e64b22b97847 Mon Sep 17 00:00:00 2001
From: Christian Helbling
Date: Thu, 29 Jun 2017 14:49:27 +0200
Subject: it_url: add option compression to use gzip or deflate (handled by
 curl)

---
 it_url.class | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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,
-- 
cgit v1.2.3