[cgiapp] Streaming Large Files using PSGI
Mark Stosberg
mark at summersault.com
Fri Oct 12 09:25:49 EDT 2012
On 10/12/2012 09:06 AM, Mike Tonks wrote:
> 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.
I'm interested in having PSGI steaming well-supported in
CGI::Application. Have you looked around at some other frameworks to see
how they handle PSGI streaming? You might find a nice "prior art" design
that you like, or find some lessons-learned that we don't need to
relearn here.
> Is Purdy on this list?
Best to CC him explicitly to be sure, or even contact him directly Even
if someone is subscribed, they have it filtered out of their inbox.
Mark
More information about the cgiapp
mailing list