You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Paul <yd...@yahoo.com> on 2000/06/20 16:53:48 UTC

garbled redirections

Hello, all.

First, the problem:
________________________________________
[Tue Jun 20 09:06:55 2000] [error] [client 90.17.209.65] Invalid error
redirection directive: ��@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

��@? Let me assure you, "��@" isn't in my code anywhere. =o)

I am, however, using a PerlPostReadRequestHandler that currently looks
much like this:
________________________________________

package Apache::PortCorrect;

use strict;
use Apache::Constants qw( :response :methods );
use Carp ();
$SIG{__WARN__} = \&Carp::cluck;

sub handler {
     my($r,$s,$url,$args,$uri,$subr);
     $r = shift;   # the request object
     return OK if 443 == $r->get_server_port;
     (undef,$url,undef) = split(/\s+/o, $r->the_request);
     return OK if $url =~ m{ ^(?:/ # doc root
                       | /(list|of|ok|dirs)/.* # edited 
                       | /(page|list)[.]shtml  # ditto
                       | .*[.](gif|jpg) 
                               )$
                       }ixo;
     $uri = "https://our.intranet.com" . $url; # again
     $args = $r->args;
     $uri .= "?$args" if $args;
     $r->custom_response(MOVED,$uri);
     return MOVED;
}

1; # guarantee return code for load
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Am I confusing or crosswiring Apache by doing a cross-port custom
response here?  It seems to work....

Or is it something entirely different?

__________________________________________________
Do You Yahoo!?
Send instant messages with Yahoo! Messenger.
http://im.yahoo.com/

Re: garbled redirections

Posted by darren chamberlain <da...@boston.com>.
Paul (ydbxmhc@yahoo.com) said something to this effect:
> Hello, all.
> 
> First, the problem:
> ________________________________________
> [Tue Jun 20 09:06:55 2000] [error] [client 90.17.209.65] Invalid error
> redirection directive: üØ@
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> üØ@? Let me assure you, "üØ@" isn't in my code anywhere. =o)
> 
> I am, however, using a PerlPostReadRequestHandler that currently looks
> much like this:
> ________________________________________
> 
> package Apache::PortCorrect;
> 
> use strict;
> use Apache::Constants qw( :response :methods );
> use Carp ();
> $SIG{__WARN__} = \&Carp::cluck;
> 
> sub handler {
>      my($r,$s,$url,$args,$uri,$subr);
>      $r = shift;   # the request object
>      return OK if 443 == $r->get_server_port;
>      (undef,$url,undef) = split(/\s+/o, $r->the_request);
>      return OK if $url =~ m{ ^(?:/ # doc root
>                        | /(list|of|ok|dirs)/.* # edited 
>                        | /(page|list)[.]shtml  # ditto
>                        | .*[.](gif|jpg) 
>                                )$
>                        }ixo;
>      $uri = "https://our.intranet.com" . $url; # again
>      $args = $r->args;
>      $uri .= "?$args" if $args;
>      $r->custom_response(MOVED,$uri);
>      return MOVED;
> }
> 
> 1; # guarantee return code for load
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Am I confusing or crosswiring Apache by doing a cross-port custom
> response here?  It seems to work....
> 
> Or is it something entirely different?

My immediate thoughts:

Are you sure that the redirect URI is being set correctly? Try printing it
to STDERR.

What's wrong with fetching the requested URI with $r->uri ? Especially since
you're appending $r->args anyway.

I would try Apache::URI to construct the URI, something like this:

    my $uri = Apache::URI->parse($r, $url);
    $uri->scheme('https');
    $uri->hostname($r->get_server_name);
    $uri->port($r->get_server_port);
    $r->args and $uri->query(scalar $r->args);
    $r->custom_response(MOVED,$uri->unparse);

Yeah, it's just string munging, but I'd try it out, to be sure that it's not 
your code.

Finally, what's wrong with using mod_rewrite to redirect requests for this
URI?

darren

-- 
Never underestimate the power of stupid people in large groups.

Re: garbled redirections

Posted by Eric Cholet <ch...@apache.org>.
> Hello, all.
>
> First, the problem:
> ________________________________________
> [Tue Jun 20 09:06:55 2000] [error] [client 90.17.209.65] Invalid error
> redirection directive: üØ@
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> üØ@? Let me assure you, "üØ@" isn't in my code anywhere. =o)
>
> I am, however, using a PerlPostReadRequestHandler that currently looks
> much like this:
> ________________________________________
>
> package Apache::PortCorrect;
>
> use strict;
> use Apache::Constants qw( :response :methods );
> use Carp ();
> $SIG{__WARN__} = \&Carp::cluck;
>
> sub handler {
>      my($r,$s,$url,$args,$uri,$subr);
>      $r = shift;   # the request object
>      return OK if 443 == $r->get_server_port;
>      (undef,$url,undef) = split(/\s+/o, $r->the_request);
>      return OK if $url =~ m{ ^(?:/ # doc root
>                        | /(list|of|ok|dirs)/.* # edited
>                        | /(page|list)[.]shtml  # ditto
>                        | .*[.](gif|jpg)
>                                )$
>                        }ixo;
>      $uri = "https://our.intranet.com" . $url; # again
>      $args = $r->args;
>      $uri .= "?$args" if $args;
>      $r->custom_response(MOVED,$uri);
>      return MOVED;
> }
>
> 1; # guarantee return code for load
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Am I confusing or crosswiring Apache by doing a cross-port custom
> response here?  It seems to work....
>
> Or is it something entirely different?

I don't think you can want custom_response here, it does an internal
redirect. You want to do an external redirect, so use
$r->header_out(location => ...)

--
Eric