summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Helbling2011-06-15 07:28:07 +0000
committerChristian Helbling2011-06-15 07:28:07 +0000
commit17e4e31dd7f5b943d6d23f4ccde01d3214a52ff9 (patch)
tree81aabad7f57e1187a02399e1a306ede63dc8ad94
parenta5715b0a60991eff22fb5c34f5b3275333949e3d (diff)
downloaditools-17e4e31dd7f5b943d6d23f4ccde01d3214a52ff9.tar.gz
itools-17e4e31dd7f5b943d6d23f4ccde01d3214a52ff9.tar.bz2
itools-17e4e31dd7f5b943d6d23f4ccde01d3214a52ff9.zip
added custom headers to get_multi
-rw-r--r--it_url.class8
1 files changed, 8 insertions, 0 deletions
diff --git a/it_url.class b/it_url.class
index aa4f985..91dae20 100644
--- a/it_url.class
+++ b/it_url.class
@@ -351,12 +351,19 @@ function get($p=null, $timeout=5)
* @param $p['urls']: array of urls to get
* @param $p['timeout']: timeout per read in seconds, defaults to 5. (TODO: fractions allowed?)
* @param $p['totaltimeout']: timeout for the whole function call
+ * @param $p['headers']: optional array of HTTP headers to send
* @return array of contents of resulting page using same keys as the urls input array,
* considering redirects, excluding headers
*/
function get_multi($p=null)
{
$p += array('totaltimeout' => "999999", 'timeout' => 5, 'retries' => 1);
+ $p['headers'] = (array)$p['headers'] + array(
+ 'User-Agent' => "Mozilla/4.0 (compatible; MSIE 7.0; ITools)",
+ 'Accept-Language' => T_lang(),
+ );
+ foreach ($p['headers'] as $header => $value)
+ $headers[] = "$header: $value";
$opts = array(
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
@@ -364,6 +371,7 @@ function get_multi($p=null)
CURLOPT_LOW_SPEED_LIMIT => 5,
CURLOPT_LOW_SPEED_TIME => $p['timeout'],
CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_HTTPHEADER => $headers,
);
$mh = curl_multi_init();