diff --git a/application/classes/HTTP/Exception/404.php b/application/classes/HTTP/Exception/404.php index c2a3997..9651d3d 100644 --- a/application/classes/HTTP/Exception/404.php +++ b/application/classes/HTTP/Exception/404.php @@ -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(); } }