/** * @param $url * @return $this * @throws AlmCurlException * @throws AlmException */ public function exec($url) { $this->curlInit(); curl_setopt($this->curl, CURLOPT_URL, $url); curl_setopt($this->curl, CURLOPT_COOKIEFILE, $this->cookieStorage->getCurlCookieFile()); $result = curl_exec($this->curl); if (curl_errno($this->curl) === 0) { $this->result = $result; $this->info = curl_getinfo($this->curl); if (!$this->isResponseValid()) { if ($this->getHttpCode() == '500') { $error = $this->getInternalError(); throw new AlmException($error); } $httpCodeConstantName = get_class($this) . '::HTTP_' . $this->getHttpCode(); if (defined($httpCodeConstantName)) { throw new AlmCurlException(constant($httpCodeConstantName)); } throw new AlmCurlException('Disallowed HTTP response code: ' . $this->getHttpCode()); } } else { throw new AlmCurlException('Curl error: ' . curl_error($this->curl)); } $this->close(); return $this; }