-
-
Save Dezinger/4c3a7aeb4b00138787c5a83175c7c852 to your computer and use it in GitHub Desktop.
Composer GZIP decoding test
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 | |
$retries = 0; | |
function fetch() { | |
global $retries; | |
echo "Retry " . $retries . " | "; | |
$opts = array( | |
'http' => array( | |
'header' => array( | |
"Accept-Encoding: gzip", | |
"Connection: close", | |
"User-Agent: Composer/1.2.1 (Linux; 3.13.0-86-generic; PHP 7.0.12)" | |
), | |
'ignore_errors' => "1", | |
'protocol_version' => "1.1" | |
) | |
); | |
$context = stream_context_create($opts); | |
//$result = file_get_contents('http://packagist.org/p/paragonie/random_compat%24f49f654e75ef0944f24b3ffb74b531f0f5a757a807bcbda5b511b85d41ff7dcb.json', false, $context); | |
$result = file_get_contents('http://packagist.org/p/psr/http-message%24086db8e213c53693bf473e07712c3c3e4c6ec4dffe350f6dad7228c3ff8c672e.json', false, $context); | |
//print_r($http_response_header); | |
$retries++; | |
if (($result = @zlib_decode($result)) !== false) { | |
echo "Decoded successfully!\n"; | |
} else { | |
echo "Error in Decoding process! Re-fetching ...\n"; | |
fetch(); | |
} | |
} | |
fetch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment