diff --git a/core/modules/media/src/Controller/OEmbedIframeController.php b/core/modules/media/src/Controller/OEmbedIframeController.php index dc98339..a32533f 100644 --- a/core/modules/media/src/Controller/OEmbedIframeController.php +++ b/core/modules/media/src/Controller/OEmbedIframeController.php @@ -134,7 +134,9 @@ public function render(Request $request) { // Return a response instead of a render array so that the frame content // will not have all the blocks and page elements normally rendered by // Drupal. - $response = new HtmlResponse(); + $response = new HtmlResponse('', HtmlResponse::HTTP_OK, [ + 'Content-Type' => 'text/html; charset=UTF-8', + ]); $response->addCacheableDependency(Url::createFromRequest($request)); try { diff --git a/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php b/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php index 0bc8c89..cc96340 100644 --- a/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php +++ b/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php @@ -94,15 +94,16 @@ public function testResourcePassedToPreprocess() { 'url' => '', 'hash' => $hash, ]); - $response = $this->container->get('html_response.attachments_processor') - ->processAttachments(OEmbedIframeController::create($this->container) - ->render($request)); + $response = OEmbedIframeController::create($this->container) + ->render($request); + $content = $response->getContent(); assert($response instanceof HtmlResponse); $content = $response->getContent(); // This query parameter is added by // media_test_oembed_preprocess_media_oembed_iframe() for YouTube videos. $this->assertStringContainsString('&pasta=rigatoni', $content); + $this->assertStringContainsString('text/html', $response->headers->get('Content-Type')); $this->assertStringContainsString('test.css', $content); $this->assertContains('yo_there', $response->getCacheableMetadata()->getCacheTags()); }