1package Maypole::Headers; 2use base 'HTTP::Headers'; 3 4use strict; 5use warnings; 6 7our $VERSION = "1." . sprintf "%04d", q$Rev: 376 $ =~ /: (\d+)/; 8 9sub get { 10 shift->header(shift); 11} 12 13sub set { 14 shift->header(@_); 15} 16 17*add = \&push; # useful for Apache::Session::Wrapper support 18 19sub push { 20 shift->push_header(@_); 21} 22 23sub init { 24 shift->init_header(@_); 25} 26 27sub remove { 28 shift->remove_header(@_); 29} 30 31sub field_names { 32 shift->header_field_names(@_); 33} 34 351; 36 37=pod 38 39=head1 NAME 40 41Maypole::Headers - Convenience wrapper around HTTP::Headers 42 43=head1 SYNOPSIS 44 45 use Maypole::Headers; 46 47 $r->headers_out(Maypole::Headers->new); # Note, automatic in Maypole 48 $r->headers_out->set('Content-Base' => 'http://localhost/maypole'); 49 $r->headers_out->push('Set-Cookie' => $cookie->as_string); 50 $r->headers_out->push('Set-Cookie' => $cookie2->as_string); 51 52 print $r->headers_out->as_string; 53 54=head1 DESCRIPTION 55 56A convenience wrapper around C<HTTP::Headers>. Additional methods are provided 57to make the mutators less repetitive and wordy. For example: 58 59 $r->headers_out->header(Content_Base => $r->config->uri_base); 60 61can be written as: 62 63 $r->headers_out->set(Content_Base => $r->config->uri_base); 64 65=head1 METHODS 66 67All the standard L<HTTP::Headers> methods, plus the following: 68 69=over 70 71=item get($header) 72 73Get the value of a header field. 74 75An alias to C<HTTP::Headers-E<gt>header> 76 77=item set($header =C<gt> $value, ...) 78 79Set the value of one or more header fields 80 81An alias to C<HTTP::Headers-E<gt>header> 82 83=item push($header =C<gt> $value) 84 85Add a value to the field named C<$header>. Previous values are maintained. 86 87An alias to C<HTTP::Headers-E<gt>push_header> 88 89=item add 90 91Alias to C<push> - useful for C<Apache::Session::Wrapper> support, in CGI mode. 92 93=item init($header =C<gt> $value) 94 95Set the value for the field named C<$header>, but only if that header is 96currently undefined. 97 98An alias to C<HTTP::Headers-E<gt>init_header> 99 100=item remove($header, ...) 101 102Remove one of more headers 103 104An alias to C<HTTP::Headers-E<gt>remove_header> 105 106=item field_names() 107 108Returns a list of distinct header names 109 110An alias to C<HTTP::Headers-E<gt>header_field_names> 111 112=back 113 114=head1 SEE ALSO 115 116L<HTTP::Headers> 117 118=head1 AUTHOR 119 120Simon Flack 121 122=cut 123