File Coverage

blib/lib/Lemonldap/Portal/Script.pm
Criterion Covered Total %
statement 0 82 0.0
branch 0 12 0.0
condition n/a
subroutine 0 11 0.0
pod n/a
total 0 105 0.0


line stmt bran cond sub pod time code
1             package Lemonldap::Portal::Script;
2              
3             our $VERSION = '0.1';
4              
5             {
6              
7             package Lemonldap::Portal::Script::Exchange;
8              
9             sub new {
10 0     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             sub set_method {
20 0     0     my $self = shift;
21 0           my $_line = shift;
22 0 0         if ( $_line =~ /^GET/ ) {
23 0           $self->{method} = 'GET';
24             }
25             else {
26 0           $self->{method} = 'POST';
27              
28             }
29             }
30              
31             sub set_ResponseCode {
32 0     0     my $self = shift;
33 0           my $_line = shift;
34 0           ( $self->{responsecode} ) = $_line =~ /(\d\d\d)/;
35             }
36              
37             sub set_tirade {
38 0     0     my $self = shift;
39 0           my $_table = shift;
40 0           my $_question = shift;
41 0           $self->{$_table} = $_question;
42             }
43              
44             sub set_status {
45 0     0     my $self = shift;
46 0           my $_value = shift;
47 0           $self->{require} = $_value;
48             }
49              
50             sub add_string {
51 0     0     my $self = shift;
52 0           my $_value = shift;
53 0           push @{ $self->{line} }, $_value;
  0            
54             }
55              
56             sub as_string {
57 0     0     my $self = shift;
58 0           my $a .= $self->{requete} . "\n";
59 0           for ( @{ $self->{line} } ) {
  0            
60 0           $a .= $_ . "\n";
61             }
62 0           return $a;
63             }
64              
65             1;
66              
67             package Lemonldap::Portal::Script::Response;
68              
69             sub new {
70 0     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             sub add_header {
82 0     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 0         if ( $TEST_STORE{ lc($_header) } ) {
94 0           push @{ $self->{headers_test} }, $_header . "#" . $_value;
  0            
95 0           push @{ $self->{headers_model} },
  0            
96             $_header . "#" . $TEST_STORE{ lc($_header) };
97             }
98 0 0         if ( $STORE{ lc($_header) } ) {
99 0           push @{ $self->{headers} }, $_header . "#" . $_value;
  0            
100             }
101              
102             }
103              
104             1;
105              
106             package Lemonldap::Portal::Script::Question;
107              
108             sub new {
109 0     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             sub add_header {
121 0     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 0         if ( !$_header ) { ## it is value
135 0           push @{ $self->{DATA} }, $_line;
  0            
136 0           return;
137             }
138              
139 0 0         return if $NO_STORE{ lc($_header) };
140 0           $_value =~ s/^ +//;
141 0 0         if ( $TEST_STORE{ lc($_header) } ) {
142 0           push @{ $self->{headers_test} }, $_header . "#" . $_value;
  0            
143 0           push @{ $self->{headers_model} },
  0            
144             $_header . "#" . $TEST_STORE{ lc($_header) };
145             }
146             else {
147 0           push @{ $self->{headers} }, $_header . "#" . $_value;
  0            
148             }
149             }
150              
151             1;
152              
153             }
154             1;
155              
156             __END__