This is an example of how to intercept HTTP heades and body response receiving.
<?php
require '../websock2.php';
define('EOL', php_sapi_name() === 'cli' ? PHP_EOL : '<br>');
{
echo
'Headers for request ' . $request->
getFullAddress() .
' have been received!' . EOL;
$type = $headers->getHeader('Content-Type');
if($type !== null)
echo 'Content-type = ' . $type . EOL;
return true;
});
$sock->setOnReceiveBodyCallback(
function($headers, $data_part,
HttpSocket $sock,
WebRequest $request)
{
echo 'Received part of response body (' . strlen($data_part) . ')!' . EOL;
return true;
});
echo 'Done!';