I've been doing some more testing and it seems to work really well.
Serving up big files quite happily, and fast!
A few additional thoughts...
The PSGI spec allows 2 useful options:
1) The subref callback as originally suggested
2) Return a filehandle and the server hadles the streaming automatically.
The filehandle option is very neat if all you need to do is send a
file to the browser.
The callback option seems useful as well because it's possible to do
stuff during or after the file streaming. I like to write a log
message and delete temp files etc at the end so this is handy.
Also I wonder if simply returning the filehandle / subref would be
more elegant that my initial $self-psgi_streaming_callback getter /
setter idea.
I tried to think of a way to do this without hacking into
Application.pm Stream.pm, but in the end figured it was the (best /
easiest) way to go. Do you think we can kick this about and get in
accepted into the upstream packages? I have written some tests and
pod documentation.
Is Purdy on this list?
Regards,
Mike
On 8 October 2012 16:55, Mike Tonks fluffym...@googlemail.com wrote:
Hi Mark,
Thanks for the feedback. OK I'll have a go then.
Here's my initial attempts...
https://github.com/miketonks/CGI--Application
https://github.com/miketonks/CGI-Application-Plugin-Stream
Does this approach seem ok?
mike
On 5 October 2012 14:03, Mark Stosberg m...@summersault.com wrote:
Mike,
My reading of the spec is that you can return a callback instead of a
body, and the Plack server should handle the rest:
https://metacpan.org/module/PSGI#Delayed-Response-and-Streaming-Body
If the server doesn't suppport streaming, a MiddleWare can provide it:
https://metacpan.org/module/Plack::Middleware::BufferedStreaming
I have not needed to do this yet myself with PSGI (but will eventually).
Mark
# CGI::Application community mailing list
####
## To unsubscribe, or change your message delivery options, ##
## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp##
####
## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ##
## Wiki: http://cgiapp.erlbaum.net/ ##
####