line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Headers::ActionPack::MediaTypeList; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
3
|
|
|
3
|
|
37425
|
$HTTP::Headers::ActionPack::MediaTypeList::AUTHORITY = 'cpan:STEVAN'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$HTTP::Headers::ActionPack::MediaTypeList::VERSION = '0.09'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: A Priority List customized for Media Types |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
102
|
|
11
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
93
|
|
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
15
|
use Scalar::Util qw[ blessed ]; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
258
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
1502
|
use HTTP::Headers::ActionPack::MediaType; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
92
|
|
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
17
|
use parent 'HTTP::Headers::ActionPack::PriorityList'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
16
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub BUILD { |
20
|
28
|
|
|
28
|
1
|
49
|
my ($self, @items) = @_; |
21
|
28
|
|
|
|
|
85
|
foreach my $item ( @items ) { |
22
|
4
|
100
|
|
|
|
22
|
$self->add( ref $item eq 'ARRAY' ? @$item : $item ) |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub add { |
27
|
80
|
|
|
80
|
1
|
93
|
my $self = shift; |
28
|
80
|
50
|
|
|
|
223
|
my ($q, $mt) = scalar @_ == 1 ? ((exists $_[0]->params->{'q'} ?$_[0]->params->{'q'} : 1.0), $_[0]) : @_; |
|
|
100
|
|
|
|
|
|
29
|
80
|
|
|
|
|
278
|
$self->SUPER::add( $q, $mt ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub add_header_value { |
33
|
76
|
|
|
76
|
1
|
97
|
my $self = shift; |
34
|
76
|
|
|
|
|
83
|
my $mt = HTTP::Headers::ActionPack::MediaType->new( @{ $_[0] } ); |
|
76
|
|
|
|
|
286
|
|
35
|
76
|
|
100
|
|
|
224
|
my $q = $mt->params->{'q'} || 1.0; |
36
|
76
|
|
|
|
|
184
|
$self->add( $q, $mt ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub as_string { |
40
|
8
|
|
|
8
|
1
|
2910
|
my $self = shift; |
41
|
8
|
|
|
|
|
21
|
join ', ' => map { $_->[1]->as_string } $self->iterable; |
|
21
|
|
|
|
|
71
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub iterable { |
45
|
28
|
|
|
28
|
1
|
40
|
my $self = shift; |
46
|
|
|
|
|
|
|
# From RFC-2616 sec14 |
47
|
|
|
|
|
|
|
# Media ranges can be overridden by more specific |
48
|
|
|
|
|
|
|
# media ranges or specific media types. If more |
49
|
|
|
|
|
|
|
# than one media range applies to a given type, |
50
|
|
|
|
|
|
|
# the most specific reference has precedence. |
51
|
|
|
|
|
|
|
sort { |
52
|
72
|
100
|
|
|
|
199
|
if ( $a->[0] == $b->[0] ) { |
|
54
|
|
|
|
|
76
|
|
53
|
32
|
100
|
|
|
|
143
|
$a->[1]->matches_all |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
54
|
|
|
|
|
|
|
? 1 |
55
|
|
|
|
|
|
|
: ($b->[1]->matches_all |
56
|
|
|
|
|
|
|
? -1 |
57
|
|
|
|
|
|
|
: ($a->[1]->minor eq '*' |
58
|
|
|
|
|
|
|
? 1 |
59
|
|
|
|
|
|
|
: ($b->[1]->minor eq '*' |
60
|
|
|
|
|
|
|
? -1 |
61
|
|
|
|
|
|
|
: ($a->[1]->params_are_empty |
62
|
|
|
|
|
|
|
? 1 |
63
|
|
|
|
|
|
|
: ($b->[1]->params_are_empty |
64
|
|
|
|
|
|
|
? -1 |
65
|
|
|
|
|
|
|
: 0))))) |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
40
|
|
|
|
|
122
|
$b->[0] <=> $a->[0] |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} map { |
71
|
28
|
|
|
|
|
74
|
my $q = $_; |
72
|
54
|
|
|
|
|
68
|
map { [ $q+0, $_ ] } reverse @{ $self->items->{ $q } } |
|
80
|
|
|
|
|
326
|
|
|
54
|
|
|
|
|
141
|
|
73
|
28
|
|
|
|
|
34
|
} keys %{ $self->items }; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub canonicalize_choice { |
77
|
80
|
50
|
|
80
|
1
|
561
|
return blessed $_[1] |
78
|
|
|
|
|
|
|
? $_[1] |
79
|
|
|
|
|
|
|
: HTTP::Headers::ActionPack::MediaType->new( $_[1] ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |