diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-08-28 11:08:04 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-08-28 11:08:04 +0000 |
commit | cc637b55793026464235a74e1cf46c5d4382c95f (patch) | |
tree | 33bc2b9f1baa00b37248019145532b392e340887 | |
parent | 16e19a71c2e4515433aca04c6523979f7dc89fdc (diff) | |
download | brdo-cc637b55793026464235a74e1cf46c5d4382c95f.tar.gz brdo-cc637b55793026464235a74e1cf46c5d4382c95f.tar.bz2 |
- Patch #80837 by killes and Dries: fixed 403 handling.
-rw-r--r-- | includes/bootstrap.inc | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index c220c7840..5d3c03ba8 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -396,22 +396,18 @@ function drupal_load($type, $name) { function drupal_page_header() { if (variable_get('cache', 0) && $cache = page_get_cache()) { bootstrap_invoke_all('init'); + // Set default values: - $date = gmdate('D, d M Y H:i:s', $cache->created) .' GMT'; - $etag = '"'. md5($date) .'"'; + $last_modified = gmdate('D, d M Y H:i:s', $cache->created) .' GMT'; + $etag = '"'.md5($last_modified).'"'; - // Check HTTP headers: - $modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $date : NULL; - if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && ($timestamp = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) > 0) { - $modified_since = $cache->created <= $timestamp; - } - else { - $modified_since = NULL; - } - $none_match = !empty($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] == $etag : NULL; + // See if the client has provided the required HTTP headers: + $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE; + $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE; - // The type checking here is very important, be careful when changing entries. - if (($modified_since !== NULL || $none_match !== NULL) && $modified_since !== FALSE && $none_match !== FALSE) { + if ($if_modified_since && $if_none_match + && $if_none_match == $etag // etag must match + && $if_modified_since == $last_modified) { // if-modified-since must match header('HTTP/1.1 304 Not Modified'); // All 304 responses must send an etag if the 200 response for the same object contained an etag header("Etag: $etag"); @@ -419,7 +415,7 @@ function drupal_page_header() { } // Send appropriate response: - header("Last-Modified: $date"); + header("Last-Modified: $last_modified"); header("ETag: $etag"); // The following headers force validation of cache: |