Re: Alias and PerlOutputFilterHandler in virtual host configuration

2009-02-15 Thread Torsten Foertsch
On Sun 15 Feb 2009, Roger Munk wrote:
> I have the following directives in my sites-available/default
> configuration:
>
>        DocumentRoot /var/www/
>        Alias /portal/ /var/www/drupal6/
>        PerlRequire "/etc/apache2/ModPerl/TE/ST.pm"
>         
>             SetHandler modperl
>             PerlOutputFilterHandler TE::ST
>         
>
> When the SetHandler and PerlOutputFilterHandler are commented out,
> the redirection from /portal to /var/www/drupal6 works correctly.
> However, when the SetHandler and PerlOutputFilterHander are enabled I
> get the following error messages:
>
>
> [Mon Feb 16 22:43:40 2009] [error] [client 192.168.1.2] Attempt to
> serve directory: /var/www/drupal6/, referer: http://10.0.0.1/portal/
> [Mon Feb 16 22:43:40 2009] [error] [client 192.168.1.2] script
> '/var/www/index.php' not found or unable to stat, referer:
> http://10.0.0.1/portal/
>
> Why would the SetHandler and PerlOutputFilterHandler stop the Alias
> directive from working correctly?

It does not. You see the first message? That is the result of the alias. 
The thing that confuses me is what do you want to achieve 
by "SetHandler modperl" but leaving out the PerlResponseHandler?

If your page is generated by php and you only want to postprocess it on 
its way out then drop the SetHandler. The PerlOutputFilterHandler does 
not need a "SetHandler modperl".

Torsten

-- 
Need professional mod_perl support?
Just hire me: torsten.foert...@gmx.net


Re: Alias and PerlOutputFilterHandler in virtual host configuration

2009-02-15 Thread Roger Munk
On Sun, Feb 15, 2009 at 4:05 PM, Torsten Foertsch
 wrote:

> If your page is generated by php and you only want to postprocess it on
> its way out then drop the SetHandler. The PerlOutputFilterHandler does
> not need a "SetHandler modperl".

Thanks, that was perfect. One more follow-up question. I want to
filter the cookies that the app sets when the user authenticates. The
app returns two 'Set-Cookie' headers, ie:

HTTP/1.1 200 OK
Date: Mon, 16 Feb 2009 14:25:27 GMT
Server: Apache
Set-Cookie: SESSf735b3e5ffd445f569dafde349c14e35=deleted; expires=Sun,
17-Feb-2008 14:25:26 GMT; path=/
Set-Cookie: 
SESSf735b3e5ffd445f569dafde349c14e35=8281d2673e2a2d6625ec7a94ea3d9716;
expires=Wed, 11 Mar 2009 17:58:47 GMT; path=/; HttpOnly


My output filter handler gets the cookies  via:

my $Cookie = $f->r->headers_out->get("Set-Cookie");

and then removes the expires=date bit with:

if ($Cookie)
{
$Cookie =~ s/expires.*GMT\;//g;
$f->r->headers_out->set("Set-Cookie" => "$Cookie");
}

The problem is that this code only seems to remove the expires date in
the first cookie. The second cookie never shows up in the filtered
HTTP response headers. How can I filter the second cookie as well?

Thanks

- Roger


Re: Alias and PerlOutputFilterHandler in virtual host configuration

2009-02-15 Thread André Warnier

Roger Munk wrote:

I have the following directives in my sites-available/default configuration:

   DocumentRoot /var/www/
   Alias /portal/ /var/www/drupal6/
   PerlRequire "/etc/apache2/ModPerl/TE/ST.pm"

SetHandler modperl
PerlOutputFilterHandler TE::ST



See Torsten's response for the SetHandler.
But apart from that, the combination of these 3 directives sounds a bit
strange to me :

  DocumentRoot /var/www/
  Alias /portal/ /var/www/drupal6/
  


The first one means that your "document root" (in other words the
filesystem area that corresponds to the URL "/") is /var/www.
In other words, if someone requests "/drupal6", he gets to
/var/www/drupal6, and if he requests "/drupal6/abc.html", he gets
/var/www/drupal6/abc.html (if it exists).
Then the alias says that "/portal/" also maps to "/var/www/drupal6/". So
now the users have 2 ways to get there : "/drupal6" and "/portal/".
So if the user requests "/portal/abc.html", he really gets
"/var/www/drupal6/abc.html" also.
Allright, so you want to make it easy for users, they just have to
remember "portal" instead of "drupal6" (and maybe for you too, if some
day you change that to "drupal7").

But then the  relates to (and only to) when users request
"/portal/".
In other words, whatever you put in that Location section does not apply
when users request the same document via "/drupal6".
So if the user requests "/portal/abc.html", the Perl output filter would
be called, but if they ask for "/drupal6/abc.html", it would not run,
although they would get the same document abc.html.

I'm thinking that this is not necessarily the effect you want to
achieve, so what is it that you want to achieve ?




Re: Alias and PerlOutputFilterHandler in virtual host configuration

2009-02-15 Thread André Warnier

Roger Munk wrote:

On Sun, Feb 15, 2009 at 4:05 PM, Torsten Foertsch
 wrote:


If your page is generated by php and you only want to postprocess it on
its way out then drop the SetHandler. The PerlOutputFilterHandler does
not need a "SetHandler modperl".


Thanks, that was perfect. One more follow-up question. I want to
filter the cookies that the app sets when the user authenticates. The
app returns two 'Set-Cookie' headers, ie:

HTTP/1.1 200 OK
Date: Mon, 16 Feb 2009 14:25:27 GMT
Server: Apache
Set-Cookie: SESSf735b3e5ffd445f569dafde349c14e35=deleted; expires=Sun,
17-Feb-2008 14:25:26 GMT; path=/
Set-Cookie: 
SESSf735b3e5ffd445f569dafde349c14e35=8281d2673e2a2d6625ec7a94ea3d9716;
expires=Wed, 11 Mar 2009 17:58:47 GMT; path=/; HttpOnly


My output filter handler gets the cookies  via:

my $Cookie = $f->r->headers_out->get("Set-Cookie");


see http://perl.apache.org/docs/2.0/api/APR/Table.html#C_get_
(you only get the first one this way)
my @cookies = $f->r->headers_out->get("Set-Cookie");
would get you an array with both.


and then removes the expires=date bit with:

if ($Cookie)
{
$Cookie =~ s/expires.*GMT\;//g;
$f->r->headers_out->set("Set-Cookie" => "$Cookie");
}

The problem is that this code only seems to remove the expires date in
the first cookie. The second cookie never shows up in the filtered
HTTP response headers. How can I filter the second cookie as well?

Thanks

- Roger





Re: Alias and PerlOutputFilterHandler in virtual host configuration

2009-02-15 Thread Roger Munk
On Sun, Feb 15, 2009 at 5:12 PM, André Warnier  wrote:
> see http://perl.apache.org/docs/2.0/api/APR/Table.html#C_get_
> (you only get the first one this way)
> my @cookies = $f->r->headers_out->get("Set-Cookie");
> would get you an array with both.

Thanks, when I tried receiving the cookies in an array, using the code
below, I only see the second cookie now in the output. Since both
cookies are set with seperate "Set-Cookie" headers are they getting
overwritten at some point, or is there a problem with my code?

unless ($f->ctx)
{
my @Cookies = $f->r->headers_out->get("Set-Cookie");

foreach my $Cookie (@Cookies)
{
$Cookie =~ s/expires.*GMT\;//g;
$f->r->headers_out->set("Set-Cookie" => "$Cookie");
}
$f->ctx(1);
}

- Roger


Re: Alias and PerlOutputFilterHandler in virtual host configuration

2009-02-15 Thread Torsten Foertsch
On Sun 15 Feb 2009, Roger Munk wrote:
> On Sun, Feb 15, 2009 at 5:12 PM, André Warnier  wrote:
> > see http://perl.apache.org/docs/2.0/api/APR/Table.html#C_get_
> > (you only get the first one this way)
> > my @cookies = $f->r->headers_out->get("Set-Cookie");
> > would get you an array with both.
>
> Thanks, when I tried receiving the cookies in an array, using the
> code below, I only see the second cookie now in the output. Since
> both cookies are set with seperate "Set-Cookie" headers are they
> getting overwritten at some point, or is there a problem with my
> code?
>
>     unless ($f->ctx)
>     {
>         my @Cookies = $f->r->headers_out->get("Set-Cookie");
>
>         foreach my $Cookie (@Cookies)
>         {
>             $Cookie =~ s/expires.*GMT\;//g;
>             $f->r->headers_out->set("Set-Cookie" => "$Cookie");
>         }
>         $f->ctx(1);
>     }

I am about to say RTFM but being polite: Please read the documentation 
mentioned above more thouroughly. APR::Table provides an "add" method. 
And before you ask your next question "How can I get rid of the 
original cookies?" read that piece again, ;-)

Torsten

-- 
Need professional mod_perl support?
Just hire me: torsten.foert...@gmx.net