You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Hans Poo <ha...@namb.cl> on 2001/10/08 18:59:34 UTC

Redirections after printing content

Hi

I'am new to the list, and i've been looking for a solution for
buffering, in order to decide to make a redirect after the printing of
HTML content. It seems that $| don't work fot this.

I take a look around and this capacity seem to appear in Apache:ASP at
this time i can't use this module, and i just have mod_perl.

Hans Poo


Re: Redirections after printing content

Posted by Hans Poo <ha...@namb.cl>.
Andrew Ho wrote:

> Hans,
>
> HP>I'am new to the list, and i've been looking for a solution for
> HP>buffering, in order to decide to make a redirect after the printing of
> HP>HTML content. It seems that $| don't work fot this.
>
> Whether or not you have $| on, you will want to explicitly control whether
> output is sent if you may want to do a redirect at some point in your
> code. There are two simple ways to rearrange your code to do this from a
> mod_perl handler or Apache::Registry scripts.
>
> The first is to determine what all the cases are where you would do a
> redirect. Then put this code up front, before you output anything.
>
> The second method would be to organize your code so that instead of using
> print or calling $r->print(), you accumulate your output into a variable.
> At the end of your handler() or Apache::Registry script, you can either
> redirect, or print the accumulated output.
>
> Humbly,
>
> Andrew
>
> ----------------------------------------------------------------------
> Andrew Ho               http://www.tellme.com/       andrew@tellme.com
> Engineer                   info@tellme.com          Voice 650-930-9062
> Tellme Networks, Inc.       1-800-555-TELL            Fax 650-930-9101
> ----------------------------------------------------------------------

Thank you Andrew

I was already aware of the solutions you gave me, and it's comfortable to
listen another programmer who seems exactly the same.

I was expecting to find something new inside mod_perl to do the job. Actually
i keep the redirection code in top of the application and it's not a clean
solution. Put a wraper around the print statement seems the cleaner solution
after all.

I don't want to reinvent the wheel and finally decided to use Apache::ASP
with it's buffering capabilities.

Hans Poo

Re: Redirections after printing content

Posted by Andrew Ho <an...@tellme.com>.
Hans,

HP>I'am new to the list, and i've been looking for a solution for
HP>buffering, in order to decide to make a redirect after the printing of
HP>HTML content. It seems that $| don't work fot this.

Whether or not you have $| on, you will want to explicitly control whether
output is sent if you may want to do a redirect at some point in your
code. There are two simple ways to rearrange your code to do this from a
mod_perl handler or Apache::Registry scripts.

The first is to determine what all the cases are where you would do a
redirect. Then put this code up front, before you output anything.

The second method would be to organize your code so that instead of using
print or calling $r->print(), you accumulate your output into a variable.
At the end of your handler() or Apache::Registry script, you can either
redirect, or print the accumulated output.

Humbly,

Andrew

----------------------------------------------------------------------
Andrew Ho               http://www.tellme.com/       andrew@tellme.com
Engineer                   info@tellme.com          Voice 650-930-9062
Tellme Networks, Inc.       1-800-555-TELL            Fax 650-930-9101
----------------------------------------------------------------------