[contents] Respect passed headers for file_get_contents() (#1234)
* [contents] Respect passed headers for file_get_contents()
This commit is contained in:
parent
cf525c964a
commit
b6be18d585
1 changed files with 14 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue