diff options
author | Kjartan Mannes <kjartan@2.no-reply.drupal.org> | 2003-09-29 13:41:22 +0000 |
---|---|---|
committer | Kjartan Mannes <kjartan@2.no-reply.drupal.org> | 2003-09-29 13:41:22 +0000 |
commit | 46e43ebed12729f42eb52f898f780a45102852b4 (patch) | |
tree | 8971d1d8d4b2abc8aca22bdf0c230557bf8ca2ae /includes/common.inc | |
parent | 0c3cc7b4877790c01588bd75508111f74c07d536 (diff) | |
download | brdo-46e43ebed12729f42eb52f898f780a45102852b4.tar.gz brdo-46e43ebed12729f42eb52f898f780a45102852b4.tar.bz2 |
- Fixed cache's handling of HTTP headers (passed all 9 unit tests)
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/includes/common.inc b/includes/common.inc index 2c88fadb6..81f155b21 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1173,17 +1173,18 @@ function drupal_page_header() { $etag = '"'. md5($date) .'"'; // Check http headers: - $modified_since = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) ? $_SERVER["HTTP_IF_MODIFIED_SINCE"] == $date : false; - $none_match = isset($_SERVER["HTTP_IF_NONE_MATCH"]) ? $_SERVER["HTTP_IF_NONE_MATCH"] == $etag : false; + $modified_since = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) ? $_SERVER["HTTP_IF_MODIFIED_SINCE"] == $date : NULL + $none_match = isset($_SERVER["HTTP_IF_NONE_MATCH"]) ? $_SERVER["HTTP_IF_NONE_MATCH"] == $etag : NULL; - // Send appropriate response: - //header("Last-Modified: $date"); - header("ETag: $etag"); - if ($modified_since && $none_match) { + // 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) { header("HTTP/1.0 304 Not Modified"); exit(); } + // Send appropriate response: + header("Last-Modified: $date"); + header("ETag: $etag"); print $cache->data; /* |