|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package CGI::Application::Plugin::Header;  | 
| 
2
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
 
 | 
354167
 | 
 use 5.008_009;  | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
28
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
301
 | 
    | 
| 
3
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
 
 | 
42
 | 
 use strict;  | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
265
 | 
    | 
| 
4
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
 
 | 
41
 | 
 use warnings;  | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
250
 | 
    | 
| 
5
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
 
 | 
910
 | 
 use parent 'Exporter';  | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
333
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
52
 | 
    | 
| 
6
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
 
 | 
7842
 | 
 use CGI::Header;  | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9362
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
226
 | 
    | 
| 
7
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
 
 | 
46
 | 
 use Carp qw/carp croak/;  | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4979
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '0.63008';  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @EXPORT  = qw( header header_add header_props );  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub import {  | 
| 
13
 | 
6
 | 
 
 | 
 
 | 
  
6
  
 | 
 
 | 
59
 | 
     my ( $class ) = @_;  | 
| 
14
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
     my $caller = caller;  | 
| 
15
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
69
 | 
     $caller->add_callback( init => \&BUILD );  | 
| 
16
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11530
 | 
     $class->export_to_level( 1, @_ );  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub BUILD {  | 
| 
20
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
  
0
  
 | 
73837
 | 
     my $self = shift;  | 
| 
21
 | 
26
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
119
 | 
     my @args = ref $_[0] eq 'HASH' ? %{$_[0]} : @_;  | 
| 
 
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
427
 | 
     while ( my ($key, $value) = splice @args, 0, 2 ) {  | 
| 
24
 | 
11
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
75
 | 
         $self->{+__PACKAGE__} = $value if lc $key eq 'header';  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
79
 | 
     return;  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub header {  | 
| 
31
 | 
100
 | 
 
 | 
 
 | 
  
100
  
 | 
  
1
  
 | 
74346
 | 
     my $self = shift;  | 
| 
32
 | 
100
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
288
 | 
     return $self->{+__PACKAGE__} = shift if @_;  | 
| 
33
 | 
93
 | 
 
 | 
  
 66
  
 | 
 
 | 
 
 | 
479
 | 
     $self->{+__PACKAGE__} ||= CGI::Header->new( query => $self->query );  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub header_add {  | 
| 
37
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
  
1
  
 | 
279601
 | 
     my $self   = shift;  | 
| 
38
 | 
35
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
153
 | 
     my @props  = ref $_[0] eq 'HASH' ? %{$_[0]} : @_;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
39
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
103
 | 
     my $header = $self->header;  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
41
 | 
35
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
749
 | 
     carp "header_add called while header_type set to 'none'" if $self->header_type eq 'none';  | 
| 
42
 | 
35
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
541
 | 
     croak "Odd number of elements passed to header_add" if @props % 2;  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
44
 | 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
135
 | 
     while ( my ($key, $value) = splice @props, 0, 2 ) {  | 
| 
45
 | 
35
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
141
 | 
         if ( ref $value eq 'ARRAY' ) {  | 
| 
46
 | 
6
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
46
 | 
             if ( $header->exists($key) ) {  | 
| 
47
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
104
 | 
                 my $existing_value = $header->get( $key );   | 
| 
48
 | 
3
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
80
 | 
                 if ( ref $existing_value eq 'ARRAY' ) {  | 
| 
49
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
                     $value = [ @$existing_value, @$value ];  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 else {  | 
| 
52
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
                     $value = [ $existing_value, @$value ];  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             else {  | 
| 
56
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
119
 | 
                 $value = [ @$value ];  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
60
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
139
 | 
         $header->set( $key => $value );  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
63
 | 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1161
 | 
     return;  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub header_props {  | 
| 
67
 | 
48
 | 
 
 | 
 
 | 
  
48
  
 | 
  
1
  
 | 
520713
 | 
     my $self   = shift;  | 
| 
68
 | 
48
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
172
 | 
     my @props  = ref $_[0] eq 'HASH' ? %{$_[0]} : @_;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
    | 
| 
69
 | 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
126
 | 
     my $header = $self->header;  | 
| 
70
 | 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
55060
 | 
     my $props  = $header->header;  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
48
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
249
 | 
     if ( @_ ) {  | 
| 
73
 | 
11
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
38
 | 
         carp "header_props called while header_type set to 'none'" if $self->header_type eq 'none';  | 
| 
74
 | 
11
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
547
 | 
         croak "Odd number of elements passed to header_props" if @props % 2;  | 
| 
75
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
42
 | 
         $header->clear->set(@props); # replace  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
78
 | 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
491
 | 
     map { ( "-$_" => $props->{$_} ) } keys %$props; # 'type' -> '-type'  | 
| 
 
 | 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
719
 | 
    | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |