]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Apache/MVC.pm
minor refactoring of redirect_request
[maypole.git] / lib / Apache / MVC.pm
index 84454bc6cf3ae8c458907a2448876264261b50b7..3ee8541a3882a58cb9b2a9c10bf18aacf64afc2d 100644 (file)
@@ -86,16 +86,6 @@ sub get_request {
     $self->ar($ar);
 }
 
-=item get_protocol
-
-=cut
-
-sub get_protocol {
-  my $self = shift;
-  my $protocol = ( $self->ar->protocol =~ m/https/i ) ? 'https' : 'http' ;
-  return $protocol;
-}
-
 =item parse_location
 
 =cut
@@ -140,8 +130,9 @@ sub parse_args {
 =cut
 
 # FIXME: use headers_in to gather host and other information?
-sub redirect_request {
-  my $self = shift;
+sub redirect_request 
+{
+  my $r = shift;
   my $redirect_url = $_[0];
   my $status = "302";
   if ($_[1]) {
@@ -149,20 +140,29 @@ sub redirect_request {
     if ($args{url}) {
       $redirect_url = $args{url};
     } else {
-      my $path = $args{path} || $self->path;
-      my $host = $args{domain} || $self->ar->hostname;
-      my $protocol = $args{protocol} || 
-        ( $self->ar->protocol =~ m/https/i ) ? 'https' : 'http' ;
+      my $path = $args{path} || $r->path;
+      my $host = $args{domain} || $r->ar->hostname;
+      my $protocol = $args{protocol} || $r->get_protocol;
       $redirect_url = "${protocol}://${host}/${path}";
     }
     $status = $args{status} if ($args{status});
   }
 
-  $self->headers_out->set('Status' => $status);
-  $self->headers_out->set('Location' => $redirect_url);
+  $r->headers_out->set('Status' => $status);
+  $r->headers_out->set('Location' => $redirect_url);
   return OK;
 }
 
+=item get_protocol
+
+=cut
+
+sub get_protocol {
+  my $self = shift;
+  my $protocol = ( $self->ar->protocol =~ m/https/i ) ? 'https' : 'http' ;
+  return $protocol;
+}
+
 =item send_output
 
 =cut