[cgiapp] Re: CGI::Application::Server and CGI::Application::Plugin::Stream

George Hartzell hartzell at alerce.com
Sat Jan 3 16:59:56 EST 2009


Mark Stosberg writes:
 > On Sun, 28 Dec 2008 21:59:02 -0700
 > Bradley C Bailey <cgiapp at brad.memoryleak.org> wrote:
 > 
 > > Hello,
 > > 
 > > I run my application under CGI::Application::Server during testing, and 
 > > recently began sending files with CGI::Application::Plugin::Stream.
 > > 
 > > However, they do not seem compatible since CAP::Stream directly prints 
 > > to STDOUT, and CA::Server runs under CGI_APP_RETURN_ONLY and expects the 
 > > application to return the content.  So CAP::Stream prints the content 
 > > before CA::Server can print the proper HTTP stuff.
 > > 
 > > I attached a simple patch for a workaround, hopefully it goes through. 
 > > I am not sure this is the best solution though.
 > > 
 > > Comments?
 > 
 > My first instinct was to try to solve this from the other direction.
 > Can ::Server be modified to allow streaming?
 > 
 > Streaming is usually used for large files, the kind you may not want 
 > to try to fit all in memory at once.
 > 
 > On the other hand, your approach could also be considered reasonable.
 > If the user has requested the "return only" behavior through the
 > environment, shouldn't the Stream plugin comply?
 > 
 > I'm interested in the opinions of others as well. 
 > 

I haven't had any time to see how hard it would be to modify
CA::Server to support streaming and I don't forsee time freeing up any
time soon.

That said, it does seem like it'd be nice to avoid loading large files
into memory.

On the other hand, I agree that this patch seems unsurprising, doing
what's been requested.

On the gripping hand, the right choice might come down to the app's
ultimate use: in a development setting slurping the entire file's
probably ok but it might not scale in a production environment.

g.



More information about the cgiapp mailing list