From 676e1cda78b7bc4eede7cad509a8d9f015a51816 Mon Sep 17 00:00:00 2001
From: Pascal Kriete
Date: Fri, 9 Apr 2010 21:16:16 +0200
Subject: Adding output library exceptions for servers with
zlib.output_compression enabled.
---
system/core/Output.php | 15 ++++++++++++++-
user_guide/changelog.html | 1 +
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/system/core/Output.php b/system/core/Output.php
index ac4129405..e25e62197 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -34,10 +34,13 @@ class CI_Output {
var $enable_profiler = FALSE;
var $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage}
+ var $_zlib_oc = FALSE;
var $_profiler_sections = array();
function CI_Output()
{
+ $this->_zlib_oc = @ini_get('zlib.output_compression');
+
log_message('debug', "Output Class Initialized");
}
@@ -111,6 +114,16 @@ class CI_Output {
*/
function set_header($header, $replace = TRUE)
{
+ // If zlib.output_compression is enabled it will compress the output,
+ // but it will not modify the content-length header to compensate for
+ // the reduction, causing the browser to hang waiting for more data.
+ // We'll just skip content-length in those cases.
+
+ if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0)
+ {
+ return;
+ }
+
$this->headers[] = array($header, $replace);
}
@@ -234,7 +247,7 @@ class CI_Output {
// --------------------------------------------------------------------
// Is compression requested?
- if ($CFG->item('compress_output') === TRUE)
+ if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE)
{
if (extension_loaded('zlib'))
{
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 21c35d6a8..14d173ab8 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -128,6 +128,7 @@ Hg Tag:
get_mime_by_extension() is now case insensitive.
Added "default" to the list Reserved Names.
Added 'application/x-msdownload' for .exe files and ''application/x-gzip-compressed' for .tgz files to config/mimes.php.
+ Updated the output library to no longer compress output or send content-length headers if the server runs with zlib.output_compression enabled.
Eliminated a call to is_really_writable() on each request unless it is really needed (Output caching)
Documented append_output() in the Output Class.
Documented a second argument in the decode() function for the Encryption Class.
--
cgit v1.2.3-24-g4f1b