File: Headers.pm

package info (click to toggle)
maypole 2.10-1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 472 kB
  • ctags: 108
  • sloc: perl: 1,345; makefile: 21
file content (116 lines) | stat: -rw-r--r-- 2,100 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package Maypole::Headers;
use base 'HTTP::Headers';

use strict;
use warnings;

our $VERSION = "1." . sprintf "%04d", q$Rev: 324 $ =~ /: (\d+)/;

sub get {
    shift->header(shift);
}

sub set {
    shift->header(@_);
}

sub push {
    shift->push_header(@_);
}

sub init {
    shift->init_header(@_);
}

sub remove {
    shift->remove_header(@_);
}

sub field_names {
    shift->header_field_names(@_);
}

1;

=pod

=head1 NAME

Maypole::Headers - Convenience wrapper around HTTP::Headers

=head1 SYNOPSIS

    use Maypole::Headers;

    $r->headers_out(Maypole::Headers->new); # Note, automatic in Maypole
    $r->headers_out->set('Content-Base' => 'http://localhost/maypole');
    $r->headers_out->push('Set-Cookie' => $cookie->as_string);
    $r->headers_out->push('Set-Cookie' => $cookie2->as_string);

    print $r->headers_out->as_string;

=head1 DESCRIPTION

A convenience wrapper around C<HTTP::Headers>. Additional methods are provided
to make the mutators less repetitive and wordy. For example:

    $r->headers_out->header(Content_Base => $r->config->uri_base);

can be written as:

    $r->headers_out->set(Content_Base => $r->config->uri_base);

=head1 METHODS

All the standard L<HTTP::Headers> methods, plus the following:

=over

=item get($header)

Get the value of a header field.

An alias to C<HTTP::Headers-E<gt>header>

=item set($header =C<gt> $value, ...)

Set the value of one or more header fields

An alias to C<HTTP::Headers-E<gt>header>

=item push($header =C<gt> $value)

Add a value to the field named C<$header>. Previous values are maintained.

An alias to C<HTTP::Headers-E<gt>push_header>

=item init($header =C<gt> $value)

Set the value for the field named C<$header>, but only if that header is
currently undefined.

An alias to C<HTTP::Headers-E<gt>init_header>

=item remove($header, ...)

Remove one of more headers

An alias to C<HTTP::Headers-E<gt>remove_header>

=item field_names()

Returns a list of distinct header names

An alias to C<HTTP::Headers-E<gt>header_field_names>

=back

=head1 SEE ALSO

L<HTTP::Headers>

=head1 AUTHOR

Simon Flack

=cut