core/modules/rest/src/RequestHandler.php | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index 0e9f41b..3a5e012 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -89,29 +89,19 @@ public function handle(RouteMatchInterface $route_match, Request $request) { if (!empty($received)) { $format = $request->getContentType(); - // Only allow serialization formats that are explicitly configured. If no - // formats are configured allow all and hope that the serializer knows the - // format. If the serializer cannot handle it an exception will be thrown - // that bubbles up to the client. - $request_method = $request->getMethod(); - if (in_array($format, $resource_config->getFormats($request_method))) { - $definition = $resource->getPluginDefinition(); - try { - if (!empty($definition['serialization_class'])) { - $unserialized = $serializer->deserialize($received, $definition['serialization_class'], $format, array('request_method' => $method)); - } - // If the plugin does not specify a serialization class just decode - // the received data. - else { - $unserialized = $serializer->decode($received, $format, array('request_method' => $method)); - } + $definition = $resource->getPluginDefinition(); + try { + if (!empty($definition['serialization_class'])) { + $unserialized = $serializer->deserialize($received, $definition['serialization_class'], $format, array('request_method' => $method)); } - catch (UnexpectedValueException $e) { - throw new BadRequestHttpException($e->getMessage()); + // If the plugin does not specify a serialization class just decode + // the received data. + else { + $unserialized = $serializer->decode($received, $format, array('request_method' => $method)); } } - else { - throw new UnsupportedMediaTypeHttpException(); + catch (UnexpectedValueException $e) { + throw new BadRequestHttpException($e->getMessage()); } }