Created
September 15, 2011 20:39
-
-
Save daharon/1220410 to your computer and use it in GitHub Desktop.
Trying to get the output using HttpRequest's 'onprogress'.
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
#!/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; | |
?> |
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
$ ./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