You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Stathy Touloumis <st...@edventions.com> on 2001/02/13 19:54:14 UTC

Setting 'Location' header

This code does not seem to work whether in a handler or when using a Mason
component.  I have tried several variations with different versions of
mod_perl to no avail.  Can anyone shed some light?

my $head = $r->headers_out;
$head->set( Location=> '/index.html' );
$head->set( Target=> '_top' );
$r->send_http_header;

Thanks!


Odd Caching Bug

Posted by Stathy Touloumis <st...@edventions.com>.
Hello,

One of the developers I currently am working with has found an odd bug that
can be replicated on several workstations.  First my configuration :
Apache 1.3.17
mod_perl 1.25
Mason (Ancient)
Apache::DBI .88
Postgres 7

MaxRequestsPerChild 1
KeepAlive on


We have two components that contain the following code.  One of which
changes a session variable (datestyle to 'ISO')on the postgres database.
Theoretically the two components should return different results based on
the specific datestyle settings ('ISO' and default).  This only occurs when
two browsers are opened independently that do not share the same session.
When using ctrl-n on a windows client to open a new window it appears that
they share session information and possibly the same tcp/ip connection(?).
When reloading the components in the two windows eventually they both return
the 'ISO' format date.  After pausing for several minutes and reloading the
component that DOES NOT explicitly set the 'ISO' format variable, it
correctly returns the default date format.

--COMPONENT 1--
<%perl_init>
my $dbh = Edventions::Utilities->new->getDbHandle; ## Uses Apache::DBI to
connect
my $sql = q( select now() as today );
my $sth = $dbh->prepare( $sql );
$sth->execute;
my $now = $sth->fetch->[0];
</%perl_init>

<h1><% $now %>

--COMPONENT 2--
<%perl_init>
my $dbh = Utilities->new->getDatabaseHandle; ## Uses Apache::DBI to connect
my $sql = q( set datestyle to 'ISO'; select now() as today );
my $sth = $dbh->prepare( $sql );
$sth->execute;
my $now = $sth->fetch->[0];
</%perl_init>

<h1><% $now %>

Now when the apache directive KeepAlive is set to 'off' this problem does
not occur.  I am trying to figure out where the caching is occurring or if
the database handle is not getting properly destroyed for each request.

Any suggestions as to why this is occurring would be greatly appreciated.

Thanks,


Re: Setting 'Location' header

Posted by Dave Rolsky <au...@urth.org>.
On Tue, 13 Feb 2001, Stathy Touloumis wrote:

> This code does not seem to work whether in a handler or when using a Mason
> component.  I have tried several variations with different versions of
> mod_perl to no avail.  Can anyone shed some light?
>
> my $head = $r->headers_out;
> $head->set( Location=> '/index.html' );
> $head->set( Target=> '_top' );
> $r->send_http_header;

The Mason FAQ has a good example of how to do a redirect from a Mason
component.  The same code (minus the Mason specific stuff) works fine
under mod_perl.

You're missing setting the status, which is probably the main problem.

Here's a link to the Mason FAQ:

http://www.masonhq.com/docs/faq/#How_do_I_do_an_external_redirect


-dave

/*==================
www.urth.org
We await the New Sun
==================*/