summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-04 22:44:01 -0500
committerDavid Rothstein <drothstein@gmail.com>2014-11-04 22:44:01 -0500
commitdf8de735c3b998af03fc34c493661e2f7c4019b0 (patch)
tree7ef325b8c3daf1db9a83dac55f70a4b39a61dd33
parent9559160204f1c4e72e145cf95d61bf61e4bd1fcf (diff)
downloadbrdo-df8de735c3b998af03fc34c493661e2f7c4019b0.tar.gz
brdo-df8de735c3b998af03fc34c493661e2f7c4019b0.tar.bz2
Issue #1918820 by neclimdul, typhonius, girishmuraly, pwolanin | 0x534B41: Fixed HTTP header date formats to follow RFC 7231 rather than RFC 1123.
-rw-r--r--CHANGELOG.txt2
-rw-r--r--includes/bootstrap.inc13
-rw-r--r--modules/aggregator/aggregator.fetcher.inc2
-rw-r--r--modules/aggregator/tests/aggregator_test.module2
-rw-r--r--modules/simpletest/tests/bootstrap.test2
5 files changed, 16 insertions, 5 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 6192f3989..ff0587160 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,8 @@
Drupal 7.33, xxxx-xx-xx (development version)
-----------------------
+- Changed the date format used in various HTTP headers output by Drupal core
+ from RFC 1123 format to RFC 7231 format.
- Added a "block_cache_bypass_node_grants" variable to allow sites which have
node access modules enabled to use the block cache if desired (API addition).
- Made image derivative generation HTTP requests return a 404 error (rather
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 862fede1c..6516db0ff 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -249,6 +249,15 @@ define('REGISTRY_WRITE_LOOKUP_CACHE', 2);
define('DRUPAL_PHP_FUNCTION_PATTERN', '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*');
/**
+ * A RFC7231 Compliant date.
+ *
+ * http://tools.ietf.org/html/rfc7231#section-7.1.1.1
+ *
+ * Example: Sun, 06 Nov 1994 08:49:37 GMT
+ */
+define('DATE_RFC7231', 'D, d M Y H:i:s \G\M\T');
+
+/**
* Provides a caching wrapper to be used in place of large array structures.
*
* This class should be extended by systems that need to cache large amounts
@@ -1266,7 +1275,7 @@ function drupal_page_header() {
$default_headers = array(
'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
- 'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
+ 'Last-Modified' => gmdate(DATE_RFC7231, REQUEST_TIME),
'Cache-Control' => 'no-cache, must-revalidate, post-check=0, pre-check=0',
'ETag' => '"' . REQUEST_TIME . '"',
);
@@ -1336,7 +1345,7 @@ function drupal_serve_page_from_cache(stdClass $cache) {
drupal_add_http_header($name, $value);
}
- $default_headers['Last-Modified'] = gmdate(DATE_RFC1123, $cache->created);
+ $default_headers['Last-Modified'] = gmdate(DATE_RFC7231, $cache->created);
// HTTP/1.0 proxies does not support the Vary header, so prevent any caching
// by sending an Expires date in the past. HTTP/1.1 clients ignores the
diff --git a/modules/aggregator/aggregator.fetcher.inc b/modules/aggregator/aggregator.fetcher.inc
index 0f7287798..ed77bb61d 100644
--- a/modules/aggregator/aggregator.fetcher.inc
+++ b/modules/aggregator/aggregator.fetcher.inc
@@ -27,7 +27,7 @@ function aggregator_aggregator_fetch($feed) {
$headers['If-None-Match'] = $feed->etag;
}
if ($feed->modified) {
- $headers['If-Modified-Since'] = gmdate(DATE_RFC1123, $feed->modified);
+ $headers['If-Modified-Since'] = gmdate(DATE_RFC7231, $feed->modified);
}
// Request feed.
diff --git a/modules/aggregator/tests/aggregator_test.module b/modules/aggregator/tests/aggregator_test.module
index 2d26a5d9a..58d9818df 100644
--- a/modules/aggregator/tests/aggregator_test.module
+++ b/modules/aggregator/tests/aggregator_test.module
@@ -32,7 +32,7 @@ function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) {
// Send appropriate response. We respond with a 304 not modified on either
// etag or on last modified.
if ($use_last_modified) {
- drupal_add_http_header('Last-Modified', gmdate(DATE_RFC1123, $last_modified));
+ drupal_add_http_header('Last-Modified', gmdate(DATE_RFC7231, $last_modified));
}
if ($use_etag) {
drupal_add_http_header('ETag', $etag);
diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test
index 5dcde3258..f723c6301 100644
--- a/modules/simpletest/tests/bootstrap.test
+++ b/modules/simpletest/tests/bootstrap.test
@@ -144,7 +144,7 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase {
$this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
- $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC1123, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag));
+ $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC7231, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag));
$this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');