diff --git a/cake/libs/view/media.php b/cake/libs/view/media.php index 4db09e0dfc1..fba19c69ab8 100644 --- a/cake/libs/view/media.php +++ b/cake/libs/view/media.php @@ -20,6 +20,12 @@ App::import('View', 'View', false); class MediaView extends View { +/** + * Indicates whether response gzip compression was enabled for this class + * + * @var boolean + */ + private $compressionEnabled = false; /** * Constructor @@ -42,7 +48,7 @@ function __construct(&$controller) { * @return unknown */ function render() { - $name = $download = $extension = $id = $modified = $path = $size = $cache = $mimeType = null; + $name = $download = $extension = $id = $modified = $path = $size = $cache = $mimeType = $compress = null; extract($this->viewVars, EXTR_OVERWRITE); if ($size) { @@ -135,7 +141,9 @@ function render() { )); } $this->_clearBuffer(); - $this->_sendFile($handle); + if ($compress) { + $this->compressionEnabled = $this->response->compress(); + } $this->response->send(); return $this->_sendFile($handle); @@ -155,7 +163,9 @@ protected function _sendFile($handle) { set_time_limit(0); $buffer = fread($handle, $chunkSize); echo $buffer; - $this->_flushBuffer(); + if (!$this->compressionEnabled) { + $this->_flushBuffer(); + } } fclose($handle); }