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 ? 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