Issue Type: Patch Created: 2012-08-08T09:35:38.000+0000 Last Updated: 2012-08-08T09:35:38.000+0000 Status: Open Fix version(s): Reporter: Tuğrul Topuz (tugrul) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Controller
Related issues: Attachments:
I created following line to refer ErrorController with 404 status.
<pre class="highlight">
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
<pre class="highlight">
"HTTP 1.1 404 OK"
This might be like following line
<pre class="highlight">
"HTTP 1.1 404 Not Found"
I have created following patch to resolve this problem.
<pre class="highlight">
--- 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;
}
<pre class="highlight">
--- 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);
+ }
}
No comments to display