mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Setting a correct Content-Length for plugin assets
This commit is contained in:
parent
9866882506
commit
60e3f02eac
2 changed files with 11 additions and 0 deletions
|
@ -315,6 +315,9 @@ class Dispatcher {
|
|||
}
|
||||
$response->type($contentType);
|
||||
}
|
||||
if (!$compressionEnabled) {
|
||||
$response->header('Content-Length', filesize($assetFile));
|
||||
}
|
||||
$response->cache(filemtime($assetFile));
|
||||
$response->send();
|
||||
ob_clean();
|
||||
|
|
|
@ -1291,6 +1291,14 @@ class DispatcherTest extends CakeTestCase {
|
|||
$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();
|
||||
|
|
Loading…
Add table
Reference in a new issue