Skip to content

Commit df8de73

Browse files
Issue #1918820 by neclimdul, typhonius, girishmuraly, pwolanin | 0x534B41: Fixed HTTP header date formats to follow RFC 7231 rather than RFC 1123.
1 parent 9559160 commit df8de73

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Drupal 7.33, xxxx-xx-xx (development version)
33
-----------------------
4+
- Changed the date format used in various HTTP headers output by Drupal core
5+
from RFC 1123 format to RFC 7231 format.
46
- Added a "block_cache_bypass_node_grants" variable to allow sites which have
57
node access modules enabled to use the block cache if desired (API addition).
68
- Made image derivative generation HTTP requests return a 404 error (rather

includes/bootstrap.inc

+11-2
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ define('REGISTRY_WRITE_LOOKUP_CACHE', 2);
248248
*/
249249
define('DRUPAL_PHP_FUNCTION_PATTERN', '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*');
250250

251+
/**
252+
* A RFC7231 Compliant date.
253+
*
254+
* http://tools.ietf.org/html/rfc7231#section-7.1.1.1
255+
*
256+
* Example: Sun, 06 Nov 1994 08:49:37 GMT
257+
*/
258+
define('DATE_RFC7231', 'D, d M Y H:i:s \G\M\T');
259+
251260
/**
252261
* Provides a caching wrapper to be used in place of large array structures.
253262
*
@@ -1266,7 +1275,7 @@ function drupal_page_header() {
12661275

12671276
$default_headers = array(
12681277
'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
1269-
'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
1278+
'Last-Modified' => gmdate(DATE_RFC7231, REQUEST_TIME),
12701279
'Cache-Control' => 'no-cache, must-revalidate, post-check=0, pre-check=0',
12711280
'ETag' => '"' . REQUEST_TIME . '"',
12721281
);
@@ -1336,7 +1345,7 @@ function drupal_serve_page_from_cache(stdClass $cache) {
13361345
drupal_add_http_header($name, $value);
13371346
}
13381347

1339-
$default_headers['Last-Modified'] = gmdate(DATE_RFC1123, $cache->created);
1348+
$default_headers['Last-Modified'] = gmdate(DATE_RFC7231, $cache->created);
13401349

13411350
// HTTP/1.0 proxies does not support the Vary header, so prevent any caching
13421351
// by sending an Expires date in the past. HTTP/1.1 clients ignores the

modules/aggregator/aggregator.fetcher.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function aggregator_aggregator_fetch($feed) {
2727
$headers['If-None-Match'] = $feed->etag;
2828
}
2929
if ($feed->modified) {
30-
$headers['If-Modified-Since'] = gmdate(DATE_RFC1123, $feed->modified);
30+
$headers['If-Modified-Since'] = gmdate(DATE_RFC7231, $feed->modified);
3131
}
3232

3333
// Request feed.

modules/aggregator/tests/aggregator_test.module

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) {
3232
// Send appropriate response. We respond with a 304 not modified on either
3333
// etag or on last modified.
3434
if ($use_last_modified) {
35-
drupal_add_http_header('Last-Modified', gmdate(DATE_RFC1123, $last_modified));
35+
drupal_add_http_header('Last-Modified', gmdate(DATE_RFC7231, $last_modified));
3636
}
3737
if ($use_etag) {
3838
drupal_add_http_header('ETag', $etag);

modules/simpletest/tests/bootstrap.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase {
144144
$this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.');
145145
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
146146

147-
$this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC1123, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag));
147+
$this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC7231, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag));
148148
$this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.');
149149
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
150150

0 commit comments

Comments
 (0)