/** * @param \Zend_Controller_Response_Abstract $response * @return \Zend\Http\Headers */ protected function getHeadersFromResponse(\Zend_Controller_Response_Abstract $response) { $headers = new HttpHeaders(); foreach ($response->getRawHeaders() as $header) { $headers->addHeaderLine($header); } foreach ($response->getHeaders() as $header) { $headers->addHeaderLine($header['name'], $header['value']); } return $headers; }
/** * Is a Html Response * * Checks if it finds a Content-Type-header with the value text/html * * @param Zend_Controller_Response_Abstract $response * @return bool */ public function isHtmlResponse(Zend_Controller_Response_Abstract $response) { foreach ($response->getHeaders() as $value) { if ('content-type' == trim(strtolower($value['name'])) && false !== strpos(strtolower($value['value']), 'text/html')) { return true; } } foreach ($response->getRawHeaders() as $value) { $regex = preg_quote('content-type: text/html', '/'); if (preg_match('/' . $regex . '/i', $value)) { return true; } } return false; }