X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=tests%2Frequestpool001.phpt;h=ff91a406801c2a2037c90256dc4969b851bbc4cc;hp=462af710759852cb0e42ea905719625795847711;hb=5855b4ed57714dabea33a2c57d4b9cb1a03af70c;hpb=a84a30daa74ea8ff52a671769528ccf06580be4e diff --git a/tests/requestpool001.phpt b/tests/requestpool001.phpt index 462af71..ff91a40 100644 --- a/tests/requestpool001.phpt +++ b/tests/requestpool001.phpt @@ -7,19 +7,13 @@ include 'skipif.inc'; --FILE-- $file) { $this->attach( - $this->factory->createRequest( - $url, - HttpRequestMethod::GET, + $this->factory->createClient( array( 'redirect' => 5, 'compress' => GZIP, @@ -61,13 +53,13 @@ class Pool extends HttpRequestPool '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; } } } @@ -76,19 +68,19 @@ class Pool extends HttpRequestPool { 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 = ""; @@ -103,9 +95,7 @@ class Pool extends HttpRequestPool 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, @@ -113,7 +103,7 @@ class Pool extends HttpRequestPool 'connecttimeout' => TOUT, 'lastmodified' => is_file($file)?filemtime($file):0 ) - ) + )->setRequest(new http\Client\Request("GET", $url)) ); } } @@ -127,7 +117,7 @@ define('RMAX', 10); 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);