summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc2
-rw-r--r--includes/common.inc2
-rw-r--r--includes/tests/bootstrap.test26
3 files changed, 28 insertions, 2 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 63f704a1d..06a154197 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -549,7 +549,7 @@ function page_get_cache() {
$cache = NULL;
- if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET' && count(drupal_set_message()) == 0) {
+ if (!$user->uid && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && count(drupal_set_message()) == 0) {
$cache = cache_get($base_root . request_uri(), 'cache_page');
if (empty($cache)) {
diff --git a/includes/common.inc b/includes/common.inc
index 7263d0a5b..ee604fb9e 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2490,7 +2490,7 @@ function _drupal_bootstrap_full() {
function page_set_cache() {
global $user, $base_root;
- if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET' && count(drupal_get_messages(NULL, FALSE)) == 0) {
+ if (!$user->uid && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && count(drupal_get_messages(NULL, FALSE)) == 0) {
// This will fail in some cases, see page_get_cache() for the explanation.
if ($data = ob_get_contents()) {
$cache = TRUE;
diff --git a/includes/tests/bootstrap.test b/includes/tests/bootstrap.test
index 4b2cf3089..3bb197aae 100644
--- a/includes/tests/bootstrap.test
+++ b/includes/tests/bootstrap.test
@@ -81,3 +81,29 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase {
);
}
}
+
+class BootstrapPageCacheTestCase extends DrupalWebTestCase {
+
+ /**
+ * Implementation of getInfo().
+ */
+ function getInfo() {
+ return array(
+ 'name' => t('Page cache test'),
+ 'description' => t('Enable the page cache, submit a HEAD request and examine headers.'),
+ 'group' => t('Bootstrap')
+ );
+ }
+
+ /**
+ * Enable cache and examine HTTP headers.
+ */
+ function testPageCache() {
+ global $base_url;
+ variable_set('cache', 1);
+ // Retrieve the front page, which has already been cached by $this->curlConnect();
+ $this->drupalHead($base_url);
+ $this->assertText('ETag: ', t('Verify presence of ETag header indicating that page caching is enabled.'));
+ }
+
+}