Skip to content

Instantly share code, notes, and snippets.

@daharon
Created September 15, 2011 20:39
Show Gist options
  • Save daharon/1220410 to your computer and use it in GitHub Desktop.
Save daharon/1220410 to your computer and use it in GitHub Desktop.
Trying to get the output using HttpRequest's 'onprogress'.
#!/usr/bin/php
<?php
$request = new \HttpRequest(
'http://10.1.1.150:8888/watch',
HTTP_METH_GET,
array(
'timeout' => 60,
'onprogress' => function ($input) {
echo print_r($input, true);
}
)
);
try {
$res = $request->send();
$response = $res->getBody();
} catch (\HttpRequestException $e) {
$response = $request->getResponseBody();
}
echo $response;
?>
$ ./http_stream_test.php
Array
(
[dltotal] => 0
[dlnow] => 0
[ultotal] => 0
[ulnow] => 0
)
Array
(
[dltotal] => 0
[dlnow] => 16
[ultotal] => 0
[ulnow] => 0
)
Array
(
[dltotal] => 0
[dlnow] => 21
[ultotal] => 0
[ulnow] => 0
)
...
Array
(
[dltotal] => 0
[dlnow] => 76
[ultotal] => 0
[ulnow] => 0
)
Array
(
[dltotal] => 0
[dlnow] => 725
[ultotal] => 0
[ulnow] => 0
)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment