From 46e43ebed12729f42eb52f898f780a45102852b4 Mon Sep 17 00:00:00 2001 From: Kjartan Mannes Date: Mon, 29 Sep 2003 13:41:22 +0000 Subject: - Fixed cache's handling of HTTP headers (passed all 9 unit tests) --- includes/common.inc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'includes/common.inc') 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; /* -- cgit v1.2.3