APM: cgi::application and response buffering?

Wayne Walker wwalker at bybent.com
Fri Apr 29 12:48:02 PDT 2005


Sam,

You could do 

$self->header_type('none');
print "Content-Type: text/html\n\n";

print "hang on"...
do some stuff
return $output;

The documentation says :

Your application should *NEVER* print() to STDOUT.  Using print() to send output to STD-
OUT (including HTTP headers) is exclusively the domain of the inherited run() method.
Breaking this rule is a common source of errors.  If your program is erroneously sending
content before your HTTP header, you are probably breaking this rule.

BUT, what I said above will probably work fine.

Wayne


On Fri, Apr 29, 2005 at 11:15:02AM -0500, Sam Foster wrote:
> I've got a little cgi that uses CGI::Application.
> Its primary job is building and delivering zip files from a filelist.
> 
> I'd like to show the user progress on what files are being added as the 
> script runs (as I some of the zip files will be many MB of data). Im 
> looking for an option or way to turn off response buffering and start 
> printing out content as it arrives but CGI::Application seems to 
> preclude this? The work is done in my runmode subroutine, but headers 
> etc. don't get sent until much later.
> 
> ... from CGI::Application::run()
> 
>     # Call cgiapp_postrun() hook
>     $self->cgiapp_postrun($bodyref);
> 
> 	# Set up HTTP headers
> 	my $headers = $self->_send_headers();
> 
> 	# Build up total output
> 	my $output  = $headers.$$bodyref;
> 
> 
> 	# Send output to browser (unless we're in serious debug mode!)
> 	unless ($ENV{CGI_APP_RETURN_ONLY}) {
> 		print $output;
> 	}
> 
> Any ideas?
> 
> thanks,
> Sam
> 
> _______________________________________________
> Austin mailing list
> Austin at pm.org
> http://mail.pm.org/mailman/listinfo/austin

-- 

Wayne Walker

wwalker at gnumber.com

Do you care who calls your cell phone at 3 in the morning?
www.gnumber.com

wwalker at bybent.com                 Do you use Linux?!
http://www.bybent.com              Get Counted!  http://counter.li.org/
Perl - http://www.perl.org/        Perl User Groups - http://www.pm.org/
Jabber:  wwalker at jabber.ntrc.net   AIM:     lwwalkerbybent
IRC:     wwalker on freenode.net


More information about the Austin mailing list