Now we are talking! This 'CGI_APP_RETURN_ONLY' mode should be documented.
I tried this and it works perfectly.  In fact, it is sufficient to set
this flag off for this particular method and not to bother with return
$output:

sub method{
        my $subapp = Subapp->new();
        $ENV{CGI_APP_RETURN_ONLY} = 0;
        $subapp->run();
}

A question remains open, how will this behave with Fast CGI. If I
initialize MyCGIApp outside the FactCGI loop, this flag will, probably,
remain off for other run modes as well.  I will have to turn this flag on
and off in each run mode.

Thanks for the fruitful discussion!

Arkady.

On Wed, 26 Mar 2003, Greg Marr wrote:

> At 12:30 PM 3/26/2003, Arkady Grudzinsky wrote:
> >thanks for your response.  From what I understand, there are ways
> >AROUND,
> >but there is no DIRECT way to do this using CGI::App.
>
> I don't know how supported this is, but I found this in 3.0:
>          # Send output to browser (unless we're in serious debug mode!)
>          unless ($ENV{CGI_APP_RETURN_ONLY}) {
>                  print $output;
>          }
>
> You could use it like so:
>
> $ENV{CGI_APP_RETURN_ONLY} = 1;
> my $output = $sub_app->run;
> $ENV{CGI_APP_RETURN_ONLY} = 0;
> return($output);
>
> This might still have a problem with duplicate headers, though.
>
> Perhaps a "return body only" flag could be added to run() for this
> purpose, or run() could check for a param() setting to only return
> the body.
>
> On the other hand, perhaps something like this instead, to prevent
> the "outer" CGI::Application from printing:
> my $output = $sub_app->run;
> $ENV{CGI_APP_RETURN_ONLY} = 1;
> return;
>
> Having an official "return only" flag would be helpful for when you
> need to print out your own header and body.  The only way to do that
> now (that I know of) is to print the header and body, and then exit().
>
> --
> Greg Marr
> [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to