public function init()
{
$this->sessId = $this->attrs->sessId;
$this->serverId = $this->attrs->serverId;
$this->path = $this->attrs->path;
// @TODO: revert timeout after request
$this->upstream->setTimeouts($this->appInstance->config->networktimeoutread->value, $this->appInstance->config->networktimeoutwrite->value);
$this->opts = $this->appInstance->getRouteOptions($this->attrs->path);
$this->CORS();
if ($this->isFinished()) {
return;
}
if ($this->opts['cookie_needed'] && !$this instanceof Info) {
if (isset($_COOKIE['JSESSIONID'])) {
$val = $_COOKIE['JSESSIONID'];
if (!is_string($val) || $val === '') {
$val = 'dummy';
}
} else {
$val = 'dummy';
}
$this->setcookie('JSESSIONID', $val, 0, '/');
}
$this->contentType($this->contentType);
if (!$this->cacheable) {
$this->noncache();
$this->header('X-Accel-Buffering: no');
}
if ($this->callbackParamEnabled) {
if (!isset($_GET['c']) || !is_string($_GET['c']) || preg_match('~[^_\\.a-zA-Z0-9]~', $_GET['c'])) {
$this->header('500 Internal Server Error');
$this->out('"callback" parameter required');
$this->finish();
return;
}
}
if (($f = $this->appInstance->config->heartbeatinterval->value) > 0) {
$this->heartbeatTimer = setTimeout(function ($timer) {
if (in_array('one-by-one', $this->pollMode)) {
$this->heartbeatOnFinish = true;
$this->stop();
return;
}
$this->sendFrame('h');
if ($this->gcEnabled) {
$this->gcCheck();
}
}, $f * 1000000.0);
}
$this->afterHeaders();
if ($this->poll) {
$this->acquire(function () {
$this->poll();
});
}
}