public function onRequest($request, $response, $illuminate_request = false)
{
// for file system
clearstatcache();
if (config('laravoole.base_config.deal_with_public')) {
if ($this->dealWithPublic($request, $response)) {
return;
}
}
try {
$kernel = $this->kernel;
if (!$illuminate_request) {
$illuminate_request = $this->dealWithRequest($request);
}
$illuminate_response = $kernel->handle($illuminate_request);
// Is gzip enabled and the client accept it?
$accept_gzip = config('laravoole.base_config.gzip') && isset($request->header['Accept-Encoding']) && stripos($request->header['Accept-Encoding'], 'gzip') !== false;
$this->dealWithResponse($response, $illuminate_response, $accept_gzip);
} catch (\Exception $e) {
echo '[ERR] ' . $e->getFile() . '(' . $e->getLine() . '): ' . $e->getMessage() . PHP_EOL;
echo $e->getTraceAsString() . PHP_EOL;
} catch (\Throwable $e) {
echo '[ERR] ' . $e->getFile() . '(' . $e->getLine() . '): ' . $e->getMessage() . PHP_EOL;
echo $e->getTraceAsString() . PHP_EOL;
} finally {
if (isset($illuminate_response)) {
$kernel->terminate($illuminate_request, $illuminate_response);
}
if ($illuminate_request->hasSession()) {
$illuminate_request->getSession()->clear();
}
if ($this->app->isProviderLoaded(\Illuminate\Auth\AuthServiceProvider::class)) {
$this->app->register(\Illuminate\Auth\AuthServiceProvider::class, [], true);
Facade::clearResolvedInstance('auth');
}
return $response;
}
}