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