diff --git a/lib/Cake/Routing/Filter/AssetDispatcher.php b/lib/Cake/Routing/Filter/AssetDispatcher.php index 1e5d7a6fe..c15a68416 100644 --- a/lib/Cake/Routing/Filter/AssetDispatcher.php +++ b/lib/Cake/Routing/Filter/AssetDispatcher.php @@ -38,7 +38,8 @@ class AssetDispatcher extends DispatcherFilter { * Checks if a requested asset exists and sends it to the browser * * @param CakeEvent $event containing the request and response object - * @return CakeResponse if the client is requesting a recognized asset, null otherwise + * @return mixed The resulting response. + * @throws NotFoundException When asset not found */ public function beforeDispatch(CakeEvent $event) { $url = urldecode($event->data['request']->url); @@ -52,13 +53,19 @@ class AssetDispatcher extends DispatcherFilter { } $assetFile = $this->_getAssetFile($url); - if ($assetFile === null || !file_exists($assetFile)) { + if ($assetFile === null) { return null; } $response = $event->data['response']; $event->stopPropagation(); + if (!file_exists($assetFile)) { + $response->statusCode(404); + $response->send(); + return $response; + } + $response->modified(filemtime($assetFile)); if ($response->checkNotModified($event->data['request'])) { return $response;