public function headerCallback($handle, $header) { if ($handle !== $this->curl->getHandle()) { throw new Exception('Error occurred.'); } $this->headers[] = trim($header); return strlen($header); }
/** * @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); } }
/** * 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; }
/** * @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()); }
/** * 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()); }
function testClonningMakesHandleCopy() { $curl = new Curl(self::TEST_VALID_URL); $copy = clone $curl; $this->assertNotEquals($curl->getHandle(), $copy->getHandle()); }
/** * Returns curl handle * @return resource */ public function getCurlHandle() { return $this->curl->getHandle(); }