projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
fix typo
[m6w6/ext-http]
/
tests
/
requestpool001.phpt
diff --git
a/tests/requestpool001.phpt
b/tests/requestpool001.phpt
index 790823c7310fac3d4f1715079a44653976b1489c..ff91a406801c2a2037c90256dc4969b851bbc4cc 100644
(file)
--- a/
tests/requestpool001.phpt
+++ b/
tests/requestpool001.phpt
@@
-7,18
+7,13
@@
include 'skipif.inc';
--FILE--
<?php
--FILE--
<?php
-use http\request\Factory as HttpRequestFactory;
-use http\request\Pool as HttpRequestPool;
-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);
echo "-TEST\n";
set_time_limit(0);
ini_set('error_reporting', E_ALL);
ini_set('html_errors', 0);
-class Pool extends
HttpRequest
Pool
+class Pool extends
\http\Curl\Client\
Pool
{
private $all;
private $rem;
{
private $all;
private $rem;
@@
-50,9
+45,7
@@
class Pool extends HttpRequestPool
foreach ($now as $url => $file) {
$this->attach(
foreach ($now as $url => $file) {
$this->attach(
- $this->factory->createRequest(
- $url,
- "GET",
+ $this->factory->createClient(
array(
'redirect' => 5,
'compress' => GZIP,
array(
'redirect' => 5,
'compress' => GZIP,
@@
-60,13
+53,13
@@
class Pool extends HttpRequestPool
'connecttimeout' => TOUT,
'lastmodified' => is_file($file)?filemtime($file):0
)
'connecttimeout' => TOUT,
'lastmodified' => is_file($file)?filemtime($file):0
)
- )
+ )
->setRequest(new http\Client\Request("GET", $url))
);
}
while ($this->once()) {
if (!$this->wait()) {
);
}
while ($this->once()) {
if (!$this->wait()) {
- throw new
HttpSocket
Exception;
+ throw new
http\
Exception;
}
}
}
}
}
}
@@
-75,19
+68,19
@@
class Pool extends HttpRequestPool
{
try {
$rc = parent::once();
{
try {
$rc = parent::once();
- } catch (
HttpRequest
Exception $x) {
+ } catch (
http\
Exception $x) {
// a request may have thrown an exception,
// but it is still save to continue
echo $x->getMessage(), "\n";
}
// a request may have thrown an exception,
// but it is still save to continue
echo $x->getMessage(), "\n";
}
- foreach ($this->getFinished
Requests
() as $r) {
+ foreach ($this->getFinished() as $r) {
$this->detach($r);
$this->detach($r);
- $u = $r->getUrl();
- $c = $r->getResponseCode();
+ $u = $r->get
Request()->getRequest
Url();
+ $c = $r->getResponse
Message()->getResponse
Code();
try {
try {
- $b = $r->getResponseBody();
+ $b = $r->getResponse
Message()->get
Body();
} catch (\Exception $e) {
echo $e->getMessage(), "\n";
$b = "";
} catch (\Exception $e) {
echo $e->getMessage(), "\n";
$b = "";
@@
-102,9
+95,7
@@
class Pool extends HttpRequestPool
if ($a = each($this->rem)) {
list($url, $file) = $a;
$this->attach(
if ($a = each($this->rem)) {
list($url, $file) = $a;
$this->attach(
- $this->factory->createRequest(
- $url,
- "GET",
+ $this->factory->createClient(
array(
'redirect' => 5,
'compress' => GZIP,
array(
'redirect' => 5,
'compress' => GZIP,
@@
-112,7
+103,7
@@
class Pool extends HttpRequestPool
'connecttimeout' => TOUT,
'lastmodified' => is_file($file)?filemtime($file):0
)
'connecttimeout' => TOUT,
'lastmodified' => is_file($file)?filemtime($file):0
)
- )
+ )
->setRequest(new http\Client\Request("GET", $url))
);
}
}
);
}
}
@@
-126,7
+117,7
@@
define('RMAX', 10);
chdir(__DIR__);
$time = microtime(true);
chdir(__DIR__);
$time = microtime(true);
-$factory = new
HttpRequestFactory(array("driver" => "curl", "reques
tPoolClass" => "Pool"));
+$factory = new
http\Client\Factory(array("driver" => "curl", "clien
tPoolClass" => "Pool"));
$factory->createPool()->run($factory);
printf("Elapsed: %0.3fs\n", microtime(true)-$time);
$factory->createPool()->run($factory);
printf("Elapsed: %0.3fs\n", microtime(true)-$time);