use Maypole::Headers;
use Maypole::Constants;
-our $VERSION = '2.10';
+our $VERSION = '2.11';
-__PACKAGE__->mk_accessors( qw( cgi ) );
+__PACKAGE__->mk_accessors( qw/cgi/ );
=head1 NAME
shift->cgi( CGI::Simple->new );
}
-=item get_protocol
-
-=cut
-
-sub get_protocol
-{
- my $self = shift;
- my $protocol = ($self->cgi->https) ? 'https' : 'http';
- return $protocol;
-}
-
=item parse_location
=cut
my $path = $args{path} || $r->cgi->url(-absolute => 1, -query=>1);
my $host = $args{domain};
($host = $r->cgi->url(-base => 1)) =~ s/^https?:\/\///i unless ($host);
- my $protocol = $args{protocol} || ($r->cgi->https()) ? 'https' : 'http';
+ my $protocol = $args{protocol} || $r->get_protocol;
$redirect_url = "${protocol}://${host}/${path}";
}
$status = $args{status} if ($args{status});
return;
}
+=item get_protocol
+
+=cut
+
+sub get_protocol
+{
+ my $self = shift;
+ my $protocol = ($self->cgi->https) ? 'https' : 'http';
+ return $protocol;
+}
+
=item send_output
+Generates output (using C<collect_output>) and prints it.
+
=cut
sub send_output
{
my $r = shift;
+ print $r->collect_output;
+}
+=item collect_output
+
+Gathers headers and output together into a string and returns it.
+
+Splitting this code out of C<send_output> supports L<Maypole::HTTPD::Frontend>.
+
+=cut
+
+sub collect_output
+{
+ my $r = shift;
+
# Collect HTTP headers
my %headers = (
-type => $r->content_type,
$headers{"-$_"} = $r->headers_out->get($_);
}
- print $r->cgi->header(%headers), $r->output;
+ return $r->cgi->header(%headers) . $r->output;
}
=item get_template_root