Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/http-kernel/Client.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
line wrap: on
line diff
--- a/vendor/symfony/http-kernel/Client.php Mon Apr 23 09:33:26 2018 +0100 +++ b/vendor/symfony/http-kernel/Client.php Mon Apr 23 09:46:53 2018 +0100 @@ -14,7 +14,6 @@ use Symfony\Component\BrowserKit\Client as BaseClient; use Symfony\Component\BrowserKit\Request as DomRequest; use Symfony\Component\BrowserKit\Response as DomResponse; -use Symfony\Component\BrowserKit\Cookie as DomCookie; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -26,16 +25,15 @@ * * @author Fabien Potencier <fabien@symfony.com> * - * @method Request|null getRequest() A Request instance + * @method Request|null getRequest() A Request instance * @method Response|null getResponse() A Response instance */ class Client extends BaseClient { protected $kernel; + private $catchExceptions = true; /** - * Constructor. - * * @param HttpKernelInterface $kernel An HttpKernel instance * @param array $server The server parameters (equivalent of $_SERVER) * @param History $history A History instance to store the browser history @@ -51,15 +49,23 @@ } /** + * Sets whether to catch exceptions when the kernel is handling a request. + * + * @param bool $catchExceptions Whether to catch exceptions + */ + public function catchExceptions($catchExceptions) + { + $this->catchExceptions = $catchExceptions; + } + + /** * Makes a request. * - * @param Request $request A Request instance - * * @return Response A Response instance */ protected function doRequest($request) { - $response = $this->kernel->handle($request); + $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $this->catchExceptions); if ($this->kernel instanceof TerminableInterface) { $this->kernel->terminate($request, $response); @@ -71,30 +77,35 @@ /** * Returns the script to execute when the request must be insulated. * - * @param Request $request A Request instance - * * @return string */ protected function getScript($request) { $kernel = str_replace("'", "\\'", serialize($this->kernel)); $request = str_replace("'", "\\'", serialize($request)); + $errorReporting = error_reporting(); - $r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader'); - $requirePath = str_replace("'", "\\'", $r->getFileName()); - $symfonyPath = str_replace("'", "\\'", dirname(dirname(dirname(__DIR__)))); - $errorReporting = error_reporting(); + $requires = ''; + foreach (get_declared_classes() as $class) { + if (0 === strpos($class, 'ComposerAutoloaderInit')) { + $r = new \ReflectionClass($class); + $file = dirname(dirname($r->getFileName())).'/autoload.php'; + if (file_exists($file)) { + $requires .= "require_once '".str_replace("'", "\\'", $file)."';\n"; + } + } + } + + if (!$requires) { + throw new \RuntimeException('Composer autoloader not found.'); + } $code = <<<EOF <?php error_reporting($errorReporting); -require_once '$requirePath'; - -\$loader = new Symfony\Component\ClassLoader\ClassLoader(); -\$loader->addPrefix('Symfony', '$symfonyPath'); -\$loader->register(); +$requires \$kernel = unserialize('$kernel'); \$request = unserialize('$request'); @@ -119,8 +130,6 @@ /** * Converts the BrowserKit request to a HttpKernel request. * - * @param DomRequest $request A DomRequest instance - * * @return Request A Request instance */ protected function filterRequest(DomRequest $request) @@ -145,8 +154,6 @@ * * @see UploadedFile * - * @param array $files An array of files - * * @return array An array with all uploaded files marked as already moved */ protected function filterFiles(array $files) @@ -184,26 +191,15 @@ /** * Converts the HttpKernel response to a BrowserKit response. * - * @param Response $response A Response instance - * * @return DomResponse A DomResponse instance */ protected function filterResponse($response) { - $headers = $response->headers->all(); - if ($response->headers->getCookies()) { - $cookies = array(); - foreach ($response->headers->getCookies() as $cookie) { - $cookies[] = new DomCookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - $headers['Set-Cookie'] = $cookies; - } - // this is needed to support StreamedResponse ob_start(); $response->sendContent(); $content = ob_get_clean(); - return new DomResponse($content, $response->getStatusCode(), $headers); + return new DomResponse($content, $response->getStatusCode(), $response->headers->all()); } }