defer warnings/exceptions of the client
authorMichael Wallner <mike@php.net>
Fri, 20 Mar 2015 07:28:40 +0000 (08:28 +0100)
committerMichael Wallner <mike@php.net>
Fri, 20 Mar 2015 07:36:09 +0000 (08:36 +0100)
commitc47d3fa3f7d62ee8595abfecaae989ec048e3257
tree05dab01e6d89442cacd0a37c5a832dac8865e5b1
parentb10189da6953e651aa86b0191d2a2ae964c38b51
defer warnings/exceptions of the client

This enables the following pattern:

<?php
use http\Client;

function handle_response_and_dequeue($res) {
var_dump($res->getResponseCode());
return true; //dequeue
}

$client = new Client;
$client->enqueue(new Client\Request(...),"handle_response_and_dequeue");
$client->enqueue(new Client\Request(...),"handle_response_and_dequeue");
$client->enqueue(new Client\Request(...),"handle_response_and_dequeue");

while (count($client)) {
try {
$client->send();
} catch (Exception $e) {
echo $e->getMessage(),"\n";
}
}
php_http_client_curl.c