Commit df8de735 authored by David_Rothstein's avatar David_Rothstein

Issue #1918820 by neclimdul, typhonius, girishmuraly, pwolanin | 0x534B41:...

Issue #1918820 by neclimdul, typhonius, girishmuraly, pwolanin | 0x534B41: Fixed HTTP header date formats to follow RFC 7231 rather than RFC 1123.
parent 95591602
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
......
......@@ -248,6 +248,15 @@
*/
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.
*
......@@ -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
......
......@@ -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.
......
......@@ -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);
......
......@@ -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.');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment