Created
June 25, 2015 08:32
-
-
Save frederikbosch/2b75db3aa837c2ede873 to your computer and use it in GitHub Desktop.
Test from both servers
This file contains 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 | |
function download ($url) { | |
$headers = array( | |
'User-Agent: Composer/source (Windows NT; 6.2; PHP 5.6.5)', | |
'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'] = implode ("\n", $options['http']['header']); | |
$ctx = stream_context_create($options); | |
$stream = fopen($url, 'r', false, $ctx); | |
$headersBeforeContents = stream_get_meta_data($stream); | |
$content = stream_get_contents($stream); | |
$headersAfterContents = stream_get_meta_data($stream); | |
var_dump('start dump from ' . $url, $headersBeforeContents, $headersAfterContents, strlen($content), 'stop dump from ' . $url); | |
} | |
download('http://packagist.org/_p/symfony/finder%24a4bc31ef5d391952af0e7202b072f6d587ae89623277f89aefad0f9d49a9bc2c.json'); | |
download('http://dump.robbast.nl/finder$a4bc31ef5d391952af0e7202b072f6d587ae89623277f89aefad0f9d49a9bc2c.json'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment