Commit a858b347 authored by alexpott's avatar alexpott

Issue #1983710 by manarth: Fixed HTTP: Use 406 (Not acceptable) over 415 (Unsupported media type).

parent f630b510
......@@ -59,7 +59,7 @@ public function onView(GetResponseForControllerResultEvent $event) {
$event->setResponse($this->$method($event));
}
else {
$event->setResponse(new Response('Unsupported Media Type', 415));
$event->setResponse(new Response('Not Acceptable', 406));
}
}
elseif ($request->attributes->get('_legacy')) {
......
......@@ -8,7 +8,7 @@
namespace Drupal\Core\Routing;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface;
......@@ -41,7 +41,7 @@ public function filter(RouteCollection $collection, Request $request) {
}
if (!count($filtered_collection)) {
throw new UnsupportedMediaTypeHttpException();
throw new NotAcceptableHttpException();
}
return $filtered_collection;
......
......@@ -60,7 +60,7 @@ public function testRead() {
// Try to read the entity with an unsupported mime format.
$response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, 'application/wrongformat');
$this->assertResponse(415);
$this->assertResponse(406);
// Try to read an entity that does not exist.
$response = $this->httpRequest('entity/' . $entity_type . '/9999', 'GET', NULL, $this->defaultMimeType);
......
......@@ -11,7 +11,7 @@
use Drupal\simpletest\UnitTestBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
/**
* Basic tests for the MimeTypeMatcher class.
......@@ -91,7 +91,7 @@ public function testNoRouteFound() {
$routes = $matcher->filter($routes, $request);
$this->fail(t('No exception was thrown.'));
}
catch (UnsupportedMediaTypeHttpException $e) {
catch (NotAcceptableHttpException $e) {
$this->pass('The correct exception was thrown.');
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment