diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php index 72f94df..f685093 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php @@ -78,7 +78,8 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio $negotiation = $container->get('content_negotiation'); $request = $container->get('request'); - $this->setContentType($negotiation->getContentType($request)); + $request_content_type = $negotiation->getContentType($request); + $this->setContentType($request_content_type == 'html' ? 'xml' : $request_content_type); $this->setMimeType($request->getMimeType($this->contentType)); } diff --git a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php index 5c4f9bd..3879427 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php @@ -126,6 +126,11 @@ public function testSerializerResponses() { $expected = $serializer->serialize($entities, 'hal_json'); $actual_json = $this->drupalGet('test/serialize/entity', array(), array('Accept: application/hal+json')); $this->assertIdentical($actual_json, $expected, 'The expected HAL output was found.'); + + // Test that by default the output will be xml. + $expected = $serializer->serialize($entities, 'xml'); + $actual_xml = $this->drupalGet('test/serialize/entity'); + $this->assertIdentical($actual_xml, $expected, 'By default xml output is returned.'); } /**