| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTTP::Body::Pairs; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.3'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: methods for getting body params in the order they were sent |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
577
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
61
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
{ |
|
10
|
|
|
|
|
|
|
require HTTP::Body; |
|
11
|
|
|
|
|
|
|
my $vanilla = \&HTTP::Body::param; |
|
12
|
1
|
|
|
1
|
|
5
|
no warnings 'redefine'; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
275
|
|
|
13
|
|
|
|
|
|
|
*HTTP::Body::param = sub { |
|
14
|
6
|
50
|
|
6
|
|
410
|
if (@_ > 2) { |
|
15
|
6
|
|
|
|
|
9
|
my ($self, $name, $value) = @_; |
|
16
|
6
|
|
|
|
|
6
|
push @{ $self->{pairs} }, $name, $value; |
|
|
6
|
|
|
|
|
20
|
|
|
17
|
|
|
|
|
|
|
} |
|
18
|
6
|
|
|
|
|
14
|
goto $vanilla; |
|
19
|
|
|
|
|
|
|
}; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
0
|
31
|
sub HTTP::Body::flat_pairs { @{ $_[0]->{pairs} } } |
|
|
1
|
|
|
|
|
17
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub HTTP::Body::pairs { |
|
25
|
1
|
|
|
1
|
0
|
3
|
my $a = $_[0]->{pairs}; |
|
26
|
1
|
|
|
|
|
2
|
my @result; |
|
27
|
1
|
|
|
|
|
6
|
for (my $i = 0; $i < @$a; $i += 2) { |
|
28
|
6
|
|
|
|
|
7
|
push @result, [@{$a}[$i, $i+1]]; |
|
|
6
|
|
|
|
|
21
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
1
|
|
|
|
|
17
|
return @result; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
HTTP::Body::Pairs |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 VERSION |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
version 0.3 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use HTTP::Body::Pairs; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $body = HTTP::Body->new(...); |
|
48
|
|
|
|
|
|
|
for ($body->pairs) { |
|
49
|
|
|
|
|
|
|
my ($key, $val) = @$_; |
|
50
|
|
|
|
|
|
|
# ... |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Adds functionality to HTTP::Body for retaining order information from the |
|
56
|
|
|
|
|
|
|
parsed http body. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 METHODS |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 flat_pairs |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns the ordered pairs as a flat list, e.g. ('foo', 'fooval', 'foo', |
|
63
|
|
|
|
|
|
|
'fooval2', 'bar', 'barval'); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 pairs |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns the ordered pairs as a list of array refs, e.g. (['foo', 'fooval'], |
|
68
|
|
|
|
|
|
|
['foo', 'fooval2'], ['bar', 'barval']). |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 RATIONALE |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
You don't normally need to know the order parameters came in. Usually if you |
|
73
|
|
|
|
|
|
|
need order at all, you only need to know the order for a particular param. |
|
74
|
|
|
|
|
|
|
That being the case, the extra storage overhead isn't warranted in HTTP::Body. |
|
75
|
|
|
|
|
|
|
This is for the odd case where you do need the order. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Paul Driver C<< frodwith@cpan.org >> |