Phoenix.pm: mod_perl internal redirect question

Doug Miles doug.miles at bpxinternet.com
Wed Jan 8 09:40:29 CST 2003


Hi all!

This is a question for all you mod_perl experts out there.  I am 
attempting to do an internal redirect in mod_perl, preserving any POST 
request parameters that might be kicking around.  I couldn't get the 
example code I found here:

http://www.esc.auckland.ac.nz/Docs/mod_perl/snippets.html#Redirect_a_POST_request_forward

to work.  It appeared to do the redirect, but wouldn't pass any of the 
POST parameters.  To complicate matters, I'm using Apache::Request 
(which is a subclass of Apache) instead of the default Apache object.  I 
did finally get the redirect to work, but only by building up my own 
query string and appending it to the URL being redirected to.  This 
works fine, but I'd really like to know why the other code doesn't work. 
  The commented out code is the code in question.  The only other change 
is to remove the appending of the parameters.  Any ideas are appreciated.

# redirect #############################################################

sub redirect
{
   use Apache::Constants qw(M_GET);

   my $self = shift;

   my %tag_parameter = @_;

   my @parameters;

   foreach my $parameter ($self->request->param)
   {

     push
     (
       @parameters,
       uri_escape($parameter) .  '=' .
         uri_escape($self->request->param($parameter))
     );

   }

   my $parameters = join('&', @parameters);

# Don't know why this doesn't work.  Appending parameters to URL below 
does. ???

#  my $content = $self->request->content;
#  $self->request->method('GET');
#  $self->request->method_number(M_GET);
#  $self->request->headers_in->unset("Content-length");
#  $self->request->args($parameters);
#  my $content = $self->request->content;

   $self->
     request->
       internal_redirect
       (
         $self->normalize_absolute_path("/pcms/$tag_parameter{'url'}") .
           "?$parameters"
       );

} # END: redirect




More information about the Phoenix-pm mailing list