]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Apache/MVC.pm
Maypole::Application supports Maypole::HTTPD (which needs a patch).
[maypole.git] / lib / Apache / MVC.pm
index 84454bc6cf3ae8c458907a2448876264261b50b7..4623b9f607dbaf3c6fb2d0f47876166ed7b9d111 100644 (file)
@@ -82,20 +82,10 @@ functionality. See L<Maypole> for these:
 
 sub get_request {
     my ($self, $r) = @_;
-    my $ar = (APACHE2) ? Apache2::Request->new($r) : Apache::Request->new($r);
+    my $ar = (APACHE2) ? Apache2::Request->new($r) : Apache::Request->instance($r);
     $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
@@ -111,7 +101,6 @@ sub parse_location {
     for (keys %headers) {
         $self->headers_in->set($_, $headers{$_});
     }
-
     my $path = $self->ar->uri;
     my $loc  = $self->ar->location;
     {
@@ -140,8 +129,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 +139,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