Forum und email

HttpRequestPool::__construct

(PECL pecl_http:0.10.0-1.5.5)

HttpRequestPool::__construct — HttpRequestPool constructor

Descrierea

void HttpRequestPool::__construct ([ HttpRequest $request ] )

Instantiate a new HttpRequestPool object. An HttpRequestPool is able to send several HttpRequests in parallel.

Accepts virtually infinite optional parameters each referencing an HttpRequest object.

Parametri

request

HttpRequest object to attach

Erori/Excepţii

Throws HttpRequestPoolException (HttpRequestException, HttpInvalidParamException).

Exemple

Example#1 A HttpRequestPool example

<?php
try {
    
$pool = new HttpRequestPool(
        new 
HttpRequest('https://www.google.com/'HttpRequest::METH_HEAD),
        new 
HttpRequest('https://www.php.net/'HttpRequest::METH_HEAD)
    );
    
$pool->send();
    foreach(
$pool as $request) {
        
printf("%s is %s (%d)\n",
            
$request->getUrl(),
            
$request->getResponseCode() ? 'alive' 'not alive',
            
$request->getResponseCode()
        );
    }
} catch (
HttpException $e) {
    echo 
$e;
}
?>