diff options
author | Nathan Gass | 2017-08-16 15:18:10 +0200 |
---|---|---|
committer | Nathan Gass | 2017-08-16 15:18:10 +0200 |
commit | 2d19ce1300556bd3140fc82658e4c57c11904cf1 (patch) | |
tree | d87283ef7f660c79c4e40408fd30ea06d3ac456d /it_url.class | |
parent | c67e290061fc3ed7214b6f73b88730f1c87d7c10 (diff) | |
download | itools-2d19ce1300556bd3140fc82658e4c57c11904cf1.tar.gz itools-2d19ce1300556bd3140fc82658e4c57c11904cf1.tar.bz2 itools-2d19ce1300556bd3140fc82658e4c57c11904cf1.zip |
handle authentication in function request_curl
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/it_url.class b/it_url.class index ce98547..608e6b7 100644 --- a/it_url.class +++ b/it_url.class @@ -306,6 +306,11 @@ static function curl_opts($p=array()) if ($p['compression']) $add[CURLOPT_ENCODING] = ""; + if ($p['pass'] || $p['user']) { + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_setopt($ch, CURLOPT_USERPWD, $p['user'] . ':' . $p['pass']); + } + return (array)$add + array( CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, @@ -341,7 +346,7 @@ function request_curl($p=array()) $url->headers = array(); $p['headers'] = (array)$p['headers'] + self::_default_headers($url, $p); - $opts = array(CURLOPT_FOLLOWLOCATION => false, CURLOPT_HEADER => 1) + self::curl_opts($p); + $opts = array(CURLOPT_FOLLOWLOCATION => false, CURLOPT_HEADER => 1) + self::curl_opts($p + array('user' => $this->user, 'pass' => $this->pass)); $curl = curl_init($url->rawurl); curl_setopt_array($curl, $opts); |