Skip to content
Permalink
Browse files

adding options for react to response when asset not exists

  • Loading branch information...
zoghal committed Jan 31, 2014
1 parent 0906dec commit 40b7694891a597af6dd094c922b1c169a07fe470
Showing with 9 additions and 2 deletions.
  1. +9 −2 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 @@ public function beforeDispatch(CakeEvent $event) {
}
$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;

0 comments on commit 40b7694

Please sign in to comment.
You can’t perform that action at this time.