adding options for react to response when asset not exists

This commit is contained in:
Saleh Souzanchi 2014-01-31 08:23:02 +03:30 committed by zoghal
parent 0906dec3c4
commit 40b7694891

View file

@ -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;