Example #1
0
 public function headerCallback($handle, $header)
 {
     if ($handle !== $this->curl->getHandle()) {
         throw new Exception('Error occurred.');
     }
     $this->headers[] = trim($header);
     return strlen($header);
 }
Example #2
0
 /**
  * @param Curl $ch
  *
  * @throws \Exception
  */
 private function safeRemove(Curl $ch)
 {
     $return = curl_multi_remove_handle($this->multiHandle, $ch->getHandle());
     if ($return !== 0) {
         throw new \Exception('Error occurred: ' . $return);
     }
 }
Example #3
0
File: Multi.php Project: skoro/curl
 /**
  * Remove Curl instance from multiple processing.
  * @param Curl $curl
  * @return bool
  */
 public function remove(Curl $curl)
 {
     $handle = $curl->getHandle();
     foreach ($this->multi as $i => $item) {
         if ($handle === $item->getHandler()) {
             curl_multi_remove_handle($this->handler, $item->getHandler());
             unset($item[$i]);
             return true;
         }
     }
     return false;
 }
Example #4
0
 /**
  * @see curl_multi_remove_handle()
  *
  * @param Curl $curl Handle to remove
  * @return int
  */
 public function remove(Curl $curl)
 {
     return curl_multi_remove_handle($this->handle, $curl->getHandle());
 }
Example #5
0
 /**
  * Returns the content of the specified cUrl instance.
  * @param \BluePsyduck\MultiCurl\Wrapper\Curl $curl
  * @return string The content.
  */
 public function getContent(Curl $curl)
 {
     return curl_multi_getcontent($curl->getHandle());
 }
Example #6
0
 function testClonningMakesHandleCopy()
 {
     $curl = new Curl(self::TEST_VALID_URL);
     $copy = clone $curl;
     $this->assertNotEquals($curl->getHandle(), $copy->getHandle());
 }
Example #7
0
 /**
  * Returns curl handle
  * @return resource
  */
 public function getCurlHandle()
 {
     return $this->curl->getHandle();
 }