/** * Parses the header retrieved from the cURL response into * our Response object. * * @param array $headers */ protected function setResponseHeaders(array $headers = []) { foreach ($headers as $header) { if (($pos = strpos($header, ':')) !== false) { $title = substr($header, 0, $pos); $value = substr($header, $pos + 1); $this->response->setHeader($title, $value); } else { if (substr($header, 0, 4) == 'HTTP') { preg_match('#^HTTP\\/([12]\\.[01]) ([0-9]+) (.+)#', $header, $matches); if (isset($matches[1])) { $this->response->setProtocolVersion($matches[1]); } if (isset($matches[2])) { $this->response->setStatusCode($matches[2], isset($matches[3]) ? $matches[3] : null); } } } } }