diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index ee4b890..78b9ecb 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -7,6 +7,7 @@ namespace Drupal\rest; +use Drupal\Core\Cache\CacheableResponse; use Drupal\Core\Render\RenderContext; use Drupal\Core\Routing\RouteMatchInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; @@ -67,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 Response($content, 400, array('Content-Type' => $request->getMimeType($format))); + return new CacheableResponse($content, 400, array('Content-Type' => $request->getMimeType($format))); } } else { @@ -100,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 Response($content, $e->getStatusCode(), $headers); + return new CacheableResponse($content, $e->getStatusCode(), $headers); } // Serialize the outgoing data for the response, if available.