diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 7da48aa..4728c52 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -116,10 +116,10 @@ public function onRespond(FilterResponseEvent $event) { $response->headers->set('X-Frame-Options', 'SAMEORIGIN', FALSE); // If the current response isn't an implementation of the - // CacheableResponseInterface, we're trusting that a Response is either - // explicitly not cacheable or that caching headers are already set from + // CacheableResponseInterface, we assume that a Response is either + // explicitly not cacheable or that caching headers are already set in // another place. - if (!($response instanceof CacheableResponseInterface)) { + if (!$response instanceof CacheableResponseInterface) { if (!$this->isCacheControlCustomized($response)) { $this->setResponseNotCacheable($response, $request); } diff --git a/core/modules/image/src/Controller/ImageStyleDownloadController.php b/core/modules/image/src/Controller/ImageStyleDownloadController.php index d23d483..7b67072 100644 --- a/core/modules/image/src/Controller/ImageStyleDownloadController.php +++ b/core/modules/image/src/Controller/ImageStyleDownloadController.php @@ -126,8 +126,10 @@ public function deliver(Request $request, $scheme, ImageStyleInterface $image_st $response = parent::download($request, $scheme); if ($response instanceof BinaryFileResponse) { + // The expires header is usually set in the finish response subscriber + // but not for images so we're setting it here. $response->headers->add([ - 'Expires' => \DateTime::createFromFormat('j-M-Y H:i:s T', '19-Nov-1978 05:00:00 GMT')->format('D, d M Y H:i:s T'), + 'Expires' => \DateTime::createFromFormat('D, d M Y H:i:s T', 'Sun, 19 Nov 1978 05:00:00 GMT')->format('D, d M Y H:i:s T') ]); } return $response; @@ -181,10 +183,12 @@ public function deliver(Request $request, $scheme, ImageStyleInterface $image_st if ($success) { $image = $this->imageFactory->get($derivative_uri); $uri = $image->getSource(); + // The expires header is usually set in the finish response subscriber + // but not for images so we're setting it here. $headers += array( 'Content-Type' => $image->getMimeType(), 'Content-Length' => $image->getFileSize(), - 'Expires' => \DateTime::createFromFormat('j-M-Y H:i:s T', '19-Nov-1978 05:00:00 GMT')->format('D, d M Y H:i:s T'), + 'Expires' => \DateTime::createFromFormat('D, d M Y H:i:s T', 'Sun, 19 Nov 1978 05:00:00 GMT')->format('D, d M Y H:i:s T'), ); return new BinaryFileResponse($uri, 200, $headers, FALSE); } diff --git a/core/modules/page_cache/src/Tests/PageCacheTest.php b/core/modules/page_cache/src/Tests/PageCacheTest.php index 421ebf1..a2278e7 100644 --- a/core/modules/page_cache/src/Tests/PageCacheTest.php +++ b/core/modules/page_cache/src/Tests/PageCacheTest.php @@ -407,10 +407,10 @@ public function testFormImmutability() { } /** - * Tests cacheability of a CacheableResponse + * Tests cacheability of a CacheableResponse. * - * Tests the difference between having a controller return a normal Response - * object versus returning a Response object that implements the + * Tests the difference between having a controller return a plain Symfony + * Response object versus returning a Response object that implements the * CacheableResponseInterface. */ public function testCacheableResponseResponses() { @@ -439,7 +439,7 @@ public function testCacheableResponseResponses() { $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.'); // Uninstall page cache. This should flush all caches so the next call to a - // previously cache page should be a miss now. + // previously cached page should be a miss now. $this->container->get('module_installer') ->uninstall(['page_cache']); diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index 9cb413e..d3b69b5 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -68,7 +68,7 @@ public function handle(RouteMatchInterface $route_match, Request $request) { catch (UnexpectedValueException $e) { $error['error'] = $e->getMessage(); $content = $serializer->serialize($error, $format); - return new CacheableResponse($content, 400, ['Content-Type' => $request->getMimeType($format)]); + return new Response($content, 400, ['Content-Type' => $request->getMimeType($format)]); } } else { @@ -101,7 +101,7 @@ public function handle(RouteMatchInterface $route_match, Request $request) { // Add the default content type, but only if the headers from the // exception have not specified it already. $headers = $e->getHeaders() + array('Content-Type' => $request->getMimeType($format)); - return new CacheableResponse($content, $e->getStatusCode(), $headers); + return new Response($content, $e->getStatusCode(), $headers); } // Serialize the outgoing data for the response, if available.