changed the main parameter of the kernel handle() method to type with 3 different values
This commit is contained in:
parent
bb77e9a3d6
commit
2c165693e7
@ -38,7 +38,7 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Request instance associated with the main request.
|
* Gets the Request instance associated with the master request.
|
||||||
*
|
*
|
||||||
* @return Request A Request instance
|
* @return Request A Request instance
|
||||||
*/
|
*/
|
||||||
@ -48,42 +48,45 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a request to convert it to a response.
|
* Handles a Request to convert it to a Response.
|
||||||
*
|
*
|
||||||
* All exceptions are caught, and a core.exception event is notified
|
* All exceptions are caught, and a core.exception event is notified
|
||||||
* for user management.
|
* for user management.
|
||||||
*
|
*
|
||||||
* @param Request $request A Request instance
|
* @param Request $request A Request instance
|
||||||
* @param Boolean $main Whether this is the main request or not
|
* @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST, HttpKernelInterface::FORWARDED_REQUEST, or HttpKernelInterface::EMBEDDED_REQUEST)
|
||||||
* @param Boolean $raw Whether to catch exceptions or not
|
* @param Boolean $raw Whether to catch exceptions or not
|
||||||
*
|
*
|
||||||
* @return Response $response A Response instance
|
* @return Response A Response instance
|
||||||
*
|
*
|
||||||
* @throws \Exception When Exception couldn't be caught by event processing
|
* @throws \Exception When an Exception occurs during processing
|
||||||
|
* and couldn't be caught by event processing or $raw is true
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request = null, $main = true, $raw = false)
|
public function handle(Request $request = null, $type = HttpKernelInterface::MASTER_REQUEST, $raw = false)
|
||||||
{
|
{
|
||||||
$main = (Boolean) $main;
|
if (HttpKernelInterface::EMBEDDED_REQUEST === $type) {
|
||||||
|
return $this->handleEmbedded($request, $raw);
|
||||||
|
}
|
||||||
|
|
||||||
if (null === $request) {
|
if (null === $request) {
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true === $main) {
|
if (HttpKernelInterface::MASTER_REQUEST === $type) {
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return $this->handleRaw($request, $main);
|
return $this->handleRaw($request, $type);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (true === $raw) {
|
if (true === $raw) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// exception
|
// exception
|
||||||
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.exception', array('main_request' => $main, 'request' => $request, 'exception' => $e)));
|
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.exception', array('request_type' => $type, 'request' => $request, 'exception' => $e)));
|
||||||
if ($event->isProcessed()) {
|
if ($event->isProcessed()) {
|
||||||
return $this->filterResponse($event->getReturnValue(), $request, 'A "core.exception" listener returned a non response object.', $main);
|
return $this->filterResponse($event->getReturnValue(), $request, 'A "core.exception" listener returned a non response object.', $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
@ -95,26 +98,24 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
*
|
*
|
||||||
* Exceptions are not caught.
|
* Exceptions are not caught.
|
||||||
*
|
*
|
||||||
* @param Request $request A Request instance
|
* @param Request $request A Request instance
|
||||||
* @param Boolean $main Whether this is the main request or not
|
* @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST, HttpKernelInterface::FORWARDED_REQUEST, or HttpKernelInterface::EMBEDDED_REQUEST)
|
||||||
*
|
*
|
||||||
* @return Response $response A Response instance
|
* @return Response A Response instance
|
||||||
*
|
*
|
||||||
* @throws \LogicException If one of the listener does not behave as expected
|
* @throws \LogicException If one of the listener does not behave as expected
|
||||||
* @throws NotFoundHttpException When controller cannot be found
|
* @throws NotFoundHttpException When controller cannot be found
|
||||||
*/
|
*/
|
||||||
protected function handleRaw(Request $request, $main = true)
|
protected function handleRaw(Request $request, $type = self::MASTER_REQUEST)
|
||||||
{
|
{
|
||||||
$main = (Boolean) $main;
|
|
||||||
|
|
||||||
// request
|
// request
|
||||||
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.request', array('main_request' => $main, 'request' => $request)));
|
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.request', array('request_type' => $type, 'request' => $request)));
|
||||||
if ($event->isProcessed()) {
|
if ($event->isProcessed()) {
|
||||||
return $this->filterResponse($event->getReturnValue(), $request, 'A "core.request" listener returned a non response object.', $main);
|
return $this->filterResponse($event->getReturnValue(), $request, 'A "core.request" listener returned a non response object.', $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load controller
|
// load controller
|
||||||
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.load_controller', array('main_request' => $main, 'request' => $request)));
|
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.load_controller', array('request_type' => $type, 'request' => $request)));
|
||||||
if (!$event->isProcessed()) {
|
if (!$event->isProcessed()) {
|
||||||
throw new NotFoundHttpException('Unable to find the controller.');
|
throw new NotFoundHttpException('Unable to find the controller.');
|
||||||
}
|
}
|
||||||
@ -127,10 +128,10 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// controller
|
// controller
|
||||||
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.controller', array('main_request' => $main, 'request' => $request, 'controller' => &$controller, 'arguments' => &$arguments)));
|
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.controller', array('request_type' => $type, 'request' => $request, 'controller' => &$controller, 'arguments' => &$arguments)));
|
||||||
if ($event->isProcessed()) {
|
if ($event->isProcessed()) {
|
||||||
try {
|
try {
|
||||||
return $this->filterResponse($event->getReturnValue(), $request, 'A "core.controller" listener returned a non response object.', $main);
|
return $this->filterResponse($event->getReturnValue(), $request, 'A "core.controller" listener returned a non response object.', $type);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$retval = $event->getReturnValue();
|
$retval = $event->getReturnValue();
|
||||||
}
|
}
|
||||||
@ -140,28 +141,60 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// view
|
// view
|
||||||
$event = $this->dispatcher->filter(new Event($this, 'core.view', array('main_request' => $main, 'request' => $request)), $retval);
|
$event = $this->dispatcher->filter(new Event($this, 'core.view', array('request_type' => $type, 'request' => $request)), $retval);
|
||||||
|
|
||||||
return $this->filterResponse($event->getReturnValue(), $request, sprintf('The controller must return a response (instead of %s).', is_object($event->getReturnValue()) ? 'an object of class '.get_class($event->getReturnValue()) : str_replace("\n", '', var_export($event->getReturnValue(), true))), $main);
|
return $this->filterResponse($event->getReturnValue(), $request, sprintf('The controller must return a response (instead of %s).', is_object($event->getReturnValue()) ? 'an object of class '.get_class($event->getReturnValue()) : str_replace("\n", '', var_export($event->getReturnValue(), true))), $type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a request that need to be embedded.
|
||||||
|
*
|
||||||
|
* @param Request $request A Request instance
|
||||||
|
* @param Boolean $raw Whether to catch exceptions or not
|
||||||
|
*
|
||||||
|
* @return string|false The Response content or false if there is a problem
|
||||||
|
*
|
||||||
|
* @throws \RuntimeException When an Exception occurs during processing
|
||||||
|
* and couldn't be caught by event processing or $raw is true
|
||||||
|
*/
|
||||||
|
protected function handleEmbedded(Request $request, $raw = false)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$response = $this->handleRaw($request, HttpKernelInterface::EMBEDDED_REQUEST);
|
||||||
|
|
||||||
|
if (200 != $response->getStatusCode()) {
|
||||||
|
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $request->getUri(), $response->getStatusCode()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->getContent();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
if (true === $raw)
|
||||||
|
{
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters a response object.
|
* Filters a response object.
|
||||||
*
|
*
|
||||||
* @param Object $response A Response instance
|
* @param Response $response A Response instance
|
||||||
* @param string $message A error message in case the response is not a Response object
|
* @param string $message A error message in case the response is not a Response object
|
||||||
|
* @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST, HttpKernelInterface::FORWARDED_REQUEST, or HttpKernelInterface::EMBEDDED_REQUEST)
|
||||||
*
|
*
|
||||||
* @param Object $response The filtered Response instance
|
* @return Response The filtered Response instance
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException if the response object does not implement the send() method
|
* @throws \RuntimeException if the passed object is not a Response instance
|
||||||
*/
|
*/
|
||||||
protected function filterResponse($response, $request, $message, $main)
|
protected function filterResponse($response, $request, $message, $type)
|
||||||
{
|
{
|
||||||
if (!$response instanceof Response) {
|
if (!$response instanceof Response) {
|
||||||
throw new \RuntimeException($message);
|
throw new \RuntimeException($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = $this->dispatcher->filter(new Event($this, 'core.response', array('main_request' => $main, 'request' => $request)), $response);
|
$event = $this->dispatcher->filter(new Event($this, 'core.response', array('request_type' => $type, 'request' => $request)), $response);
|
||||||
$response = $event->getReturnValue();
|
$response = $event->getReturnValue();
|
||||||
|
|
||||||
if (!$response instanceof Response) {
|
if (!$response instanceof Response) {
|
||||||
|
@ -20,19 +20,23 @@ namespace Symfony\Components\HttpKernel;
|
|||||||
*/
|
*/
|
||||||
interface HttpKernelInterface
|
interface HttpKernelInterface
|
||||||
{
|
{
|
||||||
|
const MASTER_REQUEST = 1;
|
||||||
|
const FORWARDED_REQUEST = 2;
|
||||||
|
const EMBEDDED_REQUEST = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a request to convert it to a response.
|
* Handles a request to convert it to a response.
|
||||||
*
|
*
|
||||||
* @param Request $request A Request instance
|
* @param Request $request A Request instance
|
||||||
* @param Boolean $main Whether this is the main request or not
|
* @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST, HttpKernelInterface::FORWARDED_REQUEST, or HttpKernelInterface::EMBEDDED_REQUEST)
|
||||||
* @param Boolean $raw Whether to catch exceptions or not
|
* @param Boolean $raw Whether to catch exceptions or not
|
||||||
*
|
*
|
||||||
* @return Response $response A Response instance
|
* @return Response $response A Response instance
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request = null, $main = true, $raw = false);
|
public function handle(Request $request = null, $type = self::MASTER_REQUEST, $raw = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Request instance associated with the main request.
|
* Gets the Request instance associated with the master request.
|
||||||
*
|
*
|
||||||
* @return Request A Request instance
|
* @return Request A Request instance
|
||||||
*/
|
*/
|
||||||
|
@ -151,7 +151,7 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Request instance associated with the main request.
|
* Gets the Request instance associated with the master request.
|
||||||
*
|
*
|
||||||
* @return Request A Request instance
|
* @return Request A Request instance
|
||||||
*/
|
*/
|
||||||
@ -164,12 +164,12 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||||||
* Handles a request to convert it to a response by calling the HttpKernel service.
|
* Handles a request to convert it to a response by calling the HttpKernel service.
|
||||||
*
|
*
|
||||||
* @param Request $request A Request instance
|
* @param Request $request A Request instance
|
||||||
* @param Boolean $main Whether this is the main request or not
|
* @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST, HttpKernelInterface::FORWARDED_REQUEST, or HttpKernelInterface::EMBEDDED_REQUEST)
|
||||||
* @param Boolean $raw Whether to catch exceptions or not
|
* @param Boolean $raw Whether to catch exceptions or not
|
||||||
*
|
*
|
||||||
* @return Response $response A Response instance
|
* @return Response $response A Response instance
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request = null, $main = true, $raw = false)
|
public function handle(Request $request = null, $type = HttpKernelInterface::MASTER_REQUEST, $raw = false)
|
||||||
{
|
{
|
||||||
if (false === $this->booted) {
|
if (false === $this->booted) {
|
||||||
$this->boot();
|
$this->boot();
|
||||||
@ -179,13 +179,13 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||||||
$request = $this->container->getRequestService();
|
$request = $this->container->getRequestService();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true === $main) {
|
if (HttpKernelInterface::MASTER_REQUEST === $type) {
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->container->setService('request', $request);
|
$this->container->setService('request', $request);
|
||||||
|
|
||||||
$response = $this->container->getHttpKernelService()->handle($request, $main, $raw);
|
$response = $this->container->getHttpKernelService()->handle($request, $type, $raw);
|
||||||
|
|
||||||
$this->container->setService('request', $this->request);
|
$this->container->setService('request', $this->request);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace Symfony\Framework\ProfilerBundle\DataCollector;
|
|||||||
use Symfony\Components\DependencyInjection\ContainerInterface;
|
use Symfony\Components\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Components\EventDispatcher\Event;
|
use Symfony\Components\EventDispatcher\Event;
|
||||||
use Symfony\Components\HttpKernel\Response;
|
use Symfony\Components\HttpKernel\Response;
|
||||||
|
use Symfony\Components\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Framework\ProfilerBundle\ProfilerStorage;
|
use Symfony\Framework\ProfilerBundle\ProfilerStorage;
|
||||||
use Symfony\Foundation\LoggerInterface;
|
use Symfony\Foundation\LoggerInterface;
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ class DataCollectorManager
|
|||||||
|
|
||||||
public function handle(Event $event, Response $response)
|
public function handle(Event $event, Response $response)
|
||||||
{
|
{
|
||||||
if (!$event->getParameter('main_request')) {
|
if (HttpKernelInterface::MASTER_REQUEST !== $event->getParameter('request_type')) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace Symfony\Framework\ProfilerBundle\Listener;
|
|||||||
use Symfony\Components\DependencyInjection\ContainerInterface;
|
use Symfony\Components\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Components\EventDispatcher\Event;
|
use Symfony\Components\EventDispatcher\Event;
|
||||||
use Symfony\Components\HttpKernel\Response;
|
use Symfony\Components\HttpKernel\Response;
|
||||||
|
use Symfony\Components\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager;
|
use Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -41,7 +42,7 @@ class WebDebugToolbar
|
|||||||
|
|
||||||
public function handle(Event $event, Response $response)
|
public function handle(Event $event, Response $response)
|
||||||
{
|
{
|
||||||
if (!$event->getParameter('main_request')) {
|
if (HttpKernelInterface::MASTER_REQUEST !== $event->getParameter('request_type')) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace Symfony\Framework\WebBundle;
|
|||||||
use Symfony\Components\DependencyInjection\ContainerInterface;
|
use Symfony\Components\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Components\HttpKernel\Request;
|
use Symfony\Components\HttpKernel\Request;
|
||||||
use Symfony\Components\HttpKernel\Response;
|
use Symfony\Components\HttpKernel\Response;
|
||||||
|
use Symfony\Components\HttpKernel\HttpKernelInterface;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the Symfony framework.
|
* This file is part of the Symfony framework.
|
||||||
@ -96,7 +97,7 @@ class Controller
|
|||||||
$path['_controller'] = $controller;
|
$path['_controller'] = $controller;
|
||||||
$subRequest = $this->getRequest()->duplicate($query, null, $path);
|
$subRequest = $this->getRequest()->duplicate($query, null, $path);
|
||||||
|
|
||||||
return $this->container->getKernelService()->handle($subRequest, false, true);
|
return $this->container->getKernelService()->handle($subRequest, HttpKernelInterface::FORWARDED_REQUEST, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +62,7 @@ class ActionsHelper extends Helper
|
|||||||
$path['_controller'] = $controller;
|
$path['_controller'] = $controller;
|
||||||
$subRequest = $this->container->getRequestService()->duplicate($query, null, Escaper::unescape($path));
|
$subRequest = $this->container->getRequestService()->duplicate($query, null, Escaper::unescape($path));
|
||||||
|
|
||||||
return $this->container->getKernelService()->handle($subRequest, false, true);
|
return $this->container->getKernelService()->handle($subRequest, HttpKernelInterface::EMBEDDED_REQUEST, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@ namespace Symfony\Framework\WebBundle\Listener;
|
|||||||
use Symfony\Components\DependencyInjection\ContainerInterface;
|
use Symfony\Components\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Components\EventDispatcher\Event;
|
use Symfony\Components\EventDispatcher\Event;
|
||||||
use Symfony\Foundation\LoggerInterface;
|
use Symfony\Foundation\LoggerInterface;
|
||||||
|
use Symfony\Components\HttpKernel\HttpKernelInterface;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the Symfony framework.
|
* This file is part of the Symfony framework.
|
||||||
@ -43,7 +44,7 @@ class ExceptionHandler
|
|||||||
|
|
||||||
public function handle(Event $event)
|
public function handle(Event $event)
|
||||||
{
|
{
|
||||||
if (!$event->getParameter('main_request')) {
|
if (HttpKernelInterface::MASTER_REQUEST !== $event->getParameter('request_type')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ class ExceptionHandler
|
|||||||
$request = $event->getParameter('request')->duplicate(null, null, $parameters);
|
$request = $event->getParameter('request')->duplicate(null, null, $parameters);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $event->getSubject()->handle($request, false, true);
|
$response = $event->getSubject()->handle($request, HttpKernelInterface::FORWARDED_REQUEST, true);
|
||||||
|
|
||||||
error_log(sprintf('%s: %s', get_class($exception), $exception->getMessage()));
|
error_log(sprintf('%s: %s', get_class($exception), $exception->getMessage()));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -6,6 +6,7 @@ use Symfony\Foundation\LoggerInterface;
|
|||||||
use Symfony\Components\DependencyInjection\ContainerInterface;
|
use Symfony\Components\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Components\EventDispatcher\Event;
|
use Symfony\Components\EventDispatcher\Event;
|
||||||
use Symfony\Components\Routing\RouterInterface;
|
use Symfony\Components\Routing\RouterInterface;
|
||||||
|
use Symfony\Components\HttpKernel\HttpKernelInterface;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the Symfony framework.
|
* This file is part of the Symfony framework.
|
||||||
@ -45,20 +46,18 @@ class RequestParser
|
|||||||
{
|
{
|
||||||
$request = $event->getParameter('request');
|
$request = $event->getParameter('request');
|
||||||
|
|
||||||
if (!$event->getParameter('main_request')) {
|
if (HttpKernelInterface::MASTER_REQUEST === $event->getParameter('request_type')) {
|
||||||
return;
|
// set the context even if the parsing does not need to be done
|
||||||
|
// to have correct link generation
|
||||||
|
$this->router->setContext(array(
|
||||||
|
'base_url' => $request->getBaseUrl(),
|
||||||
|
'method' => $request->getMethod(),
|
||||||
|
'host' => $request->getHost(),
|
||||||
|
'is_secure' => $request->isSecure(),
|
||||||
|
));
|
||||||
|
$this->container->setParameter('request.base_path', $request->getBasePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the context even if the parsing does not need to be done
|
|
||||||
// to have correct link generation
|
|
||||||
$this->router->setContext(array(
|
|
||||||
'base_url' => $request->getBaseUrl(),
|
|
||||||
'method' => $request->getMethod(),
|
|
||||||
'host' => $request->getHost(),
|
|
||||||
'is_secure' => $request->isSecure(),
|
|
||||||
));
|
|
||||||
$this->container->setParameter('request.base_path', $request->getBasePath());
|
|
||||||
|
|
||||||
if ($request->path->has('_controller')) {
|
if ($request->path->has('_controller')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use Symfony\Components\EventDispatcher\EventDispatcher;
|
|||||||
use Symfony\Components\EventDispatcher\Event;
|
use Symfony\Components\EventDispatcher\Event;
|
||||||
use Symfony\Components\HttpKernel\Request;
|
use Symfony\Components\HttpKernel\Request;
|
||||||
use Symfony\Components\HttpKernel\Response;
|
use Symfony\Components\HttpKernel\Response;
|
||||||
|
use Symfony\Components\HttpKernel\HttpKernelInterface;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the Symfony framework.
|
* This file is part of the Symfony framework.
|
||||||
@ -39,7 +40,7 @@ class ResponseFilter
|
|||||||
|
|
||||||
public function filter(Event $event, Response $response)
|
public function filter(Event $event, Response $response)
|
||||||
{
|
{
|
||||||
if (!$event->getParameter('main_request') || $response->headers->has('Content-Type')) {
|
if (HttpKernelInterface::MASTER_REQUEST !== $event->getParameter('request_type') || $response->headers->has('Content-Type')) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user