public function testnullIsReturnedWhenRequestingANonExistingHeader() { $response = new CurlClientResponse("HTTP/1.1 200 OK\r\nCache-Control: max-age=30\r\nCache-Control: s-maxage=50\r\n\r\n"); $this->assertEquals(null, $response->getHeader('Host')); }
/** * Executes a Curl. * * @param String $method * @param String $location * * @return CurlClientResponse * @throws ConnectionFailedException */ public function execute($method, $location) { curl_setopt_array($this->curl, [CURLOPT_URL => $location, CURLOPT_COOKIE => $this->getRequestCookies(), CURLOPT_CUSTOMREQUEST => $method]); if (!($response = curl_exec($this->curl))) { $err = curl_error($this->curl); $msg = sprintf("unable to communicate with server at '%s'; %s", $location, $err); $this->restart(); throw new ConnectionFailedException($msg); } $response = new CurlClientResponse($response); $this->cookies = array_merge($this->cookies, $response->getCookies()); if ($this->restart === true) { $this->restart(); } return $response; }