unsetting PerlTransHandler

2003-08-14 Thread Torsten Foertsch
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I have a



PerlTransHandler Handler






and want to unset the TransHandler inside the .

How to do that?

Thanks
Torsten
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/O2FrwicyCTir8T4RAsXlAKCr0SfbKsG/9iNbv4pjxv1rOodV1wCggKOQ
zQ/hRg4aSVwUDr3brnJY+I8=
=oKyR
-END PGP SIGNATURE-


RE: unsetting PerlTransHandler

2003-08-14 Thread Frank Maas
> and want to unset the TransHandler inside the .
> How to do that?

AFAIK: not. The TransHandler is the first to be called and cannot appear
inside a container (ref. ModPerl cookbook). The only thing I can think of,
and in fact implemented this, to make the TransHandler URI-aware and 
return immediately if the uri is something you do not want to be touched
by the TransHandler.

Hope this helps

--Frank


Re: unsetting PerlTransHandler

2003-08-14 Thread Geoffrey Young

I understand translation handlers cannot be -specific. But 
 directives apply before any translation handler is called (see 
below). 
yes they do, but not really.  to really understand this, see

http://httpd.apache.org/docs/sections.html

specifically,

"There is actually a /  sequence performed just 
before the name translation phase (where Aliases and DocumentRoots  are used 
to map URLs to filenames). The results of this sequence are completely 
thrown away after the translation has completed."

which is what you found in the code - note the "completely thrown away" 
part.  in essence, this means that the results of the  config 
merging are discarded prior to translation, after which  merging 
is done again.

regardless, officially apache translation (which includes the 
PerlTransHandler) cannot be  specific - directives must appear 
outside of , , and  (and their regex 
counterparts).  if you look at other modules that implement translation 
handlers (mod_rewrite, for instance), you'll see that their translation 
directives all have RSRC_CONF prototypes, which prohibits their placement 
inside of these containers.

--Geoff



Re: unsetting PerlTransHandler

2003-08-14 Thread Frank Maas
On Thu, Aug 14, 2003 at 11:07:13AM -0400, Geoffrey Young wrote:
> 
> "There is actually a /  sequence performed just 
> before the name translation phase (where Aliases and DocumentRoots  are 
> used to map URLs to filenames). The results of this sequence are completely 
> thrown away after the translation has completed."
> 
> which is what you found in the code - note the "completely thrown away" 
> part.  in essence, this means that the results of the  config 
> merging are discarded prior to translation, after which  merging 
> is done again.

Ehm... considering both solutions worked and the quoted paragraph, 
shouldn't we read it as 'the results of this sequence can be used during
the translation phase, but are thrown away after the translation has
completed'. This would mean that the results are not discarded prior to 
translation, but after translation and that would also explain why the two 
solutions work...

--Frank


Re: unsetting PerlTransHandler

2003-08-14 Thread Torsten Foertsch
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thursday 14 August 2003 14:49, Geoffrey Young wrote:
> trans handlers are used to map the URI to a filename, the result of which
> lets Apache know to which  the URI belongs to.  it can also
> affect which  the URI belongs to if that  is paired
> with an Alias directive.   trying to make a trans handler 
> specific doesn't really make sense - if you are already in a 
> section then you should already know which file (or lack thereof) you want
> to serve. that's just how Apache works.

Thanks for the explanation. But...

I understand translation handlers cannot be -specific. But 
 directives apply before any translation handler is called (see 
below). Even more I found a note in Apache docs on mod_alias:

"Aliasing occurs before  sections are checked, so only the 
destination of aliases are affected. (Note however   sections are 
run through once before aliases are performed, so they will apply.)"

I admit there can be confusion if a translation handler changes r->uri since 
 directives are applied again after  and  sections 
after the translation handler has returned. But mod_alias doesn't do that. It 
sets r->filename and returns OK (and finishs the translation phase).

> > return DECLINED
> >   if(grep {$_ eq __PACKAGE__.'::handler'}
> > @{$r->get_handlers('PerlHandler')}); ...
> > }
>
> I don't think that will work the way you desire - the PerlHandler directive
> should not be merged into the current configuration for the request until
> after the trans handler runs, so I wouldn't expect it to be present in
> get_handlers() yet.

But it actually does work, as does Frank's variant (PerlSetVar 
SkipTransHandler 1). I've read a little source 
(apache_1.3.26/src/main/http_request.c: process_request_internal()):

if ((access_status = location_walk(r))) {
ap_die(access_status, r);
return;
}

if ((access_status = ap_translate_name(r))) {
decl_die(access_status, "translate", r);
return;
}

...

/*
 * NB: directory_walk() clears the per_dir_config, so we don't inherit
 * from location_walk() above
 */

if ((access_status = directory_walk(r))) {
ap_die(access_status, r);
return;
}

if ((access_status = file_walk(r))) {
ap_die(access_status, r);
return;
}

if ((access_status = location_walk(r))) {
ap_die(access_status, r);
return;
}

as I understand location_walk() applies  sections. It is called just 
before the translation handlers (ap_translate_name()). Later on they are 
applied again because directory_walk() clears that data. That means it can 
lead to confusion if a translation handler changes r->uri a different 
 section gets applied.

BTW, the same steps are also performed for subrequests.

Torsten
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/O51+wicyCTir8T4RAnJmAJ96c1oepdttLD/NsD0RVIfblXfT3ACfepf9
l6APcLfK6u/Mp3un7t5GYYg=
=akE9
-END PGP SIGNATURE-


Re: unsetting PerlTransHandler

2003-08-14 Thread Torsten Foertsch
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thursday 14 August 2003 18:20, Geoffrey Young wrote:
> Frank Maas wrote:
> > Ehm... considering both solutions worked and the quoted paragraph,
> > shouldn't we read it as 'the results of this sequence can be used during
> > the translation phase, but are thrown away after the translation has
> > completed'. This would mean that the results are not discarded prior to
> > translation, but after translation and that would also explain why the
> > two solutions work...
>
> well, they can only be used during translation if the URI is unaltered. 
> for instance, given the example we've seen already
>
> PerlTransHandler MyPackage::transhandler
> 
> PerlHandler MyPackage::handler
> 
>
> checking get_handlers() in transhandler() only works because the initial
> merge (which is thrown away) ends up being the same merge as after
> translation.  if any (other) trans handlers meddle with $r->uri (which is
> perfectly valid) then the initial get_handlers() call will report settings
> completely different than the end  that is finally applied to the
> URL.

well, if a transhandler alters the Uri than maybe MyPackage::handler will not 
be called at all, yes. But from the point of view at start of the request it 
would be called.

> so, I guess -specific settings can be used during translation,
> much in the same way that you can break encapsulation in Perl by simply
> accessing the object via its underlying hash - the "feature" works
> currently due to the way things are implemented, but using it is not
> guaranteed to work in the future (apache 2.0?), and may have unintended
> consequences in the present.  in other words, it's a bad idea and people
> who know better certainly don't rely on it.

I'm wondering then for what reason that initial merge is done at all if not to 
be used during name translation?

well, a translation handler cannot be sure that the $r->dir_config it gets was 
really caused by the $r->uri it sees. Further, other handlers in later phases 
can get completely different settings.

I've searched the standard modules for /r->uri\s*=/ and found only one 
occurence in mod_rewrite with the [PT] flag. I assume the right solution 
would be to do another merge based on the new uri if someone alters the uri 
during name translation and plans to return DECLINED.

And as for apache 2, there I have found these lines:

if ((access_status = ap_location_walk(r))) {
return access_status;
}

if ((access_status = ap_run_translate_name(r))) {
return decl_die(access_status, "translate", r);
}

Torsten
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/O+VtwicyCTir8T4RAiiEAJ4rtu6tMCVrkho5eP3L3+Yz8NGQ9QCguIUb
oxm9P4ttWWeO0g7/BRb4raQ=
=iiYV
-END PGP SIGNATURE-


Re: unsetting PerlTransHandler

2003-08-14 Thread Geoffrey Young

Yes, I've implemented it also that way. But I thought  acts on the 
URI and in principle there can be a -specific transhandler. I'm 
wondering why it is impossible?
trans handlers are used to map the URI to a filename, the result of which 
lets Apache know to which  the URI belongs to.  it can also 
affect which  the URI belongs to if that  is paired with 
an Alias directive.   trying to make a trans handler  specific 
doesn't really make sense - if you are already in a  section then 
you should already know which file (or lack thereof) you want to serve. 
that's just how Apache works.

For now I have implemented that particular case by

PerlTransHandler MyPackage::transhandler

PerlHandler MyPackage::handler

package MyPackage;

sub transhandler {
... 
return DECLINED
  if(grep {$_ eq __PACKAGE__.'::handler'} @{$r->get_handlers('PerlHandler')});
...
}

i.e. if my handler is installed return DECLINED.
I don't think that will work the way you desire - the PerlHandler directive 
should not be merged into the current configuration for the request until 
after the trans handler runs, so I wouldn't expect it to be present in 
get_handlers() yet.

a better way is probably to let your PerlTransHandler run always.  then, for 
requests to  use a PerlHeaderParserHandler to unset $r->filename.

HTH

--Geoff




RE: unsetting PerlTransHandler

2003-08-14 Thread Frank Maas
> I'm wondering why it is impossible?

I am not exactly sure here, but I think this is because a TransHandler
is definitely not allowed inside a  or  container. And
since Apache does not make the distinction between containers (it uses
the constant RSRC_CONF to disallow a directive from being in (all) 
containers)  is the innocent victim here.

> For now I have implemented that particular case by

Wouldn't this be simpler?

|PerlTransHandler MyPackage::transhandler
|
|  PerlSetVar SkipTransHandler 1
|
|
|package MyPackage;
|
|sub transhandler {
|...
|return DECLINED if $r->dir_config('SkipTransHandler');
|...
|}

--Frank


Re: unsetting PerlTransHandler

2003-08-14 Thread Geoffrey Young


Frank Maas wrote:
On Thu, Aug 14, 2003 at 11:07:13AM -0400, Geoffrey Young wrote:

"There is actually a /  sequence performed just 
before the name translation phase (where Aliases and DocumentRoots  are 
used to map URLs to filenames). The results of this sequence are completely 
thrown away after the translation has completed."

which is what you found in the code - note the "completely thrown away" 
part.  in essence, this means that the results of the  config 
merging are discarded prior to translation, after which  merging 
is done again.


Ehm... considering both solutions worked and the quoted paragraph, 
shouldn't we read it as 'the results of this sequence can be used during
the translation phase, but are thrown away after the translation has
completed'. This would mean that the results are not discarded prior to 
translation, but after translation and that would also explain why the two 
solutions work...
well, they can only be used during translation if the URI is unaltered.  for 
instance, given the example we've seen already

PerlTransHandler MyPackage::transhandler

PerlHandler MyPackage::handler

checking get_handlers() in transhandler() only works because the initial 
merge (which is thrown away) ends up being the same merge as after 
translation.  if any (other) trans handlers meddle with $r->uri (which is 
perfectly valid) then the initial get_handlers() call will report settings 
completely different than the end  that is finally applied to the 
URL.

so, I guess -specific settings can be used during translation, 
much in the same way that you can break encapsulation in Perl by simply 
accessing the object via its underlying hash - the "feature" works currently 
due to the way things are implemented, but using it is not guaranteed to 
work in the future (apache 2.0?), and may have unintended consequences in 
the present.  in other words, it's a bad idea and people who know better 
certainly don't rely on it.

--Geoff



Re: unsetting PerlTransHandler

2003-08-14 Thread Torsten Foertsch
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thursday 14 August 2003 13:48, Frank Maas wrote:
> |
> |  PerlSetVar SkipTransHandler 1
> |

I don't want to make it configurable.

Torsten
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/O54ywicyCTir8T4RAss0AJ4rNMkqyKC0Tlh8tPZF5XbGc4GSeQCgjwto
CvsUie4PVYy1QQ/MfsywCtI=
=npMM
-END PGP SIGNATURE-


Re: unsetting PerlTransHandler

2003-08-14 Thread Torsten Foertsch
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thursday 14 August 2003 12:34, Frank Maas wrote:
> > and want to unset the TransHandler inside the .
> > How to do that?
>
> AFAIK: not. The TransHandler is the first to be called and cannot appear
> inside a container (ref. ModPerl cookbook). The only thing I can think of,
> and in fact implemented this, to make the TransHandler URI-aware and
> return immediately if the uri is something you do not want to be touched
> by the TransHandler.

Yes, I've implemented it also that way. But I thought  acts on the 
URI and in principle there can be a -specific transhandler. I'm 
wondering why it is impossible?

For now I have implemented that particular case by

PerlTransHandler MyPackage::transhandler

PerlHandler MyPackage::handler


package MyPackage;

sub transhandler {
... 
return DECLINED
  if(grep {$_ eq __PACKAGE__.'::handler'} @{$r->get_handlers('PerlHandler')});
...
}

i.e. if my handler is installed return DECLINED.

Torsten
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/O2e0wicyCTir8T4RAjpXAKC8qRHIrQXxIA3O1RP3BnC40LcVqgCgy+eS
c+edNr0sMUM+tq0jmICq39Q=
=PnAk
-END PGP SIGNATURE-


RE: PerlTransHandler headaches

2003-07-30 Thread Glenn E. Bailey III
: don't forget, you can't just change handlers and expect them 
: to work - 

This is probably what has been messing me up. Doing a quick stop
and restart of Apache after any change I made seems to have fixed
my problems, do! Thanks for your help ;-)

. Glenn E. Bailey III
. Network Solutions Developer
. Sprocket Data, Inc.



Re: PerlTransHandler headaches

2003-07-30 Thread Geoffrey Young

: so, the general rule for PerlTransHandlers is to return 
: DECLINED unless you 
: set $r->filename.

What I am trying to do is just test, to make sure it is working
ok. So what I did is wrote the following snippit:
sub handler {
  my $r = shift;
  return DECLINED;
  }
That should still allow me to pull up my default content, correct? As
of now it still gives me a 404 ..
make sure the request works without the PerlTransHandler installed first. 
if it does, then adding that routine should be ok.

don't forget, you can't just change handlers and expect them to work - 
because the code is loaded the first time it's seen and not on every 
request, you either need to install Apache::StatINC, Apache::Reload, set 
PerlFreshRestart On and restart the server or (simplest) fully shutdown and 
startup the server.

--Geoff



RE: PerlTransHandler headaches

2003-07-30 Thread Glenn E. Bailey III
: check out the resources at http://perl.apache.org/ - there's 
: lots of good 
: information there :)

Heh, only found one document there concerning the TransHandler
stuff .. 

: so, the general rule for PerlTransHandlers is to return 
: DECLINED unless you 
: set $r->filename.

What I am trying to do is just test, to make sure it is working
ok. So what I did is wrote the following snippit:

sub handler {
  my $r = shift;
  return DECLINED;
  }

That should still allow me to pull up my default content, correct? As
of now it still gives me a 404 ..



Re: PerlTransHandler headaches

2003-07-30 Thread Geoffrey Young


Glenn E. Bailey III wrote:
Hello,

While I am not new to Perl, I am completely new to mod_perl. 
check out the resources at http://perl.apache.org/ - there's lots of good 
information there :)

sub handler {
  my $r = shift;
  return OK;
  }
1;
And not matter what I always get a 404 with the following in the log:

[Tue Jul 29 03:27:27 2003] [error] [client 10.0.0.1] File does not 
exist: /
the translation phase is there to map the URI to a filename.  by returning 
OK, you're telling Apache that you've done the translation (that is, you 
have set $r->filename to something useful).  since you didn't set 
$r->filename, apache is returning 404, since it can't serve the value of 
$r->filename.

so, the general rule for PerlTransHandlers is to return DECLINED unless you 
set $r->filename.

chapter 12 in the mod_perl Developer's Cookbook deals specifically with the 
PerlTransHandler and is as good a place to start learning as any.

HTH

--Geoff



PerlTransHandler headaches

2003-07-30 Thread Glenn E. Bailey III
Hello,

While I am not new to Perl, I am completely new to mod_perl. I have 
a client I am working on moving a project that runs under mod_perl. 
He does alot manipulation with the PerlTransHandler stuff. Well, 
even on a default mod_perl install, with a default Apache install, I 
can not get the darn thing to work for the life of me. Here is the 
simple script I am using to test with:

use Apache::Constants qw|OK DECLINED REDIRECT M_GET|;
use strict;
use warnings;

sub handler {
  my $r = shift;
  return OK;
  }
1;

And not matter what I always get a 404 with the following in the log:

[Tue Jul 29 03:27:27 2003] [error] [client 10.0.0.1] File does not 
exist: /

Any suggestions on where to start looking? The original coder of the 
project has left the client and is nowhere to be found, fun fun .. ;-)



Re[6]: Problem with PerlTransHandler

2003-06-27 Thread "Sergey V . Stashinskas"
It's my original very simple script:
package Apache::StripSession;
use strict;
use Apache;
use Apache::Constants qw(:common);
use DBI;
sub handler {
my $r = shift;
my $dbh = DBI->connect('dbi:mysql:altboards', 'root', '');
# Session
return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;
warn "$1, $2";
$r->subprocess_env(SESSION => $1);
$r->uri($2);
return DECLINED;
}
1;

When I try to get page from http://localhost/session/123343..12121/index
it work perfectly.
And this string has appeared in error.log -
"12345678901234567890123456789012, /index at "

But if I comment out string 'warn "$1, $2"; ' the same script with the same url 
doesn't work.
$2 is undefined and browser tell me something like "www.localhost could not be found 
..."
Why???

__END__

-Original Message-
From: "Raf" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Fri, 27 Jun 2003 15:35:16 - (GMT)
Subject: Re: Re[4]: Problem with PerlTransHandler

> 
> Sergey V. Stashinskas said:
> > Problem is not in connection with database.
> > When I try to connect then $2 regexp variable becomes undefined and
> > script can not redirect anywhere. ($r->uri($2)) But when script is not
> > connected with database all works perfectly and this variable has a real
> > defined value. I can not understand this ...
> 
> What are you actually getting in your logs?  Are you sure that it's even
> getting to $2?  My thought is this:
> 
> *  if you don't get a $dbh back, then under strict you should get a
> cock-up reporting that it can't run the method disconnect on an undefined
> reference.
> 
> Can't see why this would happen.  How you tried to dump the uri with a
> STDERR?  Noticed that you're from Russia, so perhaps it's some kind of
> character encoding/local problem, since you're matching against latin
> character classes?  Can weird character creep into your session string?
> 
> Just thoughts.  Final thought is running it through Apache::DB if you
> fancy building it.  Just a thought.
> 
> Cheers,
> 
> R.
> 
> 
> 
> 
> 
> 
> 
> 
> > Original source:
> > package Apache::StripSession;
> > use strict;
> > use Apache;
> > use Apache::Constants qw(:common);
> >
> > sub handler {
> > my $r = shift;
> >
> > my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> > $dbh->disconnect;
> > return DECLINED unless $r->uri =~
> > /^\/session\/([a-zA-Z0-9]{32})(.*)/;
> >
> > $r->subprocess_env(SESSION => $1);
> > $r->uri($2);
> >
> > return DECLINED;
> > }
> >
> > 1;
> >
> > -Original Message-
> > From: "Raf" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Date: Fri, 27 Jun 2003 15:09:13 - (GMT)
> > Subject: Re: Re[2]: Problem with PerlTransHandler
> >
> >>
> >> Sergey V. Stashinskas said:
> >> > If these lines are commented out then script is working ok.
> >> >
> >> > -Original Message-
> >> > From: <[EMAIL PROTECTED]>
> >> > To: "Sergey V. Stashinskas  "
> >> > <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]> Date: Fri, 27
> >> Jun 2003 16:39:12 +0300
> >> > Subject: RE: Problem with PerlTransHandler
> >> >
> >> >>
> >> >> Have you tried to comment out the 2 DBI lines like this:
> >> >>
> >> >> #my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> >> >> #$dbh->disconnect;
> >>
> >> Can't find your original post, however try doing something like:
> >>
> >> $dbh->disconnect if ref($dbh);
> >>
> >> or:
> >>
> >> if (ref $dbh) {
> >> $dbh->disconnect;
> >> else {
> >> ## CHECK LOGS for this
> >> print STDERR "\n Failed to connect \n";
> >> };
> >>
> >> Cheers,
> >>
> >> Raf
> >>
> >>
> >>
> >>
> 
> 
> 
> 


Re: Re[4]: Problem with PerlTransHandler

2003-06-27 Thread Raf
Sergey V. Stashinskas said:
> Problem is not in connection with database.
> When I try to connect then $2 regexp variable becomes undefined and
> script can not redirect anywhere. ($r->uri($2)) But when script is not
> connected with database all works perfectly and this variable has a real
> defined value. I can not understand this ...

What are you actually getting in your logs?  Are you sure that it's even
getting to $2?  My thought is this:

*  if you don't get a $dbh back, then under strict you should get a
cock-up reporting that it can't run the method disconnect on an undefined
reference.

Can't see why this would happen.  How you tried to dump the uri with a
STDERR?  Noticed that you're from Russia, so perhaps it's some kind of
character encoding/local problem, since you're matching against latin
character classes?  Can weird character creep into your session string?

Just thoughts.  Final thought is running it through Apache::DB if you
fancy building it.  Just a thought.

Cheers,

R.








> Original source:
> package Apache::StripSession;
> use strict;
> use Apache;
> use Apache::Constants qw(:common);
>
> sub handler {
> my $r = shift;
>
> my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> $dbh->disconnect;
> return DECLINED unless $r->uri =~
> /^\/session\/([a-zA-Z0-9]{32})(.*)/;
>
> $r->subprocess_env(SESSION => $1);
> $r->uri($2);
>
> return DECLINED;
> }
>
> 1;
>
> -Original Message-
> From: "Raf" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Date: Fri, 27 Jun 2003 15:09:13 - (GMT)
> Subject: Re: Re[2]: Problem with PerlTransHandler
>
>>
>> Sergey V. Stashinskas said:
>> > If these lines are commented out then script is working ok.
>> >
>> > -Original Message-
>> > From: <[EMAIL PROTECTED]>
>> > To: "Sergey V. Stashinskas  "
>> > <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]> Date: Fri, 27
>> Jun 2003 16:39:12 +0300
>> > Subject: RE: Problem with PerlTransHandler
>> >
>> >>
>> >> Have you tried to comment out the 2 DBI lines like this:
>> >>
>> >> #my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
>> >> #$dbh->disconnect;
>>
>> Can't find your original post, however try doing something like:
>>
>> $dbh->disconnect if ref($dbh);
>>
>> or:
>>
>> if (ref $dbh) {
>> $dbh->disconnect;
>> else {
>> ## CHECK LOGS for this
>> print STDERR "\n Failed to connect \n";
>> };
>>
>> Cheers,
>>
>> Raf
>>
>>
>>
>>





Re[4]: Problem with PerlTransHandler

2003-06-27 Thread "Sergey V . Stashinskas"
Problem is not in connection with database.
When I try to connect then $2 regexp variable becomes undefined and script can not 
redirect anywhere. ($r->uri($2))
But when script is not connected with database all works perfectly and this variable 
has a real defined value.
I can not understand this ...

Original source:
package Apache::StripSession;
use strict;
use Apache;
use Apache::Constants qw(:common);

sub handler {
my $r = shift;

my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
$dbh->disconnect;
return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;

$r->subprocess_env(SESSION => $1);
$r->uri($2);

return DECLINED;
}

1;

-Original Message-
From: "Raf" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Fri, 27 Jun 2003 15:09:13 - (GMT)
Subject: Re: Re[2]: Problem with PerlTransHandler

> 
> Sergey V. Stashinskas said:
> > If these lines are commented out then script is working ok.
> >
> > -Original Message-
> > From: <[EMAIL PROTECTED]>
> > To: "Sergey V. Stashinskas  "
> > <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]> Date: Fri, 27 Jun
> > 2003 16:39:12 +0300
> > Subject: RE: Problem with PerlTransHandler
> >
> >>
> >> Have you tried to comment out the 2 DBI lines like this:
> >>
> >> #my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> >> #$dbh->disconnect;
> 
> Can't find your original post, however try doing something like:
> 
> $dbh->disconnect if ref($dbh);
> 
> or:
> 
> if (ref $dbh) {
> $dbh->disconnect;
> else {
> ## CHECK LOGS for this
> print STDERR "\n Failed to connect \n";
> };
> 
> Cheers,
> 
> Raf
> 
> 
> 
> 


Re: Re[2]: Problem with PerlTransHandler

2003-06-27 Thread Raf
Sergey V. Stashinskas said:
> If these lines are commented out then script is working ok.
>
> -Original Message-
> From: <[EMAIL PROTECTED]>
> To: "Sergey V. Stashinskas  "
> <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]> Date: Fri, 27 Jun
> 2003 16:39:12 +0300
> Subject: RE: Problem with PerlTransHandler
>
>>
>> Have you tried to comment out the 2 DBI lines like this:
>>
>> #my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
>> #$dbh->disconnect;

Can't find your original post, however try doing something like:

$dbh->disconnect if ref($dbh);

or:

if (ref $dbh) {
$dbh->disconnect;
else {
## CHECK LOGS for this
print STDERR "\n Failed to connect \n";
};

Cheers,

Raf





Re[2]: Problem with PerlTransHandler

2003-06-27 Thread "Sergey V . Stashinskas"
If these lines are commented out then script is working ok.

-Original Message-
From: <[EMAIL PROTECTED]>
To: "Sergey V. Stashinskas  " <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
Date: Fri, 27 Jun 2003 16:39:12 +0300
Subject: RE: Problem with PerlTransHandler

> 
> Have you tried to comment out the 2 DBI lines like this:
> 
> #my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> #$dbh->disconnect;
> 
> and is still not working? You really need the database connection?
> 
> Lian
> 
> 
> > -Original Message-
> > From: Sergey V. Stashinskas [mailto:[EMAIL PROTECTED]
> > Sent: Friday, June 27, 2003 1:48 PM
> > To: [EMAIL PROTECTED]
> > Subject: Problem with PerlTransHandler
> >
> >
> > Hi all,
> >
> > Excuse me for my poor English because I'm from Russia.
> >
> > I have the problem with url translation.
> > There are 2 scripts to do it.
> > 1st script work perfectly, but 2nd failed.
> > Only difference between them is string "my $dbh = DBI->connect...";
> > I use Apche::DBI but without this module the same thing happens.
> > Why?
> >
> > 1st:
> > package Apache::StripSession
> > use strict;
> > use Apache;
> > use Apache::Constants qw(:common);
> >
> > sub handler {
> > my $r = shift;
> >
> > return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;
> >
> > $r->subprocess_env(SESSION => $1);
> > $r->uri($2);
> >
> > return DECLINED;
> > }
> >
> > 2nd:
> > package Apache::StripSession;
> > use strict;
> > use Apache;
> > use Apache::Constants qw(:common);
> >
> > sub handler {
> > my $r = shift;
> >
> > my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> > $dbh->disconnect;
> > return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;
> >
> > $r->subprocess_env(SESSION => $1);
> > $r->uri($2);
> >
> > return DECLINED;
> > }
> >
> >
> 
> 


RE: Problem with PerlTransHandler

2003-06-27 Thread csebe
Have you tried to comment out the 2 DBI lines like this:

#my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
#$dbh->disconnect;

and is still not working? You really need the database connection?

Lian


> -Original Message-
> From: Sergey V. Stashinskas [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 27, 2003 1:48 PM
> To: [EMAIL PROTECTED]
> Subject: Problem with PerlTransHandler
>
>
> Hi all,
>
> Excuse me for my poor English because I'm from Russia.
>
> I have the problem with url translation.
> There are 2 scripts to do it.
> 1st script work perfectly, but 2nd failed.
> Only difference between them is string "my $dbh = DBI->connect...";
> I use Apche::DBI but without this module the same thing happens.
> Why?
>
> 1st:
> package Apache::StripSession
> use strict;
> use Apache;
> use Apache::Constants qw(:common);
>
> sub handler {
> my $r = shift;
>
> return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;
>
> $r->subprocess_env(SESSION => $1);
> $r->uri($2);
>
> return DECLINED;
> }
>
> 2nd:
> package Apache::StripSession;
> use strict;
> use Apache;
> use Apache::Constants qw(:common);
>
> sub handler {
> my $r = shift;
>
> my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> $dbh->disconnect;
> return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;
>
> $r->subprocess_env(SESSION => $1);
> $r->uri($2);
>
> return DECLINED;
> }
>
>



Re[2]: Problem with PerlTransHandler

2003-06-27 Thread "Sergey V . Stashinskas"
DBI->connect is working ok.
Strange problem is with regexp.
If "DBI->connect ..." string is present in script then $1 ok but $2 is undefined.
Otherwise $1 and $2 have real normal values.


-Original Message-
From: Thomas Klausner <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Date: Fri, 27 Jun 2003 14:56:22 +0200
Subject: Re: Problem with PerlTransHandler

> 
> Hi!
> 
> On Fri, Jun 27, 2003 at 02:47:45PM +0400, "Sergey V. Stashinskas"  wrote:
> 
> > sub handler {
> > my $r = shift;
> > 
> > my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> > $dbh->disconnect;
> 
> maybe the DBI->connect isn't working and thus your script dies / throws some
> error ? 
> 
> I'd try to check if connect works, if $dbh works, etc.
> 
> -- 
> #!/usr/bin/perl   http://domm.zsi.at
> for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
> 


Re: Problem with PerlTransHandler

2003-06-27 Thread Thomas Klausner
Hi!

On Fri, Jun 27, 2003 at 02:47:45PM +0400, "Sergey V. Stashinskas"  wrote:

> sub handler {
> my $r = shift;
> 
> my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
> $dbh->disconnect;

maybe the DBI->connect isn't working and thus your script dies / throws some
error ? 

I'd try to check if connect works, if $dbh works, etc.

-- 
#!/usr/bin/perl   http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}


Problem with PerlTransHandler

2003-06-27 Thread "Sergey V . Stashinskas"
Hi all,

Excuse me for my poor English because I'm from Russia.

I have the problem with url translation.
There are 2 scripts to do it.
1st script work perfectly, but 2nd failed.
Only difference between them is string "my $dbh = DBI->connect...";
I use Apche::DBI but without this module the same thing happens.
Why?

1st:
package Apache::StripSession
use strict;
use Apache;
use Apache::Constants qw(:common);

sub handler {
my $r = shift;

return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;

$r->subprocess_env(SESSION => $1);
$r->uri($2);

return DECLINED;
}

2nd:
package Apache::StripSession;
use strict;
use Apache;
use Apache::Constants qw(:common);

sub handler {
my $r = shift;

my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
$dbh->disconnect;
return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;

$r->subprocess_env(SESSION => $1);
$r->uri($2);

return DECLINED;
}




Re: mod_perl PerlTransHandler weirdness

2003-06-20 Thread Aaron Ross
just fyi, mod_rewrite should be capable of handling those tests. See the
file tests under
http://httpd.apache.org/docs-2.1/en/mod/mod_rewrite.html#rewritecond

HTH, Aaron


On Tue, 2003-06-17 at 08:56, Joel Bernstein wrote:
> Alternatively, can anybody suggest a different way to offer this
> functionality? I don't think mod_rewrite applies, since the tests are
> too complicated, but would stand corrected if somebody knows
> different...
> 
> I posted this to london.pm earlier and had no joy.
> 
> /joel, getting a bit desperate.
-- 
Aaron Ross  
   company . Alias I, Inc 
  mail . 10 East 39th Street
 New York, NY 10016
 email . [EMAIL PROTECTED]
 phone . 212 696 0690
   fax . 212 696 0626
  cell . 917 753 2323




Re: mod_perl PerlTransHandler weirdness

2003-06-17 Thread Geoffrey Young


Joel Bernstein wrote:
Hi,

I would not be surprised if this problem has arisen due to me expecting
more from Apache+mod_perl than it's capable of.
The server is running Apache 1.3.mumble with mod_perl and mod_php. The
site has been entirely built in PHP, by somebody else. They want the
facility for http://foo.bar.com/david to redirect to
http://foo.bar.com/?page=publicprofile.php&name=david .
the secret to the PerlTransHandler is this: it is there to make the URI into a file.

so, if you deconstruct the URI to a point where you know which real file you want to serve 
(at a filesystem level, that is, like /usr/local/apache/htdocs/foo.html) then set 
$r->filename and return OK.

otherwise, what you want to do is set $r->uri to the relative URI you want Apache to 
deconstruct and return DECLINED.  the default Apache trans handler will then map it to a 
filename for you.  Apache will also take care of directories, non-files (like URIs such as 
/server-status which do not map to files) and so on.

so, given http://foo.bar.com/?page=publicprofile.php&name=david you might want to really 
execute http://foo.bar.com/publicprofile.php?name=david, right?  so, parse the incoming 
$uri and set $r->uri to '/publicprofile.php?name=david' and return DECLINED.

now, if publicprofile.php is not running as PHP it means that mod_php is not set up 
properly - perhaps you not used AddHandler to specify .php files as mod_php scripts, or 
perhaps have used SetHandler to override the default handler for the  that 
governs.  the way to test this is to request the resulting uri 
(/publicprofile.php?name=david) and see if it works without your trans handler.  once that 
works, just insert the trans handler and try again.


It was suggested that path_info may not be available
yet by the trans phase.
yup.  $r->path_info is what is left over from the URI once the URI is mapped to a file or 
, so it should be empty until after translation (and possibly empty after as well).

HTH

--Geoff



Re: mod_perl PerlTransHandler weirdness

2003-06-17 Thread Aaron Trevena
On Tue, 2003-06-17 at 13:56, Joel Bernstein wrote:
> Alternatively, can anybody suggest a different way to offer this
> functionality? I don't think mod_rewrite applies, since the tests are
> too complicated, but would stand corrected if somebody knows
> different...

Have you tried moving the index.php out of root into a directory
(virtual or otherwise) where all content is passed thru mod_php - can't
remember the settings off the top of my head.

or you could use an internal redirect so that apache treats the new url
as a new request and starts from the beginning of its cycle.

hth,

A.

-- 
Aaron Trevena, BSc (Hons) --- Software Engineer
Tusker Direct :: www.tuskerdirect.com




Re: mod_perl PerlTransHandler weirdness

2003-06-17 Thread Joel Bernstein
Alternatively, can anybody suggest a different way to offer this
functionality? I don't think mod_rewrite applies, since the tests are
too complicated, but would stand corrected if somebody knows
different...

I posted this to london.pm earlier and had no joy.

/joel, getting a bit desperate.


mod_perl PerlTransHandler weirdness

2003-06-17 Thread Joel Bernstein
Hi,

I would not be surprised if this problem has arisen due to me expecting
more from Apache+mod_perl than it's capable of.

The server is running Apache 1.3.mumble with mod_perl and mod_php. The
site has been entirely built in PHP, by somebody else. They want the
facility for http://foo.bar.com/david to redirect to
http://foo.bar.com/?page=publicprofile.php&name=david .

As I understand it, this needs to run at the URI Translation stage in
Apache, which is exposed thru mod_perl via PerlTransHandlers. In the
event that the request doesn't match these criteria, it needs to return
control to Apache in order that the page gets served as normal (through
mod_php). Without the handler in place, this all works, but the /david
form doesn't, since there's no code in place to do it.

Basically, I have a handler Apache::Publicprofile::Redirector::handler()
which is in Apache/Publicprofile/Redirector.pm

It is loaded in the site Apache config like:

##begin apache config excerpt##
[ inside a VirtualHost block, outside Location block ]

PerlModule Apache::Publicprofile::Redirector

SetHandler perl-script
PerlTransHandler Apache::Publicprofile::Redirector
PerlSendHeader Off
##end apache config excerpt##

I'm attaching the module, with a slight change to remove the actual
webserver details, as requested by the guy whose project this is. I hope
the code is self-explanatory, please query any bits that aren't.

Currently, the behaviour exhibited is as follows:

In any case, regardless of whether the handler is returning OK or
DECLINED, Apache tries to serve the *source* of /index.php - ie without
running it through mod_php.

Is the issue perhaps that PerlTransHandler is the wrong stage to run at?
Is it even possible to do what they want to do?

FWIW, changing $r->path_info to $r->uri changes from 404 Not Found to
400 Bad Request. It was suggested that path_info may not be available
yet by the trans phase.

Any help _much_ appreciated - I'm lost here!

/joel

-- 
S. Joel Bernstein
joel at fysh dot org


Apache-Publicprofile-Redirector.pm
Description: Perl program


Re: the perl Script called from perlTranshandler seems to besynchronized

2003-01-21 Thread Randy Kobes
On Wed, 22 Jan 2003, Db-Doc SP wrote:

> 
> > Hello All,
> >
> > I am having a peculiar problem it seems that only one request
> > can be serviced at a time while using mod_perl
> > (perlTransHandler).
> >
> > we are using
> >
> > Apache 1.3.26
> > mod_perl
> >
> > It seems as though when I use mod_perl apache can handle only
> > one request at a time. If the first request takes say 10
> > minutes to get response, during this 10 minutes all other
> > requests are blocked, and are handled only after the first
> > request is successfully processed and response sent out

Would this happen to be on Win32? If so, you're probably
running into the mod_perl 1.0 multithreading issues - see
   http://perl.apache.org/docs/1.0/os/win32/multithread.html
and then
   http://perl.apache.org/docs/2.0/os/win32/install.html
for information on installing mod_perl 2.0 to avoid this
problem.

-- 
best regards,
randy kobes




Re: the perl Script called from perlTranshandler seems to be synchronized

2003-01-21 Thread Db-Doc SP

> Hello All,
>
> I am having a peculiar problem it seems that only one request can be serviced at a 
>time while using  mod_perl (perlTransHandler).
>
> we are using
>
> Apache 1.3.26
> mod_perl
>
> It seems as though when I use mod_perl apache can handle only one request at a time.
> If the first request takes say 10 minutes to get response, during this 10 minutes 
>all other requests are blocked,
> and are handled only after the first request  is successfully processed and response 
>sent out
>
>
> This is very important for us to decide if we want to use mod_perl. please advise.
>
> Your help will be much appreciated.
>
> regards
>   Harsha Yale
>
>
>
>
>
>
> --
>
> This e-mail may contain confidential and/or privileged information. If you are not 
>the intended recipient (or have received this e-mail in error) please notify the 
>sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
>distribution of the material in this e-mail is strictly forbidden.



--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.





Re: mod_rewrite + PerlTransHandler

2003-01-20 Thread cowsgoesm00
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Mon, 20 Jan 2003 10:10:36 +1100, Stas Bekman wrote:
>Not in mod_perl 1.0. Your best bet is probably to move the
>mod_rewrite's
>rules into your perl transhandler.

or maybe just have mod_rewrite take precedence over mod_perl, by
having LoadModule mod_rewrite after mod_perl's?

cheers,
<[EMAIL PROTECTED]> - wa1800z@DALnet&CAiRC - #32741432
KeyID 0xDE9EB50B - D0D87CA98916CBB258AC 77FB91E0DA95DE9EB50B

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE+K9+4keDald6etQsRAid0AJ48NUaxGwFIwDw9Kzfq0AVwTZ1bVgCfdgwe
tnAu1NE/HanCb4RKIw/b6s0=
=uVGf
-END PGP SIGNATURE-




Re: mod_rewrite + PerlTransHandler

2003-01-19 Thread Stas Bekman
Torsten Foertsch wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I am trying to get a PerlTransHandler called *after* some mod_rewrite 
processing.

I thought if I configure the rewrite rules *before* the PerlTransHandler:

RewriteEngine   On
RewriteRule	...	[PT]
PerlTransHandler Apache::TestTrans::transhandler

it would work that way. But it does not.

&Apache::TestTrans::transhandler is always called *before* mod_rewrite 
processing.

Is there a way to determine the handler order?

Not in mod_perl 1.0. Your best bet is probably to move the mod_rewrite's 
rules into your perl transhandler.

It should be possible in 2.0, though the API is not there yet. Apache 2.0 
allows to insert handlers before/after a specified handler + other options.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



mod_rewrite + PerlTransHandler

2003-01-19 Thread Torsten Foertsch
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I am trying to get a PerlTransHandler called *after* some mod_rewrite 
processing.

I thought if I configure the rewrite rules *before* the PerlTransHandler:

RewriteEngine   On
RewriteRule ... [PT]
PerlTransHandler Apache::TestTrans::transhandler

it would work that way. But it does not.

&Apache::TestTrans::transhandler is always called *before* mod_rewrite 
processing.

Is there a way to determine the handler order?

Thanks
Torsten
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+Kt+/wicyCTir8T4RAqmNAJsGfm6CaPueSjCRAIA/BZ1BgWtxxACfWCLY
GAo8nB1xxL1r+7blx7+qbi8=
=473P
-END PGP SIGNATURE-



Re: Session managing using PerlTransHandler

2002-11-22 Thread Enrico Sorcinelli
On Fri, 22 Nov 2002 19:09:25 +0200
[EMAIL PROTECTED] wrote:

> How I Can redirect to page http://foo.bar/ses1/index.html from  PerlTransHandler 
>Module?

Hi,
the description of your problem is very... short.
The chapter 5 of 'eagle' book explain how to put and strip session ID
on the left to the left of the URI.

Moreover, the Apache::SessionManager module does things transparently for you.
It works in PerlTransHandler phase.
(http://www.cpan.org/modules/by-module/Apache/Apache-SessionManager-0.04.tar.gz)

Bye

- Enrico
 




Session managing using PerlTransHandler

2002-11-22 Thread dima
How I Can redirect to page http://foo.bar/ses1/index.html from  PerlTransHandler 
Module?






Re: PerlTransHandler problem

2002-06-13 Thread darren chamberlain

* Rasoul Hajikhani <[EMAIL PROTECTED]> [2002-06-12 19:12]:
> Hello folks,
> I am trying to implement a simple PerlTransHandler to change:
> 
> http://myserver/
> 
> to 
> 
> http://myserver.rhythm.com/
> 
> And here is my code:

[-- snip --]

Have you seen <http://httpd.apache.org/docs/misc/rewriteguide.html>? The
first section is about URL layout, and the first example is about
canonicalizing URLs.

(darren)

-- 
It has long been an axiom of mine that the little things are
infinitely the most important.
-- Arthur Conan Coyle



Re: PerlTransHandler problem

2002-06-12 Thread Nick Tonkin


mod_rewrite is going to be faster for this and easier to implement, I'd
say.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^myserver\.rhythm\.com [NC]
RewriteRule ^/(.*) http://myserver.rhythm.com/$1 [L,R]

in your httpd.conf will probably do the trick.

Of course this does't solve your conundrum vis a vis PerlTransHandler, but
it's a more elegant solution anyway, imho.

- nick

   
Nick Tonkin   {|8^)>


On Wed, 12 Jun 2002, Rasoul Hajikhani wrote:

> A funny thing is happening with my PerlTransHandler...
> It is not being called at all... :(
> I have added warn messages but they never appear in the error log.
> I am at a loss and hoping that some one may have an answer...
> -r
> 
> Lyle Brooks wrote:
> > 
> > Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
> > > Hello folks,
> > > I am trying to implement a simple PerlTransHandler to change:
> > >
> > > http://myserver/
> > >
> > > to
> > >
> > > http://myserver.rhythm.com/
> > >
> > > And here is my code:
> > >
> > > package MIS::GENERAL::FixURL;
> > >
> > > use Apache::Constants qw(DECLINED);
> > >
> > > use strict;
> > >
> > > sub handler
> > > {
> > > my $r   = shift;
> > > my $uri = $r->uri;
> > >
> > > return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)
> > 
> > IIRC, the $r->uri method is normally not going yield the hostname or
> > scheme (unless this is a proxy request).
> > 
> > So for a request to http://www.rhythm.com/test/myfile.html
> > 
> > $r->uri is going to return only
> > 
> > /test/myfile.html
> > 
> > You may want to do some logging to verify.
> > 
> > Add
> > 
> > use Apache::Log ();
> > 
> > then inside your handler...
> > 
> > my $log = $r->server->log;
> > 
> > $log->debug("Processing request " . $r->uri);
> > 
> > Hope that helps.
> > 
> > >
> > > $uri=~ s/^(.+)/$1\.rhythm\.com/;
> > > $r->uri($uri);
> > >
> > > return DECLINED;
> > > }
> > >
> > > 1;
> > >
> > > Here is my https.conf entry:
> > > PerlTransHandler MIS::GENERAL::FixURL
> > >
> > > And here is my error when I type: s7.rhythm.com
> > >
> > > Invalid URI in request GET / HTTP/1.0
> > >
> > > But I get no error with: http://s7/
> > >
> > > Can some one tell me what am I doing wrong?
> > >
> > > Thanks in advance
> > > -r
> 




Re: PerlTransHandler problem

2002-06-12 Thread simran

What it sounds like you want is: 

PerlTransHandler Whatever::CheckName

and in CheckName.pm

sub handler {
  my $r = instance Apache::Request(shift);

  if ($r->hostname !~ /rhythm\.com/) {
$r->header_out("Location" => "http://myserver.rhythm.com".$r->uri);
return REDIRECT;
  }
  else {
redirect DECLINED;
  }
}

---

A redirect rule (using the Rewrite Engine) would probably be easier and
better yet. 

simran.



> > > Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
> > > > Hello folks,
> > > > I am trying to implement a simple PerlTransHandler to change:
> > > >
> > > > http://myserver/
> > > >
> > > > to
> > > >
> > > > http://myserver.rhythm.com/
> > > >
> > > > And here is my code:
> > > >
> > > > package MIS::GENERAL::FixURL;
> > > >
> > > > use Apache::Constants qw(DECLINED);
> > > >
> > > > use strict;
> > > >
> > > > sub handler
> > > > {
> > > > my $r   = shift;
> > > > my $uri = $r->uri;
> > > >
> > > > return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)
> > > 
> > > IIRC, the $r->uri method is normally not going yield the hostname or
> > > scheme (unless this is a proxy request).
> > > 
> > > So for a request to http://www.rhythm.com/test/myfile.html
> > > 
> > > $r->uri is going to return only
> > > 
> > > /test/myfile.html
> > > 
> > > You may want to do some logging to verify.
> > > 
> > > Add
> > > 
> > > use Apache::Log ();
> > > 
> > > then inside your handler...
> > > 
> > > my $log = $r->server->log;
> > > 
> > > $log->debug("Processing request " . $r->uri);
> > > 
> > > Hope that helps.
> > > 
> > > >
> > > > $uri=~ s/^(.+)/$1\.rhythm\.com/;
> > > > $r->uri($uri);
> > > >
> > > > return DECLINED;
> > > > }
> > > >
> > > > 1;
> > > >
> > > > Here is my https.conf entry:
> > > > PerlTransHandler MIS::GENERAL::FixURL
> > > >
> > > > And here is my error when I type: s7.rhythm.com
> > > >
> > > > Invalid URI in request GET / HTTP/1.0
> > > >
> > > > But I get no error with: http://s7/
> > > >
> > > > Can some one tell me what am I doing wrong?
> > > >
> > > > Thanks in advance
> > > > -r
> 
> 




Re: PerlTransHandler problem

2002-06-12 Thread Lyle Brooks

Quoting Lyle Brooks ([EMAIL PROTECTED]):
> Sounds like it's more of a DNS issue than a modperl issue.
> 
> Depending on what your motivation for requiring the full name, you
> may also explicitly set
> 
> ServerName  myserver.rhythm.com
> UseCanonicalName off

errr... should be

UseCanonicalName On


>  
> Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
> > I am realy trying to make sure that all requests for 
> > http://myserver/
> > are treated as
> > http://myserver.rhythm.com/
> > so that my other applications that depend on reading cookies down the
> > request chain could actually do so...
> > -r
> > 
> > "Randal L. Schwartz" wrote:
> > > 
> > > >>>>> "Rasoul" == Rasoul Hajikhani <[EMAIL PROTECTED]> writes:
> > > 
> > > Rasoul> I am trying to implement a simple PerlTransHandler to change:
> > > 
> > > Rasoul> http://myserver/
> > > 
> > > Rasoul> to
> > > 
> > > Rasoul> http://myserver.rhythm.com/
> > > 
> > > Both of those are "/" as far as as $r->uri is concerned.
> > > 
> > > What are you *really* trying to do?
> > > 
> > > --
> > > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> > > <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
> > > Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> > > See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: PerlTransHandler problem

2002-06-12 Thread Lyle Brooks

Sounds like it's more of a DNS issue than a modperl issue.

Depending on what your motivation for requiring the full name, you
may also explicitly set

ServerName  myserver.rhythm.com
UseCanonicalName off
 
Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
> I am realy trying to make sure that all requests for 
> http://myserver/
> are treated as
> http://myserver.rhythm.com/
> so that my other applications that depend on reading cookies down the
> request chain could actually do so...
> -r
> 
> "Randal L. Schwartz" wrote:
> > 
> > >>>>> "Rasoul" == Rasoul Hajikhani <[EMAIL PROTECTED]> writes:
> > 
> > Rasoul> I am trying to implement a simple PerlTransHandler to change:
> > 
> > Rasoul> http://myserver/
> > 
> > Rasoul> to
> > 
> > Rasoul> http://myserver.rhythm.com/
> > 
> > Both of those are "/" as far as as $r->uri is concerned.
> > 
> > What are you *really* trying to do?
> > 
> > --
> > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> > <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
> > Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> > See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: PerlTransHandler problem

2002-06-12 Thread Lyle Brooks

You are only going to have Transhandlers defined in the main server or
virtual host, not in any  or  containers.

Check and see if you have any other Transhandlers defined earlier in
your httpd.conf file.   If an earlier Transhandler returns OK, then
later ones won't be called.

Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
> A funny thing is happening with my PerlTransHandler...
> It is not being called at all... :(
> I have added warn messages but they never appear in the error log.
> I am at a loss and hoping that some one may have an answer...
> -r
> 
> Lyle Brooks wrote:
> > 
> > Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
> > > Hello folks,
> > > I am trying to implement a simple PerlTransHandler to change:
> > >
> > > http://myserver/
> > >
> > > to
> > >
> > > http://myserver.rhythm.com/
> > >
> > > And here is my code:
> > >
> > > package MIS::GENERAL::FixURL;
> > >
> > > use Apache::Constants qw(DECLINED);
> > >
> > > use strict;
> > >
> > > sub handler
> > > {
> > > my $r   = shift;
> > > my $uri = $r->uri;
> > >
> > > return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)
> > 
> > IIRC, the $r->uri method is normally not going yield the hostname or
> > scheme (unless this is a proxy request).
> > 
> > So for a request to http://www.rhythm.com/test/myfile.html
> > 
> > $r->uri is going to return only
> > 
> > /test/myfile.html
> > 
> > You may want to do some logging to verify.
> > 
> > Add
> > 
> > use Apache::Log ();
> > 
> > then inside your handler...
> > 
> > my $log = $r->server->log;
> > 
> > $log->debug("Processing request " . $r->uri);
> > 
> > Hope that helps.
> > 
> > >
> > > $uri=~ s/^(.+)/$1\.rhythm\.com/;
> > > $r->uri($uri);
> > >
> > > return DECLINED;
> > > }
> > >
> > > 1;
> > >
> > > Here is my https.conf entry:
> > > PerlTransHandler MIS::GENERAL::FixURL
> > >
> > > And here is my error when I type: s7.rhythm.com
> > >
> > > Invalid URI in request GET / HTTP/1.0
> > >
> > > But I get no error with: http://s7/
> > >
> > > Can some one tell me what am I doing wrong?
> > >
> > > Thanks in advance
> > > -r



Re: PerlTransHandler problem

2002-06-12 Thread Rasoul Hajikhani

A funny thing is happening with my PerlTransHandler...
It is not being called at all... :(
I have added warn messages but they never appear in the error log.
I am at a loss and hoping that some one may have an answer...
-r

Lyle Brooks wrote:
> 
> Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
> > Hello folks,
> > I am trying to implement a simple PerlTransHandler to change:
> >
> > http://myserver/
> >
> > to
> >
> > http://myserver.rhythm.com/
> >
> > And here is my code:
> >
> > package MIS::GENERAL::FixURL;
> >
> > use Apache::Constants qw(DECLINED);
> >
> > use strict;
> >
> > sub handler
> > {
> > my $r   = shift;
> > my $uri = $r->uri;
> >
> > return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)
> 
> IIRC, the $r->uri method is normally not going yield the hostname or
> scheme (unless this is a proxy request).
> 
> So for a request to http://www.rhythm.com/test/myfile.html
> 
> $r->uri is going to return only
> 
> /test/myfile.html
> 
> You may want to do some logging to verify.
> 
> Add
> 
> use Apache::Log ();
> 
> then inside your handler...
> 
> my $log = $r->server->log;
> 
> $log->debug("Processing request " . $r->uri);
> 
> Hope that helps.
> 
> >
> > $uri=~ s/^(.+)/$1\.rhythm\.com/;
> > $r->uri($uri);
> >
> > return DECLINED;
> > }
> >
> > 1;
> >
> > Here is my https.conf entry:
> > PerlTransHandler MIS::GENERAL::FixURL
> >
> > And here is my error when I type: s7.rhythm.com
> >
> > Invalid URI in request GET / HTTP/1.0
> >
> > But I get no error with: http://s7/
> >
> > Can some one tell me what am I doing wrong?
> >
> > Thanks in advance
> > -r



Re: PerlTransHandler problem

2002-06-12 Thread Rasoul Hajikhani

I am realy trying to make sure that all requests for 
http://myserver/
are treated as
http://myserver.rhythm.com/
so that my other applications that depend on reading cookies down the
request chain could actually do so...
-r

"Randal L. Schwartz" wrote:
> 
> >>>>> "Rasoul" == Rasoul Hajikhani <[EMAIL PROTECTED]> writes:
> 
> Rasoul> I am trying to implement a simple PerlTransHandler to change:
> 
> Rasoul> http://myserver/
> 
> Rasoul> to
> 
> Rasoul> http://myserver.rhythm.com/
> 
> Both of those are "/" as far as as $r->uri is concerned.
> 
> What are you *really* trying to do?
> 
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: PerlTransHandler problem

2002-06-12 Thread Randal L. Schwartz

>>>>> "Rasoul" == Rasoul Hajikhani <[EMAIL PROTECTED]> writes:

Rasoul> I am trying to implement a simple PerlTransHandler to change:

Rasoul> http://myserver/

Rasoul> to 

Rasoul> http://myserver.rhythm.com/

Both of those are "/" as far as as $r->uri is concerned.

What are you *really* trying to do?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: PerlTransHandler problem

2002-06-12 Thread Lyle Brooks



Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
> Hello folks,
> I am trying to implement a simple PerlTransHandler to change:
> 
> http://myserver/
> 
> to 
> 
> http://myserver.rhythm.com/
> 
> And here is my code:
> 
> package MIS::GENERAL::FixURL;
> 
> use Apache::Constants qw(DECLINED);
> 
> use strict;
> 
> sub handler
> {
> my $r   = shift;
> my $uri = $r->uri;
> 
> return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)

IIRC, the $r->uri method is normally not going yield the hostname or 
scheme (unless this is a proxy request).

So for a request to http://www.rhythm.com/test/myfile.html 

$r->uri is going to return only

/test/myfile.html


You may want to do some logging to verify.

Add  

use Apache::Log ();

then inside your handler...

my $log = $r->server->log;

$log->debug("Processing request " . $r->uri);


Hope that helps.

> 
> $uri=~ s/^(.+)/$1\.rhythm\.com/;
> $r->uri($uri);
> 
> return DECLINED;
> }
> 
> 1;
> 
> Here is my https.conf entry:
> PerlTransHandler MIS::GENERAL::FixURL
> 
> And here is my error when I type: s7.rhythm.com
> 
> Invalid URI in request GET / HTTP/1.0
> 
> But I get no error with: http://s7/
> 
> Can some one tell me what am I doing wrong?
> 
> Thanks in advance
> -r



PerlTransHandler problem

2002-06-12 Thread Rasoul Hajikhani

Hello folks,
I am trying to implement a simple PerlTransHandler to change:

http://myserver/

to 

http://myserver.rhythm.com/

And here is my code:

package MIS::GENERAL::FixURL;

use Apache::Constants qw(DECLINED);

use strict;

sub handler
{
my $r   = shift;
my $uri = $r->uri;

return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)

$uri=~ s/^(.+)/$1\.rhythm\.com/;
$r->uri($uri);

return DECLINED;
}

1;

Here is my https.conf entry:
PerlTransHandler MIS::GENERAL::FixURL

And here is my error when I type: s7.rhythm.com

Invalid URI in request GET / HTTP/1.0

But I get no error with: http://s7/

Can some one tell me what am I doing wrong?

Thanks in advance
-r



Re: %ENV via PerlTransHandler

2001-06-13 Thread Doug MacEachern

On Wed, 21 Mar 2001, Paul Evad wrote:

> question: how does one access the environment variables when using 
> mod_perl as a transhandler?
> 
> I notice that
> 
> $r->subprocess_env->do(sub {
>   my($key, $value) = @_;
>   $r->warn("$key => $value\n");
>   1;
>});
> 
> gives two different sets of results when used via a transhandler or via
> 
> PerlTransHandler Apache::Kudos::Test # yields near to nothing in subprocess_env

%ENV is normally not setup until later on, you can make it happen sooner
by calling subprocess_env in a void context:

$r->subprocess_env;






RE: %ENV via PerlTransHandler

2001-03-21 Thread Geoffrey Young



-Original Message-
From: Paul Evad
To: [EMAIL PROTECTED]
Sent: 3/21/01 1:36 PM
Subject: %ENV via PerlTransHandler
>
>question: how does one access the environment variables when using 
>mod_perl as a transhandler?
>

what kind of stuff are you expecting HTTP_REFERER and company via
PerlSetupEnv On?  I'm not sure, but maybe this gets populated after
translation (which might make sense since it is unknown that the file is a
cgi script until after translation).  haven't checked it, though, and I
stopped relying on those long ago...

--Geoff



RE: %ENV via PerlTransHandler

2001-03-21 Thread Rob Bloodgood

> question: how does one access the environment variables when using
> mod_perl as a transhandler?
[ SNIP transhandler vs content handler diffs ]
> Is there a better way to get at ENV stuff than subprocess_env?

The setup of %ENV is a convenience for CGI programmers.  In fact, other than
loading/caching scripts, most of what Apache::Registry does is emulate the
CGI environment by setting up the %ENV hash and STDIN/STDOUT.

But the information that is placed into %ENV is all copied from the request
record (which is normally not available to CGI scripts), e.g.:

sub handler {
   my $r = shift;

   # $ENV{REMOTE_ADDR}
   print $r->connection->remote_addr;

   # $ENV{DOCUMENT_ROOT}
   print $r->document_root;

   # $ENV{REQUEST_URI}
   print $r->uri;
}

These methods are all documented in the various mod_perl/Apache::*, plus the
guide, plus the Quick Reference card lists them.

Hope this helps!

L8r,
Rob




%ENV via PerlTransHandler

2001-03-21 Thread Paul Evad

question: how does one access the environment variables when using 
mod_perl as a transhandler?

I notice that

$r->subprocess_env->do(sub {
  my($key, $value) = @_;
  $r->warn("$key => $value\n");
  1;
   });

gives two different sets of results when used via a transhandler or via

PerlTransHandler Apache::Kudos::Test # yields near to nothing in subprocess_env



   SetHandler perl-script
   PerlHandler Apache::Tutorial::First


The above does give the full ENV variables I would have expected.

Is there a better way to get at ENV stuff than subprocess_env?

- paul
-- 

- Kudosnet Technologies Inc. -
Support: [EMAIL PROTECTED]
Accounts: [EMAIL PROTECTED]
Sales: [EMAIL PROTECTED]
 1-877-885-8367 --



Re: Replacing mod_prewrite with a PerlTransHandler

2000-11-16 Thread Tom Mornini

On 15 Nov 2000, David Hodgkinson wrote:

> Geoffrey Young <[EMAIL PROTECTED]> writes:
> 
> > Perhaps that would make for a good talk ;)
> 
> mod_rewrite recovery?
> 
> Ok seriously then, we're proposing replacing a lite apache and
> mod_rewrite with a slightly heavier, but presumably highly shared
> mod_perled apache at the front end.
> 
> Measurements anyone?

Perhaps, as others have suggested, mod_backhand makes this moot.

If not, then I can tell you that on Linux, I was able to make a
light-weight front-end that was 1/3 the RSS of a mod_perl backend without
any modules loaded. Adding modules would make the back-end even heavier.

-- 
-- Tom Mornini
-- InfoMania Printing and Prepress




Replacing mod_prewrite with a PerlTransHandler Was: Re: [ANNOUNCE] ApacheCon USA 2001: Call For Papers

2000-11-15 Thread David Hodgkinson

Geoffrey Young <[EMAIL PROTECTED]> writes:

> Perhaps that would make for a good talk ;)

mod_rewrite recovery?

Ok seriously then, we're proposing replacing a lite apache and
mod_rewrite with a slightly heavier, but presumably highly shared
mod_perled apache at the front end.

Measurements anyone?

-- 
Dave Hodgkinson, http://www.hodgkinson.org
Editor-in-chief, The Highway Star   http://www.deep-purple.com
  Apache, mod_perl, MySQL, Sybase hired gun for, well, hire
  -



RE: PerlTransHandler and CGI.pm

2000-06-07 Thread Eric Jain

Got it... Seems like the query string is decoded twice: Therefore

http://biodoc.ch/de/search;query=%252Btest+%252Bdna+-xyz

works perfectly, since all the '%' are encoded. Then it even works
with slashes :-)


--
Eric Jain


> When processing the url
> http://biodoc.ch/de/search?query=%2Btest+%2Bdna+-xyz ,
> $cgi->param('query') correctly returns '+test +dna -xyz'.
>
> But if I use http://biodoc.ch/de/search;query=%2Btest+%2Bdna+-xyz
> instead, I get ' test  dna -xyz'. If I include a %3F (=?)
> in the url,
> I even get a 404 error. Slashes too only work if they are
> not encoded.
>
> There must be something wrong in my PerlTransHandler, approximatly
> here:
>
>   my $uri = $r->uri();
>
>   if ( my($u1,$u2) = $uri =~ / ^ ([^?]+?) ; ([^?]*) $ /x )
>   {
>   $r->uri($u1);
>   $r->args($u2);
>   }
>
> But what?
>
> --
> Eric Jain
>




PerlTransHandler and CGI.pm

2000-06-07 Thread Eric Jain

When processing the url
http://biodoc.ch/de/search?query=%2Btest+%2Bdna+-xyz ,
$cgi->param('query') correctly returns '+test +dna -xyz'.

But if I use http://biodoc.ch/de/search;query=%2Btest+%2Bdna+-xyz
instead, I get ' test  dna -xyz'. If I include a %3F (=?) in the url,
I even get a 404 error. Slashes too only work if they are not encoded.

There must be something wrong in my PerlTransHandler, approximatly
here:

my $uri = $r->uri();

if ( my($u1,$u2) = $uri =~ / ^ ([^?]+?) ; ([^?]*) $ /x )
{
$r->uri($u1);
$r->args($u2);
}

But what?

--
Eric Jain




Re: PerlTransHandler

2000-05-25 Thread Doug MacEachern

On Thu, 25 May 2000, Sergey Ivanyuk wrote:

> package handler;
> 
> use Apache;
> 
> sub handler {
> return DECLINED;
> }

where does DECLINED come from?  watch what happens if you add 'print
handler()' and run it from the command line, and watch what happens when
you add 'use strict;'.  adding 'use Apache::Constants qw(DECLINED)' will
fix your problem.




Re: PerlTransHandler

2000-05-25 Thread Sergey Ivanyuk

> > I'm having problems with the PerlTransHandler handler.  I would like
> > to only translate some requests, but keep Aliases working.  However, I
> > just can't get that done.  If I use a simple 'return DECLINED;', all
> > my cgi scripts and aliases directories return 'Not found'.  I know the
> > handler is executed, and if I remove it from httpd.conf, everything
> > works fine.  What am I doing wrong?  Should a simple 'return
> > DECLINED;' run default handlers, or am I missing something?  Thanks in
> > advance.
> 
> return DECLINED; should work fine.  can you post a tiny example config and
> handler?  Apache::ShowRequest (part of the Apache::Module package on CPAN)
> can also help debug this sort of problem. 

A little more information.  Originally, I was trying this on Redhat
5.2, now just tried it on 6.2 with stock apache and stock mod_perl.
Same result. 

I've added the line marked by + to the default httpd.conf:
--

+  PerlTransHandler handler
  Alias /perl/ /home/httpd/perl/
  
SetHandler perl-script
--

This is my handler.pm:

--
#!/usr/bin/perl

package handler;

use Apache;

sub handler {
return DECLINED;
}

1;
--

With this config, no requests work.  Not even a request to the root of
the server, which has the default apache test page installed.  If I
remove the PerlTransHandler line from the config and restart apache,
everything works.

There are the stats from the box I've tried it on:

--
[modemch@rabox4 modemch]$ rpm -qa | grep 'apache\|mod_perl'
apache-1.3.12-2
mod_perl-1.21-10
[modemch@rabox4 modemch]$ uname -a
Linux rabox4.eventsdigital.com 2.2.14-5.0 #1 Tue Mar 7 20:53:41 EST 2000 i586 unknown
[modemch@rabox4 modemch]$ cat /etc/issue

Red Hat Linux release 6.2 (Zoot)
Kernel 2.2.14-5.0 on an i586

[modemch@rabox4 modemch]$ 
--

I really really need to get to the bottom of this.  Thanks for all your help.





Re: PerlTransHandler

2000-05-25 Thread Doug MacEachern

On Thu, 25 May 2000, Sergey Ivanyuk wrote:

> Hi All. 
> 
> I'm having problems with the PerlTransHandler handler.  I would like
> to only translate some requests, but keep Aliases working.  However, I
> just can't get that done.  If I use a simple 'return DECLINED;', all
> my cgi scripts and aliases directories return 'Not found'.  I know the
> handler is executed, and if I remove it from httpd.conf, everything
> works fine.  What am I doing wrong?  Should a simple 'return
> DECLINED;' run default handlers, or am I missing something?  Thanks in
> advance.

return DECLINED; should work fine.  can you post a tiny example config and
handler?  Apache::ShowRequest (part of the Apache::Module package on CPAN)
can also help debug this sort of problem. 




PerlTransHandler

2000-05-25 Thread Sergey Ivanyuk

Hi All. 

I'm having problems with the PerlTransHandler handler.  I would like
to only translate some requests, but keep Aliases working.  However, I
just can't get that done.  If I use a simple 'return DECLINED;', all
my cgi scripts and aliases directories return 'Not found'.  I know the
handler is executed, and if I remove it from httpd.conf, everything
works fine.  What am I doing wrong?  Should a simple 'return
DECLINED;' run default handlers, or am I missing something?  Thanks in
advance.




Re: PerlTransHandler question.

2000-05-23 Thread Randal L. Schwartz

>>>>> "Antonio" == Antonio Pascual <[EMAIL PROTECTED]> writes:

Antonio> I want handler a request only if the url is like http://localhost/idTrans=XXX
Antonio> In other case do the default behaviour.
Antonio> How could I do this?
Antonio> I suppose that I have to use PerlTransHandler, but I don't know how.

Nahh.  Use basic core functionality, in your top-level conf file:

http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



RE: PerlTransHandler question.

2000-05-23 Thread Geoffrey Young



time to pick up the Eagle book...
 
check out
http://www.modperl.com/
 
specifically
http://www.modperl.com/book/chapters/ch7.html#The_URI_Translation_Phase
 
HTH
 
--Geoff

  -Original Message-From: Antonio Pascual 
  [mailto:[EMAIL PROTECTED]]Sent: Tuesday, May 23, 2000 
  9:59 AMTo: [EMAIL PROTECTED]Subject: PerlTransHandler 
  question.
  I want handler a request only if the url is like 
  http://localhost/idTrans=XXX
  In other case do the default 
  behaviour.
  How could I do this?
  I suppose that I have to use PerlTransHandler, 
  but I don't know how.
   
  Thanks in advance.
   
  Antonio.


PerlTransHandler question.

2000-05-23 Thread Antonio Pascual



I want handler a request only if the url is like http://localhost/idTrans=XXX
In other case do the default 
behaviour.
How could I do this?
I suppose that I have to use PerlTransHandler, but 
I don't know how.
 
Thanks in advance.
 
Antonio.


Re: Getting ENV in PerlTransHandler

2000-05-12 Thread Doug MacEachern

On Mon, 8 May 2000, sadhanandham balaraman wrote:

> Hi,
> 
>   How do I get ENV variables values in my PerlTransHandler. I want to 
>know 
> the HTTP_USER_AGENT in my PerlTransHandler.

try staying away from %ENV unless you want cgi compat, which you can't
have for a transhandler of course.  try $r->headers_in->{'User-Agent'}





Getting ENV in PerlTransHandler

2000-05-08 Thread sadhanandham balaraman

Hi,

How do I get ENV variables values in my PerlTransHandler. I want to 
know 
the HTTP_USER_AGENT in my PerlTransHandler.

Please suggest me.

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com




RE: PerlTransHandler and sort of mapping

2000-04-07 Thread Eric Cholet

> hi,
> 
> I was wondering how to map PerlTransHandler only for certain type of files.
> ( I'm doing URI rewriting not URI->filename translation ?!!)
> 
> Something like :
> 
>  
>PerlTransHandler  Apache::MyHandler
>  
> 
> 
> Yes I know this is wrong...can this be done in some other way ?

Yes, it's wrong because the job of the translation phase is precisely to
translate from url to file, therefore it cannot operate on files!

PerlTransHandler Apache::MyHandler
...
sub handler
{
  my $r = shift;
  return DECLINED unless $r->uri =~ /\.xml$/;
  ...
}
--
Eric




PerlTransHandler and sort of mapping

2000-04-07 Thread raptor

hi,

I was wondering how to map PerlTransHandler only for certain type of files.
( I'm doing URI rewriting not URI->filename translation ?!!)

Something like :

 
   PerlTransHandler  Apache::MyHandler
 


Yes I know this is wrong...can this be done in some other way ?

Thanx
=
iVAN
[EMAIL PROTECTED]
=



Re: or PerlTransHandler directive for multiple /user/subd ir/action

2000-01-13 Thread Andre Landwehr

On Thu, Jan 13, 2000 at 06:08:33AM -0500, Clifford Lang wrote:
> 
> Which is best or right one to use?
> 
> I have thousands of user directories, with a sub of admin for them to
> configure their site. 
> 
> >From the admin location I want to call the "config" (module e.g.
> www.here.com/user/admin/config)
> 

There are examples for doing this with mod_rewrite which is maybe
the most simple solution. Look at
http://www.apache.org/docs/mod/mod_rewrite.html

Take care,
Andre



Re: or PerlTransHandler directive for multiple /user/subdir/action

2000-01-13 Thread Gerald Richter

>
> Which is best or right one to use?
>
> I have thousands of user directories, with a sub of admin for them to
> configure their site.
>
> >From the admin location I want to call the "config" (module e.g.
> www.here.com/user/admin/config)
>
> Can I write a  with wildcards as  then
> set my handler?
>

Take a look at 

Gerald


> Or should I write a PerlTransHandler for the whole site looking for a
match,
> then setting the perlhandler from there? Something like
>
> $r->url =~ m:^/(.+)/admin/config$/ || return DECLINED;
> $r->handler("perl-handler");
> $r->push_handlers(PerlHandler => \&new_handler);
> return DECLINED;
>
>
>
> TIA,  [EMAIL PROTECTED]
>



or PerlTransHandler directive for multiple /user/subdir/action

2000-01-13 Thread Clifford Lang


Which is best or right one to use?

I have thousands of user directories, with a sub of admin for them to
configure their site. 

>From the admin location I want to call the "config" (module e.g.
www.here.com/user/admin/config)

Can I write a  with wildcards as  then
set my handler?

Or should I write a PerlTransHandler for the whole site looking for a match,
then setting the perlhandler from there? Something like 

$r->url =~ m:^/(.+)/admin/config$/ || return DECLINED;
$r->handler("perl-handler");
$r->push_handlers(PerlHandler => \&new_handler);
return DECLINED;



TIA,  [EMAIL PROTECTED]



Re: setting query in PerlTransHandler

2000-01-09 Thread Ajay Shah


>
>I may be wrong, but I bet you have to do this instead:
>

But you aren't :)

>
>   $r->uri("/articles/index.html");
>   $r->args("id=$id");
>
>By the time the apache-request object has been created, args are
>handled in a separate slot.
>

That worked. Maybe this should be documented somewhere in the guide?

Thank you very much.

Ajay
__
Get Your Private, Free Email at http://www.hotmail.com



Re: setting query in PerlTransHandler

2000-01-09 Thread Randal L. Schwartz

> "Ajay" == Ajay Shah <[EMAIL PROTECTED]> writes:

Ajay> /articles/10/index.html  =>  /articles/index.html?id=10

Ajay> This is what I tried.

Ajay> sub handler {
Ajay> my $r = shift;
Ajay> my $uri = $r->uri;

Ajay> my ($id) = ($uri =~ m|^/articles/(.*?)/|);
Ajay> my $newuri = $r->document_root . "/articles/index.html";
Ajay> my $uriobj = $r->parsed_uri;
Ajay> $uriobj->query("id=$id");
Ajay> $r->uri($newuri);

Ajay> return OK;
Ajay> }

I may be wrong, but I bet you have to do this instead:


  $r->uri("/articles/index.html");
  $r->args("id=$id");

By the time the apache-request object has been created, args are
handled in a separate slot.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



setting query in PerlTransHandler

2000-01-09 Thread Ajay Shah

This maybe be repeated becuase I sent the first message via
Geo Crawlere and don't know how long they are going to take
to review the message. Sorry if it comes in twice.

I am writing a simple PerlTransHandler that is going to change
the request into another with query string.
The following is what I am looking for

/articles/10/index.html  =>  /articles/index.html?id=10

This is what I tried.

sub handler {
my $r = shift;
my $uri = $r->uri;

my ($id) = ($uri =~ m|^/articles/(.*?)/|);
my $newuri = $r->document_root . "/articles/index.html";
my $uriobj = $r->parsed_uri;
$uriobj->query("id=$id");
$r->uri($newuri);

return OK;
}

1;

All .html documents are being parsed by Embperl and that
works fine.

In my document $fdat{id} doesn't return anything as I think
it should be returing 10.

printing out Apache->request->parsed_uri->query in the
Embperl document doesn't print anything.

In the book there only one sentece about using the query()
method. and even that doesn't explain how to set up key=value
to return it later.

Any help is appreciated.

Ajay
__
Get Your Private, Free Email at http://www.hotmail.com



Re: [Re: [Re: again - more then one PerlTransHandler]]

1999-12-22 Thread Peter Haworth

Doug MacEachern wrote:
> > At least that's what I thought !
> > 
> > In fact now Apache lets me use more then one 
> > PerlTransHandler, but it doesn't care
> > of what is the return codes are!!!
> > 
> > Even I return OK, it still calls
> > next registered handlers. Really weird!
> 
> mod_perl does care.  but, mod_perl stacked handlers are not quite the same
> as Apache C handlers.  unless the return status from a Perl handler is
> something other than OK or DECLINED, mod_perl propagates the status code
> of the last handler run back up to Apache.
> originally, stacked handlers were introduced for chaining multiple content
> handlers.  if the OK status from the first handler was propagated back to
> Apache, there would be no chain, and little use for stacked handlers.
> 
> you can always override this behavior by using a single Perl*Handler which
> decides what path to take based on the return status, or use a
> PerlDispatchHandler, or PerlDirectiveHandlers, to name a few.

I've got round this by having a module which adds a JournalsTrans directive,
which says which trans handlers to apply, then have just one PerlTransHandler,
which processes them all:

httpd.conf:
  PerlTransHandlerJournals::Frontend::handle_trans
  JournalsTrans /EJ   Journals::EJ::handle_trans
  JournalsTrans /EJ/Admin Journals::EJ::Admin::handle_trans
  JournalsTrans /Journals Journals::Info::handle_trans

sub Journals::Frontend::handle_trans{
  my($r)=@_;

  # Fetch handlers configured by Journals::Config
  if(my $cfg=Apache::ModuleConfig->get($r,'Journals::Config')){
if(my $trans=$cfg->{JournalsTrans}){
  my $uri=$r->uri;
  foreach(@$trans){
my($test_uri,$uri_sub,$sub)=@$_;
if($uri_sub->($uri)){
  my $code=$sub->($r,$test_uri);
  return $code
if $code!=DECLINED;
}
  }
  $r->log->error("No handler matching $uri found");
}else{
  $r->log->crit('No JournalsTrans module config found');
}
  }else{
$r->log->crit("Can't retrieve module config");
  }

  return DECLINED;
}


-- 
Peter Haworth   [EMAIL PROTECTED]
If a packet hits a pocket on a socket on a port
& the bus is interrupted as a very last resort
& the memory address makes your processes abort
then the socket packet pocket has an error to report!



Re: [Re: [Re: again - more then one PerlTransHandler]]

1999-12-22 Thread Andrei A. Voropaev

I believe this should be reflected in the documentation. Because after
reading Eagle book one gets absolutely different understanding. It
doesn't diffirentiate Perl stacked handlers and Apache handlers. From
Doug's words (and from practice :) those are slightly different in the
way how their return codes are treated.

BTW. Do I understand it correctly now that if my PERL handler returns
either OK or DECLINED then the next PERL handler (if
any) for this phase will be called anyway, but Apache "native" handlers
will be called depending on what is the phase. Ie. for URL translation the
"native" handler will be called only if last Perl handler returned DECLINED.

Andrei


On Tue, Dec 21, 1999 at 01:45:40PM -0800, Doug MacEachern wrote:
> > At least that's what I thought !
> > 
> > In fact now Apache lets me use more then one 
> > PerlTransHandler, but it doesn't care
> > of what is the return codes are!!!
> > 
> > Even I return OK, it still calls
> > next registered handlers. Really weird!
> 
> mod_perl does care.  but, mod_perl stacked handlers are not quite the same
> as Apache C handlers.  unless the return status from a Perl handler is
> something other than OK or DECLINED, mod_perl propagates the status code
> of the last handler run back up to Apache.
> originally, stacked handlers were introduced for chaining multiple content
> handlers.  if the OK status from the first handler was propagated back to
> Apache, there would be no chain, and little use for stacked handlers.
> 
> you can always override this behavior by using a single Perl*Handler which
> decides what path to take based on the return status, or use a
> PerlDispatchHandler, or PerlDirectiveHandlers, to name a few.
> 
> 

-- 



Re: [Re: [Re: again - more then one PerlTransHandler]]

1999-12-21 Thread Doug MacEachern

> At least that's what I thought !
> 
> In fact now Apache lets me use more then one 
> PerlTransHandler, but it doesn't care
> of what is the return codes are!!!
> 
> Even I return OK, it still calls
> next registered handlers. Really weird!

mod_perl does care.  but, mod_perl stacked handlers are not quite the same
as Apache C handlers.  unless the return status from a Perl handler is
something other than OK or DECLINED, mod_perl propagates the status code
of the last handler run back up to Apache.
originally, stacked handlers were introduced for chaining multiple content
handlers.  if the OK status from the first handler was propagated back to
Apache, there would be no chain, and little use for stacked handlers.

you can always override this behavior by using a single Perl*Handler which
decides what path to take based on the return status, or use a
PerlDispatchHandler, or PerlDirectiveHandlers, to name a few.





Re: [Re: [Re: again - more then one PerlTransHandler]]

1999-12-19 Thread Evgenii Bazarov

Thanks for the answers!

I was using RedHat rpm and it was giving the problem
as it was suggested. After I built mod_perl with apache
(mod_perl 1.21, apache 1.3.9, the problem was resolved. 

At least that's what I thought !

In fact now Apache lets me use more then one 
PerlTransHandler, but it doesn't care
of what is the return codes are!!!

Even I return OK, it still calls
next registered handlers. Really weird!

Thanks!
Evg

Eric Cholet <[EMAIL PROTECTED]> wrote:
On Thu, 16 Dec 1999, you wrote:
> Waa!!! So far nobody who answered even doubted that
> it should be possible to have more then one 
> PerlTransHandler. The "Eagle" book also says
> that it should be possible. People suggested that
> either my mod_perl built with wrong flags or I messed
> up return codes OK/DECLINED (which I didn't!).
> 
> Is what you saying documented somewhere?!!!

Here's a simple test I just ran (with the CVS version of mod_perl, but 1.21
should work as well, although I haven't tested it):

Foo.pm:
package Foo;
sub handler
{
$r = shift;
$r->warn("Foo translating " . $r->uri);
return DECLINED;
}
1;

Bar.pm:
package Bar;
sub handler
{
$r = shift;
$r->warn("Bar translating " . $r->uri);
    return DECLINED;
}
1;

in httpd.conf:
PerlTransHandler +Foo
PerlTransHandler +Bar

after accessing the server, in error.log:
[Fri Dec 17 00:44:22 1999] [warn] Foo translating /
[Fri Dec 17 00:44:22 1999] [warn] Bar translating /

So yes it's possible to have several TransHandlers.

--
Eric Cholet



Get free email and a permanent address at http://www.netaddress.com/?N=1



Re: [Re: again - more then one PerlTransHandler]

1999-12-16 Thread Eric Cholet

On Thu, 16 Dec 1999, you wrote:
> Waa!!! So far nobody who answered even doubted that
> it should be possible to have more then one 
> PerlTransHandler. The "Eagle" book also says
> that it should be possible. People suggested that
> either my mod_perl built with wrong flags or I messed
> up return codes OK/DECLINED (which I didn't!).
> 
> Is what you saying documented somewhere?!!!

Here's a simple test I just ran (with the CVS version of mod_perl, but 1.21
should work as well, although I haven't tested it):

Foo.pm:
package Foo;
sub handler
{
$r = shift;
$r->warn("Foo translating " . $r->uri);
return DECLINED;
}
1;

Bar.pm:
package Bar;
sub handler
{
$r = shift;
$r->warn("Bar translating " . $r->uri);
    return DECLINED;
}
1;

in httpd.conf:
PerlTransHandler +Foo
PerlTransHandler +Bar

after accessing the server, in error.log:
[Fri Dec 17 00:44:22 1999] [warn] Foo translating /
[Fri Dec 17 00:44:22 1999] [warn] Bar translating /

So yes it's possible to have several TransHandlers.

--
Eric Cholet



Re: [Re: again - more then one PerlTransHandler]

1999-12-16 Thread Evgenii Bazarov

Waa!!! So far nobody who answered even doubted that
it should be possible to have more then one 
PerlTransHandler. The "Eagle" book also says
that it should be possible. People suggested that
either my mod_perl built with wrong flags or I messed
up return codes OK/DECLINED (which I didn't!).

Is what you saying documented somewhere?!!!

Thanks,
Evg


darren chamberlain <[EMAIL PROTECTED]> wrote:
You're not missing anything. You can only have one translation handler. In
the case of the two TransHandlers, the second definition masks the first.

Can't you just rewrite the SimpleTranslation::handler to be
ModeratelyComplexTranslation::handler, and do the Right Thing in that one
handler? I.e., if every request is being passed through 2 handlers, why not
consolidate them into one handler?

darren

Evgenii Bazarov ([EMAIL PROTECTED]) wrote:
> Hi everybody,
> 
> Sorry for the poor wording of my question. Once again:
> 
> I am trying to install and use more then one translation
> handler. I tried two approaches to specifying handlers
> in the Apache config file (both recommended in the 
> "Eagle" book.) First, have both handlers on the same line,
> e.g. in httpd.conf
> 
> PerlTransHandler  SimpleTranslation::handler FancyTranslation::handler
> 
> In this case Apache spits out error:
> 
>  Syntax error on line 29 of /etc/httpd/conf/perl.conf
>  PerlTransHandler takes one argument, the Perl Translation handler routine 
> name.
> 
> and exits.
> 
> Secondly I tried to put two lines in config:
> 
> PerlTransHandler  SimpleTranslation::handler
> PerlTransHandler  FancyTranslation::handler
>  
> In this case, only second handler gets invoked.
> Am I missing something?!!!
> 
> Evg
-- 
If God had not given us sticky tape, it would have been necessary to invent
it.



Get free email and a permanent address at http://www.netaddress.com/?N=1



Re: [Re: more then one PerlTransHandler]

1999-12-16 Thread Evgenii Bazarov

I use Apache config file with
PerlTransHandler entry. Yes I set
DECLINED, but actually it doesn't matter
in this case, because the LAST
handler out of all installed PerlTransHandlers in the
file actually gets invoked by Apache in my test. 
If it be the FIRST, I would suspect that I 
messed up return codes.

You said it works fine for you... What is your set
up?!

Best regards,
Evg


"Andrei A. Voropaev" <[EMAIL PROTECTED]> wrote:
How did you try to set it? It works for me fine.

Do you know that if your PerlTransHandler returns OK then no other
TransHandlers are executed? If you want others to work then return DECLINED

Andrei

On Sun, Dec 12, 1999 at 07:46:01AM -0700, Evgenii Bazarov wrote:
> Hi!
> 
> I tried to set more then one PerlTransHandler but
> if I specify both on the same line, Apache says
> "syntax error", otherwise it see only the last one.
> 
> Apache 1.3.6 on Linux with mod_perl 1.19
> 
> According to "Apache Modules" book it should be
> possible... Any advice will be highly appreciated!
> 
> Cheers,
> Evg
> 
> 
> Get free email and a permanent address at http://www.netaddress.com/?N=1

-- 



Get free email and a permanent address at http://www.netaddress.com/?N=1



Re: again - more then one PerlTransHandler

1999-12-15 Thread Jay J

- Original Message -
From: "Andrei A. Voropaev" <[EMAIL PROTECTED]>
To: "Evgenii Bazarov" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, December 15, 1999 10:18 AM
Subject: Re: again - more then one PerlTransHandler


> It works perfectly well for me. I have modperl 1.21, apache 1.3.9 on
> RedHad linux (5.2). I install any number of TransHandlers and as long
> as each one of them returns DECLINED they are all executed. I tried
> both ways (one line and multiple lines) and everything has worked.
>
> Probably you just need to make sure that you used EVERYTHING=1 when
> you compiled modperl. That's what I had and nothing else.
>
> Andrei

Out of curiosity, would it be PERL_STACKED_HANDLERS=1 specifically?

-Jay J



> On Mon, Dec 13, 1999 at 06:41:45AM -0700, Evgenii Bazarov wrote:
> > Hi everybody,
> >
> > Sorry for the poor wording of my question. Once again:
> >
> > I am trying to install and use more then one translation
> > handler. I tried two approaches to specifying handlers
> > in the Apache config file (both recommended in the
> > "Eagle" book.) First, have both handlers on the same line,
> > e.g. in httpd.conf
> >
> > PerlTransHandler  SimpleTranslation::handler FancyTranslation::handler
> >
> > In this case Apache spits out error:
> >
> >  Syntax error on line 29 of /etc/httpd/conf/perl.conf
> >  PerlTransHandler takes one argument, the Perl Translation handler
routine
> > name.
> >
> > and exits.
> >
> > Secondly I tried to put two lines in config:
> >
> > PerlTransHandler  SimpleTranslation::handler
> > PerlTransHandler  FancyTranslation::handler
> >
> > In this case, only second handler gets invoked.
> > Am I missing something?!!!
> >
> > Evg
> >
> >
> >
> > 
> > Hi!
> >
> > I tried to set more then one PerlTransHandler but
> > if I specify both on the same line, Apache says
> > "syntax error", otherwise it see only the last one.
> >
> > Apache 1.3.6 on Linux with mod_perl 1.19
> >
> > According to "Apache Modules" book it should be
> > possible... Any advice will be highly appreciated!
> >
> > Cheers,
> > Evg
> >
> >
> >
> > 
> > Get free email and a permanent address at http://www.netaddress.com/?N=1
>
> --
>



Re: again - more then one PerlTransHandler

1999-12-15 Thread Andrei A. Voropaev

It works perfectly well for me. I have modperl 1.21, apache 1.3.9 on
RedHad linux (5.2). I install any number of TransHandlers and as long
as each one of them returns DECLINED they are all executed. I tried
both ways (one line and multiple lines) and everything has worked.

Probably you just need to make sure that you used EVERYTHING=1 when
you compiled modperl. That's what I had and nothing else.

Andrei

On Mon, Dec 13, 1999 at 06:41:45AM -0700, Evgenii Bazarov wrote:
> Hi everybody,
> 
> Sorry for the poor wording of my question. Once again:
> 
> I am trying to install and use more then one translation
> handler. I tried two approaches to specifying handlers
> in the Apache config file (both recommended in the 
> "Eagle" book.) First, have both handlers on the same line,
> e.g. in httpd.conf
> 
> PerlTransHandler  SimpleTranslation::handler FancyTranslation::handler
> 
> In this case Apache spits out error:
> 
>  Syntax error on line 29 of /etc/httpd/conf/perl.conf
>  PerlTransHandler takes one argument, the Perl Translation handler routine 
> name.
> 
> and exits.
> 
> Secondly I tried to put two lines in config:
> 
> PerlTransHandler  SimpleTranslation::handler
> PerlTransHandler  FancyTranslation::handler
>  
> In this case, only second handler gets invoked.
> Am I missing something?!!!
> 
> Evg
> 
> 
> 
> 
> Hi!
> 
> I tried to set more then one PerlTransHandler but
> if I specify both on the same line, Apache says
> "syntax error", otherwise it see only the last one.
> 
> Apache 1.3.6 on Linux with mod_perl 1.19
> 
> According to "Apache Modules" book it should be
> possible... Any advice will be highly appreciated!
> 
> Cheers,
> Evg
> 
> 
> 
> 
> Get free email and a permanent address at http://www.netaddress.com/?N=1

-- 



Re: again - more then one PerlTransHandler

1999-12-15 Thread darren chamberlain

You're not missing anything. You can only have one translation handler. In
the case of the two TransHandlers, the second definition masks the first.

Can't you just rewrite the SimpleTranslation::handler to be
ModeratelyComplexTranslation::handler, and do the Right Thing in that one
handler? I.e., if every request is being passed through 2 handlers, why not
consolidate them into one handler?

darren

Evgenii Bazarov ([EMAIL PROTECTED]) wrote:
> Hi everybody,
> 
> Sorry for the poor wording of my question. Once again:
> 
> I am trying to install and use more then one translation
> handler. I tried two approaches to specifying handlers
> in the Apache config file (both recommended in the 
> "Eagle" book.) First, have both handlers on the same line,
> e.g. in httpd.conf
> 
> PerlTransHandler  SimpleTranslation::handler FancyTranslation::handler
> 
> In this case Apache spits out error:
> 
>  Syntax error on line 29 of /etc/httpd/conf/perl.conf
>  PerlTransHandler takes one argument, the Perl Translation handler routine 
> name.
> 
> and exits.
> 
> Secondly I tried to put two lines in config:
> 
> PerlTransHandler  SimpleTranslation::handler
> PerlTransHandler  FancyTranslation::handler
>  
> In this case, only second handler gets invoked.
> Am I missing something?!!!
> 
> Evg
-- 
If God had not given us sticky tape, it would have been necessary to invent it.



RE: again - more then one PerlTransHandler

1999-12-15 Thread Geoffrey Young

well, you are missing something :)

p 73: "Apache will walk through the registered uri_translate handlers until
one returns a status other than DECLINED."

thus I suspect that SimpleTranslation::handler is returning OK, so your
request never gets to FancyTranslation::handler

HTH

--Geoff

> -Original Message-
> From: Evgenii Bazarov [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 13, 1999 8:42 AM
> To: [EMAIL PROTECTED]
> Subject: again - more then one PerlTransHandler
> 
> 
> Hi everybody,
> 
> Sorry for the poor wording of my question. Once again:
> 
> I am trying to install and use more then one translation
> handler. I tried two approaches to specifying handlers
> in the Apache config file (both recommended in the 
> "Eagle" book.) First, have both handlers on the same line,
> e.g. in httpd.conf
> 
> PerlTransHandler  SimpleTranslation::handler FancyTranslation::handler
> 
> In this case Apache spits out error:
> 
>  Syntax error on line 29 of /etc/httpd/conf/perl.conf
>  PerlTransHandler takes one argument, the Perl Translation 
> handler routine 
> name.
> 
> and exits.
> 
> Secondly I tried to put two lines in config:
> 
> PerlTransHandler  SimpleTranslation::handler
> PerlTransHandler  FancyTranslation::handler
>  
> In this case, only second handler gets invoked.
> Am I missing something?!!!
> 
> Evg
> 
> 
> 
> 
> Hi!
> 
> I tried to set more then one PerlTransHandler but
> if I specify both on the same line, Apache says
> "syntax error", otherwise it see only the last one.
> 
> Apache 1.3.6 on Linux with mod_perl 1.19
> 
> According to "Apache Modules" book it should be
> possible... Any advice will be highly appreciated!
> 
> Cheers,
> Evg
> 
> 
> 
> 
> Get free email and a permanent address at 
http://www.netaddress.com/?N=1



again - more then one PerlTransHandler

1999-12-14 Thread Evgenii Bazarov

Hi everybody,

Sorry for the poor wording of my question. Once again:

I am trying to install and use more then one translation
handler. I tried two approaches to specifying handlers
in the Apache config file (both recommended in the 
"Eagle" book.) First, have both handlers on the same line,
e.g. in httpd.conf

PerlTransHandler  SimpleTranslation::handler FancyTranslation::handler

In this case Apache spits out error:

 Syntax error on line 29 of /etc/httpd/conf/perl.conf
 PerlTransHandler takes one argument, the Perl Translation handler routine 
name.

and exits.

Secondly I tried to put two lines in config:

PerlTransHandler  SimpleTranslation::handler
PerlTransHandler  FancyTranslation::handler
 
In this case, only second handler gets invoked.
Am I missing something?!!!

Evg




Hi!

I tried to set more then one PerlTransHandler but
if I specify both on the same line, Apache says
"syntax error", otherwise it see only the last one.

Apache 1.3.6 on Linux with mod_perl 1.19

According to "Apache Modules" book it should be
possible... Any advice will be highly appreciated!

Cheers,
Evg




Get free email and a permanent address at http://www.netaddress.com/?N=1



Re: more then one PerlTransHandler

1999-12-14 Thread Doug MacEachern

On 12 Dec 1999, Evgenii Bazarov wrote:

> Hi!
> 
> I tried to set more then one PerlTransHandler but
> if I specify both on the same line, Apache says
> "syntax error", otherwise it see only the last one.

make sure you have built the server with at least PERL_STACKED_HANDLERS=1
or EVERYTHING=1.  if you're still stuck, please send the complete error
message.



more then one PerlTransHandler

1999-12-12 Thread Evgenii Bazarov

Hi!

I tried to set more then one PerlTransHandler but
if I specify both on the same line, Apache says
"syntax error", otherwise it see only the last one.

Apache 1.3.6 on Linux with mod_perl 1.19

According to "Apache Modules" book it should be
possible... Any advice will be highly appreciated!

Cheers,
Evg


Get free email and a permanent address at http://www.netaddress.com/?N=1



Re: hostname sanitation in PerlTransHandler or anywhere else

1999-10-29 Thread Dan Rench


On Fri, 29 Oct 1999, I wrote:

> I can only think of a couple options: hack http_core.c to do what I want,
> or write a custom LogHandler that uses the sanitized host.

We've decided on another option: if you're sending a Host: header that
needs "sanitation," then either 1) you're trying to run some kind of
"exploit" or 2) you're using a very broken browser.  We're going to
just punt and send you a 404 right there.  The end.

BTW, it was a broken client calling itself "NetAttache/2.5" that started
this whole thing.



Re: hostname sanitation in PerlTransHandler or anywhere else

1999-10-29 Thread Francesc Guasch

Dan Rench wrote:
> 
> PS: I'd still like to hear from anyone who is running mod_perl on
> Solaris 2.5.1 with Perl 5.005_03 -- I don't want to stick with 5.004 forever.

If only you could upgrade to solaris 2.6. I have it running:

SunOS 5.6
This is perl, version 5.005_03 built for sun4-solaris
apache-1.3.9
mod_perl-1.21


-- 
 ^-^,-. mailto:[EMAIL PROTECTED]
 o o   )http://www.etsetb.upc.es/~frankie
  Y (_ (__(OOOo



hostname sanitation in PerlTransHandler or anywhere else

1999-10-29 Thread Dan Rench

We use a TransHandler to (among other things) manage name-based virtual
hosts (simply put, given the incoming Host: header plus URI, map to a file).

We (of course) sanitize the incoming URI and Host.  It works fine.
I "save" the sanitized hostname like so:

$r->header_in('Host',$host);
$r->subprocess_env('SERVER_NAME',$host);
$r->parsed_uri->hostname($host);

I used to use just the first line, but I added the other two thinking
they might fix our problems...


First problem (somewhat minor):

$ENV{'SERVER_NAME'} remains "unsanitized" (i.e., it's still exactly what
the client sent in the "Host:" header).  This is not a big deal because the
sanitized host gets set properly in $ENV{'HTTP_HOST'}.  Scripts can just
use that variable instead.

Second problem (bigger):

For logging, we use CLF with the virtual host name tacked on the front
of the line (using %V in the LogConfig).  Yes we have "UseCanonicalName On"
and I've read http://apache.org/docs/mod/core.html#usecanonicalname so I
know that %V and SERVER_NAME get set to whatever the client sends.
(and I can't turn it off, because then %V is always ServerName, and
suddenly no "virtual hosts").

I experimented by putting the host sanitation in a PostReadRequestHandler.
Same results.  I thought this phase was "...where you can examine HTTP
headers and change them before Apache gets a crack at them" (TPJ #9, p.6).


Here's the relevant bit of Apache code (1.3.9) in http_core.c in the
ap_get_server_name() function:

if (d->use_canonical_name == USE_CANONICAL_NAME_OFF) {
return r->hostname ? r->hostname : r->server->server_hostname;
}

There's no $r->hostname method in mod_perl that I can find, and
unfortunately $r->server->server_hostname is read-only.

I can only think of a couple options: hack http_core.c to do what I want,
or write a custom LogHandler that uses the sanitized host.

Is there any other way?



PS: I'd still like to hear from anyone who is running mod_perl on
Solaris 2.5.1 with Perl 5.005_03 -- I don't want to stick with 5.004 forever.



Re: PerlTransHandler

1999-10-21 Thread Randal L. Schwartz

> "Dan" == Dan Rench <[EMAIL PROTECTED]> writes:


Dan> I'd suggest using $r->subprocess_env() instead.

I was going to suggest that too.  %ENV controls the environment
of the currently running Perl process, but child processes come from
the "subprocess env", which only the call above sets.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: PerlTransHandler

1999-10-21 Thread Dan Rench


On Tue, 19 Oct 1999, Mark Cogan wrote:

> >> On Tuesday, October 19, 1999 4:13 AM, William Deegan
> [SMTP:[EMAIL PROTECTED]] wrote:
> >> > How can I change the environment variables that get passed to a perl
> >> > script running under Apache::Registry from a PerlTransHandler?
> >> >
> >> > I'm using the PerlTransHandler to do a sort of dynamic mod_rewrite
> >> > functionality.

[...]

> Use the %ENV hash in perl. The environment is shared between the whole
> request, so setting $ENV{whatever} in the PerlTransHandler will make it
> visible to the content handler down the line. 

I'd suggest using $r->subprocess_env() instead.

We have a somewhat similar situation where we have a PerlTransHandler
that sets certain environment variables that CGI scripts depend on
(yes, plain mod_cgi while we have mod_perl -- but that's another story).

I guess %ENV will work in many situations, but it might bite you later
when you can't figure out why a particular env variable isn't getting set
in certain situations (speaking from experience).

See the explanation on pages 454-455 in the Eagle book.



Re: PerlTransHandler

1999-10-20 Thread Mark Cogan

At 10:03 AM 10/19/99 -0700, William Deegan wrote:
>Eric Cholet wrote:
>> 
>> On Tuesday, October 19, 1999 4:13 AM, William Deegan
[SMTP:[EMAIL PROTECTED]] wrote:
>> > How can I change the environment variables that get passed to a perl
>> > script running under Apache::Registry from a PerlTransHandler?
>> >
>> > I'm using the PerlTransHandler to do a sort of dynamic mod_rewrite
>> > functionality.
>> 
>> Since you've got mod_perl on both sides, I'd suggest you don't use env
>> variables (which are expensive). Your Trans handler can just set
>> package variables which will be picked up by the registry script.
>> Alternatives are using $r->dir_config, or $r->notes.
>
>I'll look into that.  For now though all of our scripts are set
>up to check for an enviroment variable set for some virtual hosts,
>now we'd like a way to set these same variables using a
>PerlTransHandler.
>
>So how do I go about setting the enviroment variables.
>Assuming that I don't care about the cost.

Use the %ENV hash in perl. The environment is shared between the whole
request, so setting $ENV{whatever} in the PerlTransHandler will make it
visible to the content handler down the line. 
---
Mark Cogan[EMAIL PROTECTED] 
Director of Engineering +1 520-881-8101
ArtToday   www.arttoday.com



Re: PerlTransHandler

1999-10-19 Thread William Deegan

Eric Cholet wrote:
> 
> On Tuesday, October 19, 1999 4:13 AM, William Deegan [SMTP:[EMAIL PROTECTED]] 
>wrote:
> > How can I change the environment variables that get passed to a perl
> > script running under Apache::Registry from a PerlTransHandler?
> >
> > I'm using the PerlTransHandler to do a sort of dynamic mod_rewrite
> > functionality.
> 
> Since you've got mod_perl on both sides, I'd suggest you don't use env
> variables (which are expensive). Your Trans handler can just set
> package variables which will be picked up by the registry script.
> Alternatives are using $r->dir_config, or $r->notes.

I'll look into that.  For now though all of our scripts are set
up to check for an enviroment variable set for some virtual hosts,
now we'd like a way to set these same variables using a
PerlTransHandler.

So how do I go about setting the enviroment variables.
Assuming that I don't care about the cost.

Thanks,
Bill

-
Buy and sell safely on the Internet with i-Escrow.
For details visit http://www.iescrow.com/
-

begin:vcard 
n:Deegan;William
tel;fax:650-638-7890
tel;work:650-638-7975
x-mozilla-html:FALSE
url:http://www.iescrow.com
org:iEscrow,Inc.
version:2.1
email;internet:[EMAIL PROTECTED]
title:Web Site Operations Manager
note:http://www.orangefood.com/baddog
adr;quoted-printable:;;1730 South Amphlett Blvd=0D=0ASuite 215;San Mateo;CA;94402;
x-mozilla-cpt:;18272
fn:William Deegan
end:vcard



RE: PerlTransHandler

1999-10-19 Thread Eric Cholet


On Tuesday, October 19, 1999 4:13 AM, William Deegan [SMTP:[EMAIL PROTECTED]] wrote:
> How can I change the environment variables that get passed to a perl
> script running under Apache::Registry from a PerlTransHandler?
> 
> I'm using the PerlTransHandler to do a sort of dynamic mod_rewrite
> functionality.

Since you've got mod_perl on both sides, I'd suggest you don't use env
variables (which are expensive). Your Trans handler can just set
package variables which will be picked up by the registry script.
Alternatives are using $r->dir_config, or $r->notes.

> 
> Thanks,
> Bill << File: bdeegan.vcf >> 

--
Eric



PerlTransHandler

1999-10-18 Thread William Deegan

How can I change the environment variables that get passed to a perl
script running under Apache::Registry from a PerlTransHandler?

I'm using the PerlTransHandler to do a sort of dynamic mod_rewrite
functionality.

Thanks,
Bill

begin:vcard 
n:Deegan;William
tel;fax:650-638-7890
tel;work:650-638-7975
x-mozilla-html:FALSE
url:http://www.iescrow.com
org:iEscrow,Inc.
version:2.1
email;internet:[EMAIL PROTECTED]
title:Web Site Operations Manager
note:http://www.orangefood.com/baddog
adr;quoted-printable:;;1730 South Amphlett Blvd=0D=0ASuite 215;San Mateo;CA;94402;
x-mozilla-cpt:;18272
fn:William Deegan
end:vcard