Created
June 22, 2015 11:12
-
-
Save sbuzonas/57cea59ed3dc5de02e54 to your computer and use it in GitHub Desktop.
Test script for github.com/composer/composer/issues/4121
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = ''; | |
$headers = array( | |
'User-Agent: DownloadTest', | |
'Accept-Encoding: gzip', | |
'Connection: close', | |
); | |
$options = array( | |
'http' => array( | |
'follow_location' => 1, | |
'max_redirects' => 20, | |
'protocol_version' => 1.1, | |
'request_fulluri' => true, | |
'header' => $headers, | |
), | |
); | |
if ('https' === parse_url($url, PHP_URL_SCHEME)) { | |
$options['ssl']['SNI_enabled'] = true; | |
if (PHP_VERSION_ID < 50600) { | |
$options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST); | |
} | |
} | |
$options['http']['header'] = uasort($options['http']['header'], function ($k) { | |
return preg_match('{^content-type}i', $k) ? 1 : -1; | |
}); | |
$ctx = stream_context_create($options); | |
$result = file_get_contents($url, false, $ctx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment