send_multi_request() public method

Sends the request using , enabling parallel requests. Uses the "rolling" method.
public send_multi_request ( array $handles, array $opt = null ) : array
$handles array (Required) An indexed array of cURL handles to process simultaneously.
$opt array (Optional) An associative array of parameters that can have the following keys:
  • callback - string|array - Optional - The string name of a function to pass the response data to. If this is a method, pass an array where the [0] index is the class and the [1] index is the method name.
  • limit - integer - Optional - The number of simultaneous requests to make. This can be useful for scaling around slow server responses. Defaults to trusting cURLs judgement as to how many to use.
return array Post-processed cURL responses.
Beispiel #1
0
 public function testSendMultiRequest()
 {
     $httpCore = new RequestCore("http://www.baidu.com");
     $ch1 = curl_init("http://www.baidu.com");
     curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
     $ch2 = curl_init("http://cn.bing.com");
     curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
     @($result = $httpCore->send_multi_request(array($ch1, $ch2)));
     $this->assertNotNull($result);
 }
 public function testSendMultiRequest()
 {
     $httpCore = new RequestCore("http://www.baidu.com");
     @($result = $httpCore->send_multi_request(array(curl_init("http://www.baidu.com"), curl_init("http://www.baidu.com"))));
     $this->assertNotNull($result);
 }