Html 如何从Dancer路由保持HTTP连接
我在一个项目中使用Perl Dancer,我想实现SSEs 我有一条舞者路线,我正努力保持它的活力Html 如何从Dancer路由保持HTTP连接,html,perl,http,dancer,Html,Perl,Http,Dancer,我在一个项目中使用Perl Dancer,我想实现SSEs 我有一条舞者路线,我正努力保持它的活力 get '/stream' => sub{ my $response = Dancer::SharedData->response; debug($response->exists); $response->status(200); $response->content("data: cool test\n\n"); $resp
get '/stream' => sub{
my $response = Dancer::SharedData->response;
debug($response->exists);
$response->status(200);
$response->content("data: cool test\n\n");
$response->content_type( 'text/event-stream' );
$response->header( 'Cache-Control' => 'no-cache' );
$response->header( 'Connection' => 'Keep-Alive' );
$response->pass;
return undef;
};
似乎从舞者路线返回任何东西都会关闭连接。理想情况下,我希望它保持打开状态并存储$response
,以便将更多数据推送到以后
更新:在进一步的研究中,舞者使用的PSGI似乎可以做到这一点:
此时正在研究中间件方法。这里的答案是转移到另一个Web服务器。我使用的是不支持http连接的starman。移动到mojolicous或twiggy