Last active
March 3, 2020 17:26
-
-
Save radutopala/8761ac647ee165d373b0c6d727cd56ea 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); | |
//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
Related to discussion from composer/composer#5814