PHP Classes

File: examples/03-chunked-encoding.php

Recommend this page to a friend!
  Classes of Sergey Shuchkin  >  React PHP HTTP Client  >  examples/03-chunked-encoding.php  >  Download  
File: examples/03-chunked-encoding.php
Role: Example script
Content type: text/plain
Description: Example script
Class: React PHP HTTP Client
Process HTTP request responses asynchronously
Author: By
Last change:
Date: 2 years ago
Size: 534 bytes
 

Contents

Class file image Download
<?php

require_once __DIR__ . '/../vendor/autoload.php';

$loop = \React\EventLoop\Factory::create();

$http = new \Shuchkin\ReactHTTP\Client( $loop );
$http->get( 'https://jigsaw.w3.org/HTTP/ChunkedScript' )->then( function () {

    echo
PHP_EOL . 'Mission complete';

}, function ( \
Exception $ex ) {

    echo
'ERROR '.$ex->getCode().' '.$ex->getMessage();

} );

$http->on('chunk', function( $chunk ) {
    echo
PHP_EOL.'-- CHUNK='.$chunk;
   
//$client->
});

//$http->on('debug', function( $s ) { echo trim($s).PHP_EOL; } );

$loop->run();

For more information send a message to info at phpclasses dot org.