Skip to content

Instantly share code, notes, and snippets.

@dshafik

dshafik/push.php Secret

Created November 14, 2015 01:13
Show Gist options
  • Save dshafik/1205bd6d3dbd797f9956 to your computer and use it in GitHub Desktop.
Save dshafik/1205bd6d3dbd797f9956 to your computer and use it in GitHub Desktop.
<?php
$callback = function() {
$args = func_get_args();
var_dump($args);
return CURL_PUSH_OK;
};
$mh = curl_multi_init();
curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback);
$data = [];
//curl_multi_setopt($mh, CURLMOPT_PUSHDATA, $data);
$ch = curl_init();
//curl_setopt($ch, CURLOPT_URL, 'http://192.168.99.100:32781/index.php');
//curl_setopt($ch, CURLOPT_URL, 'http://0.0.0.0:8080/curl');
//curl_setopt($ch, CURLOPT_URL, 'http://http2.akamai.com');
curl_setopt($ch, CURLOPT_URL, $_SERVER['argv'][1]);
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_multi_add_handle($mh, $ch);
$active = null;
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
curl_multi_close($mh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment