Allow for etag caching

This commit is contained in:
Deon George 2013-04-13 17:53:50 +10:00
parent 6f7913d363
commit 45c83c5025

View File

@ -43,13 +43,24 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
} elseif (preg_match('/^file:\/\/(.*)$/',$redirect,$matches) AND file_exists($matches[1])) {
$response->status(200);
$response->headers('Content-Type', Kohana_Exception::$error_view_content_type.'; charset='.Kohana::$charset);
$response->body(file_get_contents($redirect));
HTTP::check_cache($this->request(),$response,sha1($response->body()));
$response->headers('Content-Type',File::mime_by_ext(pathinfo($matches[1],PATHINFO_EXTENSION)));
$response->headers('Content-Length',(string)$response->content_length());
$response->headers('Last-Modified',date('r',$matches[1] ? filemtime($matches[1]) : time()));
}
return $response;
} catch (Exception $e) {
// Incase we are thrown in this exception.
if ($e instanceof HTTP_Exception AND $e->getCode() != 404) {
$x = new $e;
return $x->get_response();
}
return parent::get_response();
}
}