/** * {@inheritdoc} */ public function terminate(Request $request, Response $response) { parent::terminate($request, $response); if ($this->app instanceof TerminableInterface) { $this->app->terminate($request, $response); } }
/** * Handle a request using a HttpKernelInterface implementing application. * * @param \React\Http\Request $request * @param \React\Http\Response $response */ public function onRequest(ReactRequest $request, ReactResponse $response) { if (null === $this->application) { return; } $content = ''; $headers = $request->getHeaders(); $contentLength = isset($headers['Content-Length']) ? (int) $headers['Content-Length'] : 0; $request->on('data', function ($data) use($request, $response, &$content, $contentLength) { // read data (may be empty for GET request) $content .= $data; // handle request after receive if (strlen($content) >= $contentLength) { $syRequest = self::mapRequest($request, $content); try { $syResponse = $this->application->handle($syRequest); } catch (\Exception $exception) { $response->writeHead(500); // internal server error $response->end(); return; } self::mapResponse($response, $syResponse); if ($this->application instanceof TerminableInterface) { $this->application->terminate($syRequest, $syResponse); } } }); }
/** * @param Request $request * @param Response $response */ public function terminate(Request $request, Response $response) { $this->newRelic->endOfTransaction(); if ($this->app instanceof TerminableInterface) { $this->app->terminate($request, $response); } }
/** * Handle a request * * @param ReactRequest $request * @param ReactResponse $response */ public function onRequest(ReactRequest $request, ReactResponse $response) { $content = ''; $headers = $request->getHeaders(); $contentLength = isset($headers['Content-Length']) ? (int) $headers['Content-Length'] : 0; $request->on('data', function ($data) use($request, $response, &$content, $contentLength) { // Read data (may be empty for GET request) $content .= $data; // Handle request after receive if (strlen($content) >= $contentLength) { $symfonyRequest = static::mapRequest($request, $content); try { // Execute $symfonyResponse = $this->application->handle($symfonyRequest); } catch (\Throwable $t) { // Executed only in PHP 7, will not match in PHP 5.x $this->fatalError($response, $t); return; } catch (\Exception $e) { // Executed only in PHP 5.x, will not be reached in PHP 7 $this->fatalError($response, $e); return; } static::mapResponse($response, $symfonyResponse); if ($this->application instanceof SymfonyHttpKernel\TerminableInterface) { $this->application->terminate($symfonyRequest, $symfonyResponse); } } }); }
/** * @param Request $request * @param Response $response */ public function terminate(Request $request, Response $response) { $logger = $this->loggerFactory->create('app.request'); $routeName = $request->attributes->get('_route'); $logger->notice(sprintf('Route %s matched', $routeName), array('route' => $routeName, 'response_code' => $response->getStatusCode(), 'response_size' => strlen($response->getContent()))); $this->loggerFactory->flushBuffer(); if ($this->app instanceof TerminableInterface) { $this->app->terminate($request, $response); } }
public function terminate(Request $request, Response $response) { foreach ($this->map as $path => $app) { if ($app instanceof TerminableInterface) { $app->terminate($request, $response); } } if ($this->app instanceof TerminableInterface) { $this->app->terminate($request, $response); } }
function run(HttpKernelInterface $app, Request $request = null) { $request = $request ?: Request::createFromGlobals(); $response = $app->handle($request); $response->send(); if ($app instanceof TerminableInterface) { $app->terminate($request, $response); } }
/** * @param Request $request * @param $type */ private function doRun(Request $request, $type) { if (false === $this->isResolved) { $this->resolvedApp = $this->builder->resolve($this); $this->isResolved = true; } $request = $request ?: Request::createFromGlobals(); $response = $this->resolvedApp->handle($request, $type); $response->send(); if ($this->resolvedApp instanceof TerminableInterface) { $this->resolvedApp->terminate($request, $response); } }
/** * Terminates the request/response cycle * * @param Request $request The request * @param Response $response The response * * @return void */ public function terminate(Request $request, Response $response) { if ($this->kernel instanceof TerminableInterface) { $this->kernel->terminate($request, $response); } }
/** * Terminates a request/response cycle. * * @param SyfmonyRequest $request A Request instance * @param Response $response A Response instance * * @api */ public function terminate(SyfmonyRequest $request, Response $response) { $this->httpKernel->terminate(Request::createFromBase($request), $response); }
/** * Terminates a request/response cycle. * * @param Request $request * @param Response $response */ public function terminate(Request $request, Response $response) { $this->kernel->terminate($request, $response); }
/** * Terminates a request/response cycle. * * @param DomRequest $request A Request instance * @param Response $response A Response instance * * @api */ public function terminate(DomRequest $request, Response $response) { $this->httpKernel->terminate($request, $response); }