Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Setting a correct Content-Length for plugin assets

  • Loading branch information...
commit 60e3f02eac982d5b20ab2c896009068a865e118a 1 parent 9866882
@lorenzo lorenzo authored
View
3  lib/Cake/Routing/Dispatcher.php
@@ -315,6 +315,9 @@ protected function _deliverAsset(CakeResponse $response, $assetFile, $ext) {
}
$response->type($contentType);
}
+ if (!$compressionEnabled) {
+ $response->header('Content-Length', filesize($assetFile));
+ }
$response->cache(filemtime($assetFile));
$response->send();
ob_clean();
View
8 lib/Cake/Test/Case/Routing/DispatcherTest.php
@@ -1291,6 +1291,14 @@ public function testAssets() {
$result = ob_get_clean();
$this->assertEqual('htc file', $result);
+ $response = $this->getMock('CakeResponse', array('_sendHeader'));
+ ob_start();
+ $Dispatcher->asset('test_plugin/css/unknown.extension', $response);
+ ob_end_clean();
+ $expected = filesize(CakePlugin::path('TestPlugin') . 'webroot' . DS . 'css' . DS . 'unknown.extension');
+ $headers = $response->header();
+ $this->assertEqual($expected, $headers['Content-Length']);
+
if (php_sapi_name() == 'cli') {
while (ob_get_level()) {
ob_get_clean();
Please sign in to comment.
Something went wrong with that request. Please try again.