Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
5dd37769
Commit
5dd37769
authored
Jul 07, 2014
by
alexpott
Browse files
Issue
#1918820
by neclimdul, typhonius, pwolanin | 0x534B41: Fixed HTTP header date formats.
parent
ddaba8bf
Changes
7
Hide whitespace changes
Inline
Side-by-side
core/includes/bootstrap.inc
View file @
5dd37769
...
...
@@ -4,6 +4,7 @@
* Functions that need to be loaded on every Drupal request.
*/
use
Drupal\Component\Datetime\DateTimePlus
;
use
Drupal\Component\Utility\Crypt
;
use
Drupal\Component\Utility\Environment
;
use
Drupal\Component\Utility\String
;
...
...
@@ -572,7 +573,7 @@ function drupal_page_header() {
$default_headers
=
array
(
'Expires'
=>
'Sun, 19 Nov 1978 05:00:00 GMT'
,
'Last-Modified'
=>
gmdate
(
D
ATE_
RFC
11
23
,
REQUEST_TIME
),
'Last-Modified'
=>
gmdate
(
D
ateTimePlus
::
RFC
7
23
1
,
REQUEST_TIME
),
'Cache-Control'
=>
'no-cache, must-revalidate, post-check=0, pre-check=0'
,
'ETag'
=>
'"'
.
REQUEST_TIME
.
'"'
,
);
...
...
core/lib/Drupal/Component/Datetime/DateTimePlus.php
View file @
5dd37769
...
...
@@ -30,6 +30,15 @@ class DateTimePlus extends \DateTime {
const
FORMAT
=
'Y-m-d H:i:s'
;
/**
* A RFC7231 Compliant date.
*
* http://tools.ietf.org/html/rfc7231#section-7.1.1.1
*
* Example: Sun, 06 Nov 1994 08:49:37 GMT
*/
const
RFC7231
=
'D, d M Y H:i:s \G\M\T'
;
/**
* An array of possible date parts.
*/
...
...
core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
View file @
5dd37769
...
...
@@ -7,6 +7,7 @@
namespace
Drupal\Core\EventSubscriber
;
use
Drupal\Component\Datetime\DateTimePlus
;
use
Drupal\Core\Config\Config
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Language\LanguageManager
;
...
...
@@ -179,7 +180,7 @@ protected function setResponseCacheable(Response $response, Request $request) {
// Last-Modified and an ETag header on the response.
if
(
!
$response
->
headers
->
has
(
'Last-Modified'
))
{
$timestamp
=
REQUEST_TIME
;
$response
->
setLastModified
(
new
\
DateTime
(
gmdate
(
D
ATE_
RFC
11
23
,
REQUEST_TIME
)));
$response
->
setLastModified
(
new
\
DateTime
(
gmdate
(
D
ateTimePlus
::
RFC
7
23
1
,
REQUEST_TIME
)));
}
else
{
$timestamp
=
$response
->
getLastModified
()
->
getTimestamp
();
...
...
core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
View file @
5dd37769
...
...
@@ -9,6 +9,7 @@
use
Drupal\aggregator\Plugin\FetcherInterface
;
use
Drupal\aggregator\FeedInterface
;
use
Drupal\Component\Datetime\DateTimePlus
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
GuzzleHttp\ClientInterface
;
use
GuzzleHttp\Exception\RequestException
;
...
...
@@ -65,7 +66,7 @@ public function fetch(FeedInterface $feed) {
$request
->
addHeader
(
'If-None-Match'
,
$feed
->
getEtag
());
}
if
(
$feed
->
getLastModified
())
{
$request
->
addHeader
(
'If-Modified-Since'
,
gmdate
(
D
ATE_
RFC
11
23
,
$feed
->
getLastModified
()));
$request
->
addHeader
(
'If-Modified-Since'
,
gmdate
(
D
ateTimePlus
::
RFC
7
23
1
,
$feed
->
getLastModified
()));
}
try
{
...
...
core/modules/aggregator/tests/modules/aggregator_test/src/Controller/AggregatorTestRssController.php
View file @
5dd37769
...
...
@@ -6,6 +6,7 @@
namespace
Drupal\aggregator_test\Controller
;
use
Drupal\Component\Datetime\DateTimePlus
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Component\Utility\Crypt
;
use
Symfony\Component\HttpFoundation\Response
;
...
...
@@ -41,7 +42,7 @@ public function testFeed($use_last_modified, $use_etag, Request $request) {
// Send appropriate response. We respond with a 304 not modified on either
// etag or on last modified.
if
(
$use_last_modified
)
{
$response
->
headers
->
set
(
'Last-Modified'
,
gmdate
(
D
ATE_
RFC
11
23
,
$last_modified
));
$response
->
headers
->
set
(
'Last-Modified'
,
gmdate
(
D
ateTimePlus
::
RFC
7
23
1
,
$last_modified
));
}
if
(
$use_etag
)
{
$response
->
headers
->
set
(
'ETag'
,
$etag
);
...
...
core/modules/system/src/Tests/Bootstrap/PageCacheTest.php
View file @
5dd37769
...
...
@@ -7,6 +7,7 @@
namespace
Drupal\system\Tests\Bootstrap
;
use
Drupal\Component\Datetime\DateTimePlus
;
use
Symfony\Component\Routing\RequestContext
;
use
Drupal\simpletest\WebTestBase
;
use
Drupal\Core\Cache\Cache
;
...
...
@@ -141,7 +142,7 @@ function testConditionalRequests() {
$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
(
D
ATE_
RFC
11
23
,
strtotime
(
$last_modified
)
+
1
),
'If-None-Match: '
.
$etag
));
$this
->
drupalGet
(
''
,
array
(),
array
(
'If-Modified-Since: '
.
gmdate
(
D
ateTimePlus
::
RFC
7
23
1
,
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.'
);
...
...
core/modules/toolbar/toolbar.module
View file @
5dd37769
...
...
@@ -5,13 +5,13 @@
* Administration toolbar for quick access to top level administration items.
*/
use
Drupal\Component\Utility\String
;
use
Drupal\Core\Cache\Cache
;
use
Drupal\Core\Render\Element
;
use
Drupal\Core\Routing\RouteMatchInterface
;
use
Drupal\Core\Template\Attribute
;
use
Drupal\Component\Datetime\DateTimePlus
;
use
Drupal\Component\Utility\Crypt
;
use
Symfony
\Component\
HttpFoundation\Response
;
use
Drupal
\Component\
Utility\String
;
use
Drupal\menu_link
\
MenuLinkInterface
;
use
Drupal\user\RoleInterface
;
use
Drupal\user\UserInterface
;
...
...
@@ -139,7 +139,7 @@ function _toolbar_initialize_page_cache() {
// accesses the callback URL again (e.g., after clearing the browser cache or
// when force-reloading a Drupal page).
$max_age
=
3600
*
24
*
365
;
drupal_add_http_header
(
'Expires'
,
gmdate
(
D
ATE_
RFC
11
23
,
REQUEST_TIME
+
$max_age
));
drupal_add_http_header
(
'Expires'
,
gmdate
(
D
ateTimePlus
::
RFC
7
23
1
,
REQUEST_TIME
+
$max_age
));
drupal_add_http_header
(
'Cache-Control'
,
'private, max-age='
.
$max_age
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment