[Dancer-users] return part of the data

Alexis Sukrieh sukria at sukria.net
Mon Aug 30 16:58:10 CEST 2010


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


More information about the Dancer-users mailing list