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