[contents] Respect passed headers for file_get_contents() (#1234)

* [contents] Respect passed headers for file_get_contents()
This commit is contained in:
triatic 2019-07-29 11:05:13 +01:00 committed by Teromene
parent cf525c964a
commit b6be18d585

View file

@ -56,7 +56,20 @@ function getContents($url, $header = array(), $opts = array()){
// Use file_get_contents if in CLI mode with no root certificates defined
if(php_sapi_name() === 'cli' && empty(ini_get('curl.cainfo'))) {
$data = @file_get_contents($url);
$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;