From: Michael Wallner Date: Wed, 19 Oct 2005 07:49:10 +0000 (+0000) Subject: - better example/approach of using the protected HttpRequestPool methods X-Git-Tag: RELEASE_0_16_0~2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=f44ffa678f477c49d692bb83d2cfc2631ac6f7af;p=m6w6%2Fext-http - better example/approach of using the protected HttpRequestPool methods to process intermediate request results --- diff --git a/http_requestpool_object.c b/http_requestpool_object.c index c0ae135..b6662e1 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -333,20 +333,20 @@ PHP_METHOD(HttpRequestPool, send) * public function send() * { * while ($this->socketPerform()) { - * $this->handleRequests(); * if (!$this->socketSelect()) { * throw new HttpSocketExcpetion; * } * } - * $this->handleRequests(); * } * - * private function handleRequests() + * protected final function socketPerform() * { + * $result = parent::socketPerform(); * foreach ($this->getFinishedRequests() as $r) { * $this->detach($r); * // handle response of finished request * } + * return $result; * } * } * ?> diff --git a/tests/HttpRequestPool_002.phpt b/tests/HttpRequestPool_002.phpt index 053f1f6..26b1159 100644 --- a/tests/HttpRequestPool_002.phpt +++ b/tests/HttpRequestPool_002.phpt @@ -14,21 +14,23 @@ class MyPool extends HttpRequestPool public function send() { while ($this->socketPerform()) { - $this->handleRequests(); if (!$this->socketSelect()) { throw new HttpSocketException; } } - $this->handleRequests(); } - private function handleRequests() + protected final function socketPerform() { + $result = parent::socketPerform(); + echo "."; foreach ($this->getFinishedRequests() as $r) { echo "=", $r->getResponseCode(), "="; $this->detach($r); } + + return $result; } }