X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FApache%2FMVC.pm;h=3ee8541a3882a58cb9b2a9c10bf18aacf64afc2d;hb=3239e23cfde1714927e043e6e72dc38d7b20e1c3;hp=84454bc6cf3ae8c458907a2448876264261b50b7;hpb=3d8147141cf009d244c8fde36da4a84b6a8b52d4;p=maypole.git diff --git a/lib/Apache/MVC.pm b/lib/Apache/MVC.pm index 84454bc..3ee8541 100644 --- a/lib/Apache/MVC.pm +++ b/lib/Apache/MVC.pm @@ -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