Hi fellow dancers, So far I know only how to return output via return. As far as I can see, this requires that I already have the full content available at the point when I return. I wonder if there is there is a webapp equivalent to this foreach (@big_loop) { my $result=do_something(); print STDOUT $result } where I can calculate a piece, output it and continue to do so until done. This would bring down the lacency (until response begins) enormously. I am working on a OAI data provider, see http://www.openarchives.org/OAI/openarchivesprotocol.html. The specification requires me to deliver a potentially big xml via http. I would love to generate this xml on the fly. Or do I get something totally wrong here? Any suggestions greatly appreciated. thanks from the beginners' dance class Maurice
Hi Maurice, Le 30/08/2010 15:40, Maurice Mengel a écrit :
[...] I wonder if there is there is a webapp equivalent to this
foreach (@big_loop) { my $result=do_something(); print STDOUT $result }
where I can calculate a piece, output it and continue to do so until done. This would bring down the lacency (until response begins) enormously.
I am working on a OAI data provider, see http://www.openarchives.org/OAI/openarchivesprotocol.html. The specification requires me to deliver a potentially big xml via http. I would love to generate this xml on the fly.
Or do I get something totally wrong here?
You're perfectly right. You actually want to _stream_ your response's content instead of rendering it at once. That's legitimate. PSGI already support that kind of response handling: http://search.cpan.org/dist/PSGI/PSGI.pod#Delayed_Reponse_and_Streaming_Body But unfortunately, Dancer does not already. We plan to address that issue with a new keyword, called 'send_data' (just like Sinatra does). If you have the time to report an issue (whishlist) on GitHub, that would be nice; so we can keep track of your demand. Thanks for the note, that would be definitely a nice feature to have for the next stable release. -- Alexis Sukrieh
participants (2)
-
Alexis Sukrieh -
Maurice Mengel