From: Marcus Ramberg Date: Wed, 8 Dec 2004 19:45:43 +0000 (+0000) Subject: Added support for extra_headers (se Maypole pod) X-Git-Tag: 2.10~58 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=271fd90b8a1b9f843853601a75a1334407ff87c4;p=maypole.git Added support for extra_headers (se Maypole pod) git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@306 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/Changes b/Changes index 4c52c6b..d56550b 100644 --- a/Changes +++ b/Changes @@ -14,6 +14,7 @@ Revision history for Perl extension Maypole - Check if has_a actually points to a Maypole::Model (Dave Howorth) - Only show buttons for public actions. (Dagfinn Ilmari Mannsåker) + - Added support for extra_headers 2.04 Tue Oct 27 14:00:00 2004 diff --git a/lib/Apache/MVC.pm b/lib/Apache/MVC.pm index cd4e96d..0921412 100644 --- a/lib/Apache/MVC.pm +++ b/lib/Apache/MVC.pm @@ -52,6 +52,11 @@ sub send_output { $r->{ar}->headers_out->set( "Content-Length" => do { use bytes; length $r->{output} } ); + foreach my $header (keys %{$r->{extra_headers}}) { + $r->{ar}->headers_out->set( + "$header" => $r->{extra_headers}{$header} + ); + } APACHE2 || $r->{ar}->send_http_header; $r->{ar}->print( $r->{output} ); } diff --git a/lib/CGI/Maypole.pm b/lib/CGI/Maypole.pm index 863bc10..88abc3c 100644 --- a/lib/CGI/Maypole.pm +++ b/lib/CGI/Maypole.pm @@ -40,10 +40,15 @@ sub parse_args { sub send_output { my $r = shift; + my %processed = map { "-".$_,$r->{extra_headers}{$_} } + keys %{$r->{extra_headers}}; print $r->{cgi}->header( -type => $r->{content_type}, -charset => $r->{document_encoding}, -content_length => do { use bytes; length $r->{output} }, + %processed + ? %processed + : {} ); print $r->{output}; } diff --git a/lib/Maypole.pm b/lib/Maypole.pm index e16dd82..1665ca7 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -11,7 +11,8 @@ our $VERSION = '2.05'; __PACKAGE__->mk_classdata($_) for qw( config init_done view_object ); __PACKAGE__->mk_accessors( qw( ar params query objects model_class template_args output path - args action template error document_encoding content_type table) + args action template error document_encoding content_type table + extra_headers ) ); __PACKAGE__->config( Maypole::Config->new() ); __PACKAGE__->init_done(0); @@ -276,6 +277,10 @@ A list of remaining parts of the request path after table and action have been removed +=head3 extra_headers + +A hash containing extra headers to be set on a request. + =head3 parse_args Turns post data and query string paramaters into a hash of C.