--FILE--
<?php
-use http\request\Factory as HttpRequestFactory;
-use http\request\Pool as HttpRequestPool;
-use http\request\Method as HttpRequestMethod;
-use http\Exception as HttpRequestException;
-use http\Exception as HttpSocketException;
-
echo "-TEST\n";
set_time_limit(0);
ini_set('error_reporting', E_ALL);
ini_set('html_errors', 0);
-class Pool extends HttpRequestPool
+class Pool extends \http\Curl\Client\Pool
{
private $all;
private $rem;
foreach ($now as $url => $file) {
$this->attach(
- $this->factory->createRequest(
- $url,
- HttpRequestMethod::GET,
+ $this->factory->createClient(
array(
'redirect' => 5,
'compress' => GZIP,
'connecttimeout' => TOUT,
'lastmodified' => is_file($file)?filemtime($file):0
)
- )
+ )->setRequest(new http\Client\Request("GET", $url))
);
}
while ($this->once()) {
if (!$this->wait()) {
- throw new HttpSocketException;
+ throw new http\Exception;
}
}
}
{
try {
$rc = parent::once();
- } catch (HttpRequestException $x) {
+ } catch (http\Exception $x) {
// a request may have thrown an exception,
// but it is still save to continue
echo $x->getMessage(), "\n";
}
- foreach ($this->getFinishedRequests() as $r) {
+ foreach ($this->getFinished() as $r) {
$this->detach($r);
- $u = $r->getUrl();
- $c = $r->getResponseCode();
+ $u = $r->getRequest()->getRequestUrl();
+ $c = $r->getResponseMessage()->getResponseCode();
try {
- $b = $r->getResponseBody();
+ $b = $r->getResponseMessage()->getBody();
} catch (\Exception $e) {
echo $e->getMessage(), "\n";
$b = "";
if ($a = each($this->rem)) {
list($url, $file) = $a;
$this->attach(
- $this->factory->createRequest(
- $url,
- HttpRequestMethod::GET,
+ $this->factory->createClient(
array(
'redirect' => 5,
'compress' => GZIP,
'connecttimeout' => TOUT,
'lastmodified' => is_file($file)?filemtime($file):0
)
- )
+ )->setRequest(new http\Client\Request("GET", $url))
);
}
}
chdir(__DIR__);
$time = microtime(true);
-$factory = new HttpRequestFactory(array("driver" => "curl", "requestPoolClass" => "Pool"));
+$factory = new http\Client\Factory(array("driver" => "curl", "clientPoolClass" => "Pool"));
$factory->createPool()->run($factory);
printf("Elapsed: %0.3fs\n", microtime(true)-$time);