Removed caching from halt method.

pull/55/merge
Mike Cao 12 years ago
parent b4a9d6f70e
commit 93d7602b20

@ -104,6 +104,7 @@ class Engine {
$this->set('flight.views.path', './views'); $this->set('flight.views.path', './views');
$this->set('flight.log_errors', false); $this->set('flight.log_errors', false);
$this->set('flight.handle_errors', true); $this->set('flight.handle_errors', true);
$this->set('flight.base_url', null);
$initialized = true; $initialized = true;
} }
@ -321,13 +322,11 @@ class Engine {
* *
* @param int $code HTTP status code * @param int $code HTTP status code
* @param string $message Response message * @param string $message Response message
* @param bool $cache Cache response
*/ */
public function _halt($code = 200, $message = '', $cache = false) { public function _halt($code = 200, $message = '') {
$this->response(false) $this->response(false)
->status($code) ->status($code)
->write($message) ->write($message)
->cache($cache)
->send(); ->send();
} }
@ -440,7 +439,7 @@ class Engine {
$this->response()->header('ETag', $id); $this->response()->header('ETag', $id);
if ($id === getenv('HTTP_IF_NONE_MATCH')) { if ($id === getenv('HTTP_IF_NONE_MATCH')) {
$this->halt(304, '', true); $this->halt(304);
} }
} }
@ -453,7 +452,7 @@ class Engine {
$this->response()->header('Last-Modified', date(DATE_RFC1123, $time)); $this->response()->header('Last-Modified', date(DATE_RFC1123, $time));
if ($time === strtotime(getenv('HTTP_IF_MODIFIED_SINCE'))) { if ($time === strtotime(getenv('HTTP_IF_MODIFIED_SINCE'))) {
$this->halt(304, '', true); $this->halt(304);
} }
} }
} }

@ -151,21 +151,19 @@ class Response {
* @return object Self reference * @return object Self reference
*/ */
public function cache($expires) { public function cache($expires) {
if ($expires !== true) { if ($expires === false) {
if ($expires === false) { $this->headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
$this->headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; $this->headers['Cache-Control'] = array(
$this->headers['Cache-Control'] = array( 'no-store, no-cache, must-revalidate',
'no-store, no-cache, must-revalidate', 'post-check=0, pre-check=0',
'post-check=0, pre-check=0', 'max-age=0'
'max-age=0' );
); $this->headers['Pragma'] = 'no-cache';
$this->headers['Pragma'] = 'no-cache'; }
} else {
else { $expires = is_int($expires) ? $expires : strtotime($expires);
$expires = is_int($expires) ? $expires : strtotime($expires); $this->headers['Expires'] = gmdate('D, d M Y H:i:s', $expires) . ' GMT';
$this->headers['Expires'] = gmdate('D, d M Y H:i:s', $expires) . ' GMT'; $this->headers['Cache-Control'] = 'max-age='.($expires - time());
$this->headers['Cache-Control'] = 'max-age='.($expires - time());
}
} }
return $this; return $this;

Loading…
Cancel
Save