ZF-12361: HTTP Status Message Incorrect

Description

I created following line to refer ErrorController with 404 status.


public function detailAction()
{
    throw new Zend_Controller_Action_Exception('News Not Exists', 404);
}

There aren't any problem for this but status message shown incorrect on client like following line


"HTTP 1.1 404 OK"

This might be like following line


"HTTP 1.1 404 Not Found"

I have created following patch to resolve this problem.


--- Zend/Controller/Response/Abstract.php   2012-08-06 01:48:38.000000000 +0300
+++ Zend/Controller/Response/Abstract.php   2012-08-08 11:59:51.000000000 +0300
@@ -234,6 +234,16 @@
     }
 
     /**
+     * Generate status message with current status code
+     *
+     * @return string
+     */
+    public function getStatusMessage()
+    {
+        return 'HTTP/1.1 ' . $this->_httpResponseCode;
+    }
+    
+    /**
      * Clear all {@link setRawHeader() raw HTTP headers}
      *
      * @return Zend_Controller_Response_Abstract
@@ -365,7 +375,7 @@
         }
 
         if (!$httpCodeSent) {
-            header('HTTP/1.1 ' . $this->_httpResponseCode);
+            header($this->getStatusMessage());
             $httpCodeSent = true;
         }
 


--- Zend/Controller/Response/Http.php   2012-08-06 01:48:38.000000000 +0300
+++ Zend/Controller/Response/Http.php   2012-08-08 12:04:50.000000000 +0300
@@ -22,6 +22,7 @@
 
 /** Zend_Controller_Response_Abstract */
 require_once 'Zend/Controller/Response/Abstract.php';
+require_once 'Zend/Http/Response.php';
 
 
 /**
@@ -35,4 +36,8 @@
  */
 class Zend_Controller_Response_Http extends Zend_Controller_Response_Abstract
 {
+    public function getStatusMessage()
+    {
+        return 'HTTP/1.1 ' . $this->_httpResponseCode . ' ' .Zend_Http_Response::responseCodeAsText($this->_httpResponseCode);
+    }
 }

Comments

No comments to display