Skip to content

Instantly share code, notes, and snippets.

@daharon
Created September 15, 2011 20:39

Revisions

  1. daharon revised this gist Sep 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion http_stream_test.php
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,6 @@
    $response = $request->getResponseBody();
    }

    return $response;
    echo $response;

    ?>
  2. daharon revised this gist Sep 15, 2011. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions http_stream_test.php
    Original file line number Diff line number Diff line change
    @@ -5,14 +5,20 @@
    'http://10.1.1.150:8888/watch',
    HTTP_METH_GET,
    array(
    'timeout' => 60,
    'onprogress' => function ($input) {
    echo print_r($input, true);
    },
    'timeout' => 60
    }
    )
    );

    $response = $request->send();
    return print_r($response->getBody(), true);
    try {
    $res = $request->send();
    $response = $res->getBody();
    } catch (\HttpRequestException $e) {
    $response = $request->getResponseBody();
    }

    return $response;

    ?>
  3. daharon created this gist Sep 15, 2011.
    18 changes: 18 additions & 0 deletions http_stream_test.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/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);

    ?>
    41 changes: 41 additions & 0 deletions output.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    $ ./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
    )

    ...