fix: require curl extension (#2617)

This commit is contained in:
dag 2022-04-10 18:54:18 +02:00 committed by GitHub
parent db28bedb23
commit c3a106892d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 63 additions and 94 deletions

View File

@ -128,35 +128,6 @@ function getContents($url, $header = array(), $opts = array(), $returnHeader = f
'content' => '', 'content' => '',
); );
// Use file_get_contents() if curl module is not installed
if(! function_exists('curl_version')) {
$httpHeaders = '';
foreach ($header as $headerL) {
$httpHeaders .= $headerL . "\r\n";
}
$ctx = stream_context_create(array(
'http' => array(
'header' => $httpHeaders
)
));
$data = @file_get_contents($url, 0, $ctx);
if($data === false) {
$errorCode = 500;
} else {
$errorCode = 200;
$retVal['header'] = implode("\r\n", $http_response_header);
}
$curlError = '';
$curlErrno = '';
$headerSize = 0;
$finalHeader = array();
} else {
$ch = curl_init($url); $ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@ -180,7 +151,6 @@ function getContents($url, $header = array(), $opts = array(), $returnHeader = f
foreach($opts as $key => $value) { foreach($opts as $key => $value) {
curl_setopt($ch, $key, $value); curl_setopt($ch, $key, $value);
} }
} }
if(defined('PROXY_URL') && !defined('NOPROXY')) { if(defined('PROXY_URL') && !defined('NOPROXY')) {
@ -225,7 +195,6 @@ function getContents($url, $header = array(), $opts = array(), $returnHeader = f
$finalHeader = end($headers); $finalHeader = end($headers);
curl_close($ch); curl_close($ch);
}
$finalHeader = array_change_key_case($finalHeader, CASE_LOWER); $finalHeader = array_change_key_case($finalHeader, CASE_LOWER);