Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 public function testDisplay()
 {
     $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 with FirePHP/1.6';
     $this->_response->expects($this->atLeastOnce())->method('sendHeaders');
     $this->_object->display();
     $actualHeaders = $this->_response->getHeaders();
     $this->assertNotEmpty($actualHeaders);
     $actualProtocol = false;
     $actualProfilerData = false;
     foreach ($actualHeaders as $oneHeader) {
         $headerName = $oneHeader['name'];
         $headerValue = $oneHeader['value'];
         if (!$actualProtocol && $headerName == 'X-Wf-Protocol-1') {
             $actualProtocol = $headerValue;
         }
         if (!$actualProfilerData && $headerName == 'X-Wf-1-1-1-1') {
             $actualProfilerData = $headerValue;
         }
     }
     $this->assertContains('Protocol/JsonStream', $actualProtocol);
     $this->assertContains('"Type":"TABLE","Label":"Code Profiler Title"', $actualProfilerData);
     $this->assertContains('[' . '["Timer Id","Time","Avg","Cnt","Emalloc","RealMem"],' . '["some_root_timer","0.080000","0.040000","2","51,000,000","50,000,000"],' . '[". some_nested_timer","0.080000","0.026667","3","42,000,000","40,000,000"],' . '[". . some_deeply_nested_timer","0.030000","0.010000","3","13,000,000","10,000,000"],' . '["one_more_root_timer","0.010000","0.010000","1","23,456,789","12,345,678"]]', $actualProfilerData);
 }
Exemplo n.º 3
0
 /**
  * Format up the ZF1 response headers into Symfony\Component\BrowserKit\Response headers format.
  *
  * @param \Zend_Controller_Response_Abstract $response The ZF1 Response Object.
  * @return array the clean key/value headers
  */
 private function formatResponseHeaders(\Zend_Controller_Response_Abstract $response)
 {
     $headers = array();
     foreach ($response->getHeaders() as $header) {
         $name = $header['name'];
         if (array_key_exists($name, $headers)) {
             if ($header['replace']) {
                 $headers[$name] = $header['value'];
             }
         } else {
             $headers[$name] = $header['value'];
         }
     }
     return $headers;
 }
Exemplo n.º 4
0
 /**
  * @static
  * @param \Zend_Controller_Response_Abstract $response
  * @return bool
  */
 public static function isHtmlResponse(\Zend_Controller_Response_Abstract $response)
 {
     // check if response is html
     $headers = $response->getHeaders();
     foreach ($headers as $header) {
         if ($header["name"] == "Content-Type") {
             if (strpos($header["value"], "html") === false) {
                 return false;
             }
         }
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * 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;
 }
 /**
  *
  * @param Zend_Controller_Response_Abstract $response
  * @param string $location
  */
 protected function assertResponseLocationHeader($response, $location)
 {
     $locationActual = null;
     foreach ($response->getHeaders() as $header) {
         if ($header['name'] === 'Location') {
             $locationActual = $header['value'];
         }
     }
     $this->assertNotNull($locationActual);
     $this->assertEquals($location, $locationActual);
 }