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(
'onprogress' => function ($input) {
echo print_r($input, true);
},
'timeout' => 60
)
);
$response = $request->send();
return print_r($response->getBody(), true);
?>
$ ./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