| 1 | package Lemonldap::Portal::Script; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | our $VERSION = '0.1'; | |||||||||
| 4 | |||||||||||
| 5 | { | ||||||||||
| 6 | |||||||||||
| 7 | 1 | package Lemonldap::Portal::Script::Exchange; | |||||||||
| 8 | |||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||
| 10 | 0 | my $class = shift; | |||||||||
| 11 | 0 | my %args = @_; | |||||||||
| 12 | 0 | my $self; | |||||||||
| 13 | 0 | $self = \%args; | |||||||||
| 14 | 0 | $self->{line} = []; | |||||||||
| 15 | 0 | bless $self, $class; | |||||||||
| 16 | 0 | return $self; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | sub set_method { | ||||||||
|
Subroutine
set_method: not called CC=2 SCAR=17.9
| |||||||||||
| 20 | 0 | my $self = shift; | |||||||||
| 21 | 0 | my $_line = shift; | |||||||||
| 22 | 0 | ▶ | if ( $_line =~ /^GET/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | $self->{method} = 'GET'; | |||||||||
| 24 | } | ||||||||||
| 25 | else { | ||||||||||
| 26 | 0 | $self->{method} = 'POST'; | |||||||||
| 27 | |||||||||||
| 28 | } | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub set_ResponseCode { | ||||||||
|
Subroutine
set_ResponseCode: not called CC=1 SCAR=6.9
| |||||||||||
| 32 | 0 | my $self = shift; | |||||||||
| 33 | 0 | my $_line = shift; | |||||||||
| 34 | 0 | ( $self->{responsecode} ) = $_line =~ /(\d\d\d)/; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub set_tirade { | ||||||||
|
Subroutine
set_tirade: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | 0 | my $self = shift; | |||||||||
| 39 | 0 | my $_table = shift; | |||||||||
| 40 | 0 | my $_question = shift; | |||||||||
| 41 | 0 | $self->{$_table} = $_question; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub set_status { | ||||||||
|
Subroutine
set_status: not called CC=1 SCAR=6.9
| |||||||||||
| 45 | 0 | my $self = shift; | |||||||||
| 46 | 0 | my $_value = shift; | |||||||||
| 47 | 0 | $self->{require} = $_value; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub add_string { | ||||||||
|
Subroutine
add_string: not called CC=1 SCAR=6.9
| |||||||||||
| 51 | 0 | my $self = shift; | |||||||||
| 52 | 0 | my $_value = shift; | |||||||||
| 53 | 0 | push @{ $self->{line} }, $_value; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: not called CC=2 SCAR=17.9
| |||||||||||
| 57 | 0 | my $self = shift; | |||||||||
| 58 | 0 | my $a .= $self->{requete} . "\n"; | |||||||||
| 59 | 0 | for ( @{ $self->{line} } ) { | |||||||||
| 60 | 0 | $a .= $_ . "\n"; | |||||||||
| 61 | } | ||||||||||
| 62 | 0 | return $a; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 1 | 1; | |||||||||
| 66 | |||||||||||
| 67 | package Lemonldap::Portal::Script::Response; | ||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||
| 70 | 0 | my $class = shift; | |||||||||
| 71 | 0 | my %args = @_; | |||||||||
| 72 | 0 | my $self; | |||||||||
| 73 | 0 | $self = \%args; | |||||||||
| 74 | 0 | $self->{headers} = []; | |||||||||
| 75 | 0 | $self->{headers_test} = []; | |||||||||
| 76 | 0 | $self->{headers_model} = []; | |||||||||
| 77 | 0 | bless $self, $class; | |||||||||
| 78 | 0 | return $self; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 0 | ▶ | sub add_header { | ||||||||
|
Subroutine
add_header: not called CC=3 SCAR=24.8
| |||||||||||
| 82 | 0 | my $self = shift; | |||||||||
| 83 | 0 | my $_line = shift; | |||||||||
| 84 | 0 | my %STORE = ( 'content-type' => 1, ); | |||||||||
| 85 | |||||||||||
| 86 | 0 | my %TEST_STORE = ( | |||||||||
| 87 | 'location' => "%LOCATION%", | ||||||||||
| 88 | 'set-cookie' => "%SETCOOKIE%", | ||||||||||
| 89 | ); | ||||||||||
| 90 | 0 | ( my $_header, my $_value ) = $_line =~ /(^.+?):\s(.+)/; | |||||||||
| 91 | |||||||||||
| 92 | 0 | $_value =~ s/^ +//; | |||||||||
| 93 | 0 | ▶ | if ( $TEST_STORE{ lc($_header) } ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | 0 | push @{ $self->{headers_test} }, $_header . "#" . $_value; | |||||||||
| 95 | 0 | push @{ $self->{headers_model} }, | |||||||||
| 96 | 0 | $_header . "#" . $TEST_STORE{ lc($_header) }; | |||||||||
| 97 | } | ||||||||||
| 98 | 0 | ▶ | if ( $STORE{ lc($_header) } ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 0 | push @{ $self->{headers} }, $_header . "#" . $_value; | |||||||||
| 100 | } | ||||||||||
| 101 | |||||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | 1 | 1; | |||||||||
| 105 | |||||||||||
| 106 | package Lemonldap::Portal::Script::Question; | ||||||||||
| 107 | |||||||||||
| 108 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||
| 109 | 0 | my $class = shift; | |||||||||
| 110 | 0 | my %args = @_; | |||||||||
| 111 | 0 | my $self; | |||||||||
| 112 | 0 | $self = \%args; | |||||||||
| 113 | 0 | $self->{headers} = []; | |||||||||
| 114 | 0 | $self->{headers_test} = []; | |||||||||
| 115 | 0 | $self->{headers_model} = []; | |||||||||
| 116 | 0 | bless $self, $class; | |||||||||
| 117 | 0 | return $self; | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | 0 | ▶ | sub add_header { | ||||||||
|
Subroutine
add_header: not called CC=4 SCAR=30.0
| |||||||||||
| 121 | 0 | my $self = shift; | |||||||||
| 122 | 0 | my $_line = shift; | |||||||||
| 123 | 0 | my %NO_STORE = ( | |||||||||
| 124 | 'accept-encoding' => 1, | ||||||||||
| 125 | 'keep-alive' => 1, | ||||||||||
| 126 | 'connection' => 1, | ||||||||||
| 127 | 'host' => 1, | ||||||||||
| 128 | ); | ||||||||||
| 129 | 0 | my %TEST_STORE = ( | |||||||||
| 130 | 'user-agent' => "%AGENT%", | ||||||||||
| 131 | 'cookie' => "%COOKIE%", | ||||||||||
| 132 | ); | ||||||||||
| 133 | 0 | ( my $_header, my $_value ) = $_line =~ /(^.+?):\s(.+)/; | |||||||||
| 134 | 0 | ▶ | if ( !$_header ) { ## it is value | ||||||||
|
Branch: 1 branch
| |||||||||||
| 135 | 0 | push @{ $self->{DATA} }, $_line; | |||||||||
| 136 | 0 | return; | |||||||||
| 137 | } | ||||||||||
| 138 | |||||||||||
| 139 | 0 | ▶ | return if $NO_STORE{ lc($_header) }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 140 | 0 | $_value =~ s/^ +//; | |||||||||
| 141 | 0 | ▶ | if ( $TEST_STORE{ lc($_header) } ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 142 | 0 | push @{ $self->{headers_test} }, $_header . "#" . $_value; | |||||||||
| 143 | 0 | push @{ $self->{headers_model} }, | |||||||||
| 144 | 0 | $_header . "#" . $TEST_STORE{ lc($_header) }; | |||||||||
| 145 | } | ||||||||||
| 146 | else { | ||||||||||
| 147 | 0 | push @{ $self->{headers} }, $_header . "#" . $_value; | |||||||||
| 148 | } | ||||||||||
| 149 | } | ||||||||||
| 150 | |||||||||||
| 151 | 1 | 1; | |||||||||
| 152 | |||||||||||
| 153 | } | ||||||||||
| 154 | 1 | 1; | |||||||||
| 155 | |||||||||||
| 156 | __END__ | ||||||||||