protected function handleRequest(\React\Http\Request $request, HttpResponse $response)
{
if ($bridge = $this->getBridge()) {
if ($this->isServingStatic()) {
if (true === $this->serveStatic($request, $response)) {
return;
}
}
$bridge->onRequest($request, $response);
if ($this->isDebug()) {
$this->sendCurrentFiles();
}
} else {
$response->writeHead('404');
$response->end('No Bridge Defined.');
}
if (headers_sent()) {
//when a script sent headers the cgi process needs to die because the second request
//trying to send headers again will fail (headers already sent fatal). Its best to not even
//try to send headers because this break the whole approach of php-pm using php-cgi.
error_log('Headers have been sent, but not redirected to client. Force restart of a worker. ' . 'Make sure your application does not send headers on its own.');
$this->shutdown();
}
}