Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function terminate(Request $request, Response $response)
 {
     parent::terminate($request, $response);
     if ($this->app instanceof TerminableInterface) {
         $this->app->terminate($request, $response);
     }
 }
Пример #2
0
 /**
  * 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);
             }
         }
     });
 }
Пример #3
0
 /**
  * @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);
     }
 }
Пример #4
0
 /**
  * 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);
             }
         }
     });
 }
Пример #5
0
 /**
  * @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);
     }
 }
Пример #6
0
 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);
     }
 }
Пример #7
0
Файл: run.php Проект: J7mbo/run
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);
    }
}
Пример #8
0
 /**
  * @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);
     }
 }
Пример #10
0
 /**
  * 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);
 }
Пример #11
0
 /**
  * Terminates a request/response cycle.
  *
  * @param Request  $request
  * @param Response $response
  */
 public function terminate(Request $request, Response $response)
 {
     $this->kernel->terminate($request, $response);
 }
Пример #12
0
 /**
  * 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);
 }