Created
December 29, 2010 01:01
-
-
Save isaiahdw/757991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classes/kohana/response.php | 34 +++++++++++++++++++++++++--------- | |
1 files changed, 25 insertions(+), 9 deletions(-) | |
diff --git a/classes/kohana/response.php b/classes/kohana/response.php | |
index 6ec1a28..ad856b9 100644 | |
--- a/classes/kohana/response.php | |
+++ b/classes/kohana/response.php | |
@@ -177,6 +177,11 @@ class Kohana_Response implements Http_Response, Serializable { | |
protected $_protocol; | |
/** | |
+ * @var string The length of the response body | |
+ */ | |
+ protected $_content_length = NULL; | |
+ | |
+ /** | |
* Sets up the response object | |
* | |
* @param array $config Setup the response object | |
@@ -388,6 +393,23 @@ class Kohana_Response implements Http_Response, Serializable { | |
} | |
/** | |
+ * Set content length | |
+ * | |
+ * @return void | |
+ */ | |
+ public function set_content_length($length = NULL) | |
+ { | |
+ if ($length === NULL) | |
+ { | |
+ $this->_content_length = $this->content_length(); | |
+ } | |
+ else | |
+ { | |
+ $this->_content_length = $length; | |
+ } | |
+ } | |
+ | |
+ /** | |
* Sends the response status and all set headers. | |
* | |
* @return Response | |
@@ -413,16 +435,10 @@ class Kohana_Response implements Http_Response, Serializable { | |
$this->_header['x-powered-by'] = 'Kohana Framework '.Kohana::VERSION.' ('.Kohana::CODENAME.')'; | |
} | |
- // If in production, include the content length in the response | |
- if (Kohana::$environment === Kohana::PRODUCTION) | |
+ // Include the content length in the response if we have one | |
+ if ($this->_content_length) | |
{ | |
- $content_length = $this->content_length(); | |
- | |
- // Set the content length for the body if required | |
- if ($content_length > 0) | |
- { | |
- $this->_header['content-length'] = (string) $content_length; | |
- } | |
+ $this->_header['content-length'] = $this->_content_length; | |
} | |
// HTTP status line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment