core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php | 2 +- .../Functional/EntityResource/Comment/CommentResourceTestBase.php | 5 +++-- .../tests/src/Functional/EntityResource/EntityResourceTestBase.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php index 3ae147d..99451df 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php @@ -119,7 +119,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) { $content = $this->t('The website encountered an unexpected error. Please try again later.'); $content .= $message ? '

' . $message : ''; - $response = new Response($content, 500); + $response = new Response($content, 500, ['Content-Type' => 'text/plain']); if ($exception instanceof HttpExceptionInterface) { $response->setStatusCode($exception->getStatusCode()); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php index f6645f4..2b7c5a3 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php @@ -303,8 +303,9 @@ public function testPostDxWithoutCriticalBaseFields() { // DX: 422 when missing 'entity_type' field. $request_options[RequestOptions::BODY] = $this->serializer->encode(array_diff_key($this->getNormalizedPostEntity(), ['field_name' => TRUE]), static::$format); $response = $this->request('POST', $url, $request_options); - // @todo Uncomment, remove next line in https://www.drupal.org/node/2820364. - $this->assertResourceErrorResponse(500, FALSE, $response); + // @todo Uncomment, remove next 2 lines in https://www.drupal.org/node/2820364. + $this->assertSame(500, $response->getStatusCode()); + $this->assertSame(['text/plain; charset=UTF-8'], $response->getHeader('Content-Type')); //$this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nfield_name: This value should not be null.\n", $response); } diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index 0c10678..9f326bc 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -508,7 +508,7 @@ public function testGet() { // DX: 406 when requesting unsupported format but specifying Accept header: - // should still result in a response with the same Content-Type. + // should result in a text/plain response. $response = $this->request('GET', $url, $request_options); $this->assert406Response($response); $this->assertSame(['text/plain; charset=UTF-8'], $response->getHeader('Content-Type'));