line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Headers::ActionPack::Util; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
22
|
|
|
22
|
|
1119
|
$HTTP::Headers::ActionPack::Util::AUTHORITY = 'cpan:STEVAN'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$HTTP::Headers::ActionPack::Util::VERSION = '0.09'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: General Utility module |
9
|
|
|
|
|
|
|
|
10
|
22
|
|
|
22
|
|
136
|
use strict; |
|
22
|
|
|
|
|
45
|
|
|
22
|
|
|
|
|
772
|
|
11
|
22
|
|
|
22
|
|
153
|
use warnings; |
|
22
|
|
|
|
|
38
|
|
|
22
|
|
|
|
|
762
|
|
12
|
|
|
|
|
|
|
|
13
|
22
|
|
|
22
|
|
30950
|
use Time::Piece; |
|
22
|
|
|
|
|
649848
|
|
|
22
|
|
|
|
|
152
|
|
14
|
22
|
|
|
22
|
|
145330
|
use HTTP::Date qw[ str2time time2str ]; |
|
22
|
|
|
|
|
69119
|
|
|
22
|
|
|
|
|
2048
|
|
15
|
22
|
|
|
22
|
|
35363
|
use HTTP::Headers::Util; |
|
22
|
|
|
|
|
30717
|
|
|
22
|
|
|
|
|
1724
|
|
16
|
|
|
|
|
|
|
|
17
|
22
|
|
|
|
|
788
|
use Sub::Exporter -setup => { |
18
|
|
|
|
|
|
|
exports => [qw[ |
19
|
|
|
|
|
|
|
header_to_date |
20
|
|
|
|
|
|
|
date_to_header |
21
|
|
|
|
|
|
|
split_header_words |
22
|
|
|
|
|
|
|
join_header_words |
23
|
|
|
|
|
|
|
join_header_params |
24
|
|
|
|
|
|
|
]] |
25
|
22
|
|
|
22
|
|
31006
|
}; |
|
22
|
|
|
|
|
395987
|
|
26
|
|
|
|
|
|
|
|
27
|
8
|
|
|
8
|
0
|
55
|
sub header_to_date { scalar Time::Piece->gmtime( str2time( shift ) ) } |
28
|
15
|
|
|
15
|
0
|
70
|
sub date_to_header { time2str( shift->epoch ) } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub split_header_words { |
31
|
141
|
|
|
141
|
1
|
201
|
my $header = shift; |
32
|
229
|
|
|
|
|
8014
|
map { |
33
|
141
|
|
|
|
|
470
|
splice @$_, 1, 1; |
34
|
229
|
|
|
|
|
914
|
$_; |
35
|
|
|
|
|
|
|
} HTTP::Headers::Util::_split_header_words( $header ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub join_header_words { |
39
|
394
|
|
|
394
|
1
|
941
|
my ($subject, @params) = @_; |
40
|
394
|
100
|
|
|
|
1168
|
return $subject . '; ' . join_header_params( '; ' => @params ) if @params; |
41
|
190
|
|
|
|
|
947
|
return $subject; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub join_header_params { |
45
|
218
|
|
|
218
|
0
|
508
|
my ($separator, @params) = @_; |
46
|
218
|
|
|
|
|
273
|
my @attrs; |
47
|
218
|
|
|
|
|
492
|
while ( @params ) { |
48
|
318
|
|
|
|
|
483
|
my $k = shift @params; |
49
|
318
|
|
|
|
|
444
|
my $v = shift @params; |
50
|
|
|
|
|
|
|
|
51
|
318
|
100
|
|
|
|
627
|
if (defined $v) { |
52
|
317
|
|
|
|
|
712
|
$v =~ s/([\"\\])/\\$1/g; # escape " and \ |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
1
|
|
|
|
|
2
|
$v = q{}; |
56
|
|
|
|
|
|
|
} |
57
|
318
|
|
|
|
|
1235
|
push @attrs => ($k . qq(="$v")); |
58
|
|
|
|
|
|
|
} |
59
|
218
|
|
|
|
|
1526
|
return join $separator => @attrs; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |