summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass2017-08-17 14:08:38 +0200
committerNathan Gass2017-08-17 14:08:38 +0200
commit2d8b4e466045e81fb7f77e25b2ccbd7f3ab44fe0 (patch)
tree19ec8d84de1c57c8d271244005315cc9ca7c2eb9
parent87dc1f54bd1cb6bf17354b8d8f33a393fddf0349 (diff)
downloaditools-2d8b4e466045e81fb7f77e25b2ccbd7f3ab44fe0.tar.gz
itools-2d8b4e466045e81fb7f77e25b2ccbd7f3ab44fe0.tar.bz2
itools-2d8b4e466045e81fb7f77e25b2ccbd7f3ab44fe0.zip
fix basic authentication support in request_curl
-rw-r--r--it_url.class19
1 files changed, 9 insertions, 10 deletions
diff --git a/it_url.class b/it_url.class
index 8b2ef51..1594f4c 100644
--- a/it_url.class
+++ b/it_url.class
@@ -283,17 +283,18 @@ function request($p=array())
static function curl_opts($p=array())
{
$p += array('totaltimeout' => "999999", 'timeout' => 5);
+ $add = [];
foreach ($p['headers'] as $header => $value)
$headers[] = "$header: $value";
if ($p['maxlength']) {
$maxlength = $p['maxlength'];
- $add = array(
+ $add += [
#CURLOPT_BUFFERSIZE => 1024 * 1024 * 10,
CURLOPT_NOPROGRESS => false,
CURLOPT_PROGRESSFUNCTION => function ($dummy0, $dummy1, $size, $dummy2, $dummy3) use ($maxlength) { return $size < $maxlength ? 0 : 1; },
- );
+ ];
}
# file upload
@@ -301,17 +302,15 @@ static function curl_opts($p=array())
$p['data'][$field] = new CURLFile($filename, mime_content_type($filename));
if ($p['data'])
- $add[CURLOPT_POSTFIELDS] = $p['data'];
+ $add += [ CURLOPT_POSTFIELDS => $p['data'] ];
if ($p['compression'])
- $add[CURLOPT_ENCODING] = "";
+ $add += [ CURLOPT_ENCODING => "" ];
- if ($p['pass'] || $p['user']) {
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_setopt($ch, CURLOPT_USERPWD, $p['user'] . ':' . $p['pass']);
- }
+ if ($p['pass'] || $p['user'])
+ $add += [ CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $p['user'] . ':' . $p['pass'] ];
- return (array)$add + array(
+ return $add + [
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => $p['totaltimeout'],
@@ -327,7 +326,7 @@ static function curl_opts($p=array())
CURLOPT_SSL_VERIFYHOST => $p['allow_insecure_ssl'] ? 0 : 2,
CURLINFO_HEADER_OUT => 1,
- );
+ ];
}
/*