line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of WebDyne. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2017 by Andrew Speer . |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU General Public License, Version 2, June 1991 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Full license text is available at: |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package WebDyne::Request::Fake; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Compiler Pragma |
19
|
|
|
|
|
|
|
# |
20
|
2
|
|
|
2
|
|
116192
|
use strict qw(vars); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
81
|
|
21
|
2
|
|
|
2
|
|
13
|
use vars qw($VERSION $AUTOLOAD); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
97
|
|
22
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
46
|
|
23
|
2
|
|
|
2
|
|
8
|
no warnings qw(uninitialized); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
83
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# External modules |
27
|
|
|
|
|
|
|
# |
28
|
2
|
|
|
2
|
|
13
|
use Cwd qw(cwd); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
93
|
|
29
|
2
|
|
|
2
|
|
693
|
use Data::Dumper; |
|
2
|
|
|
|
|
9805
|
|
|
2
|
|
|
|
|
116
|
|
30
|
2
|
|
|
2
|
|
486
|
use HTTP::Status (RC_OK); |
|
2
|
|
|
|
|
6049
|
|
|
2
|
|
|
|
|
1951
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Version information |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
$VERSION='1.248'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Debug load |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
0 && debug("Loading %s version $VERSION", __PACKAGE__); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# All done. Positive return |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#================================================================================================== |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub dir_config { |
52
|
|
|
|
|
|
|
|
53
|
20
|
|
|
20
|
0
|
71
|
my ($r, $key)=@_; |
54
|
20
|
|
|
|
|
78
|
return $ENV{$key}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub filename { |
60
|
|
|
|
|
|
|
|
61
|
24
|
|
|
24
|
0
|
46
|
my $r=shift(); |
62
|
24
|
|
|
|
|
46952
|
File::Spec->rel2abs($r->{'filename'}, cwd()); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub headers_out { |
68
|
|
|
|
|
|
|
|
69
|
10
|
|
|
10
|
0
|
20
|
my ($r, $k, $v)=@_; |
70
|
10
|
50
|
|
|
|
41
|
if (@_ == 3) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
return $r->{'headers_out'}{$k}=$v |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
elsif (@_ == 2) { |
74
|
0
|
|
|
|
|
0
|
return $r->{'headers_out'}{$k} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
elsif (@_ == 1) { |
77
|
10
|
|
50
|
|
|
77
|
return ($r->{'headers_out'} ||= {}); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
0
|
|
|
|
|
0
|
return err ('incorrect usage of %s headers_out object, r->headers_out(%s)', +__PACKAGE__, join(',', @_[1..$#_])); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub headers_in { |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
0
|
0
|
0
|
my $r=shift(); |
89
|
0
|
|
0
|
|
|
0
|
$r->{'headers_in'} ||= {}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub is_main { |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
0
|
0
|
0
|
my $r=shift(); |
97
|
0
|
0
|
|
|
|
0
|
$r->{'main'} ? 0 : 1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub log_error { |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
0
|
0
|
my $r=shift(); |
105
|
0
|
0
|
|
|
|
0
|
warn(@_) unless $r->notes('nowarn'); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub lookup_file { |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
0
|
0
|
0
|
my ($r, $fn)=@_; |
113
|
0
|
|
0
|
|
|
0
|
my $r_child=ref($r)->new(filename => $fn) || return err (); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub lookup_uri { |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
0
|
0
|
0
|
my ($r, $uri)=@_; |
121
|
0
|
|
|
|
|
0
|
my $fn=File::Spec::Unix->catfile((File::Spec->splitpath($r->filename()))[1], $uri); |
122
|
0
|
|
|
|
|
0
|
return $r->lookup_file($fn); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub main { |
128
|
|
|
|
|
|
|
|
129
|
10
|
|
|
10
|
0
|
19
|
my $r=shift(); |
130
|
10
|
50
|
33
|
|
|
131
|
@_ ? $r->{'main'}=shift() : $r->{'main'} || $r; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub new { |
136
|
|
|
|
|
|
|
|
137
|
11
|
|
|
11
|
0
|
4049
|
my ($class, %r)=@_; |
138
|
11
|
|
|
|
|
47
|
return bless \%r, $class; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub notes { |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
0
|
0
|
0
|
my ($r, $k, $v)=@_; |
146
|
0
|
0
|
|
|
|
0
|
if (@_ == 3) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
147
|
0
|
|
|
|
|
0
|
return $r->{'_notes'}{$k}=$v |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
elsif (@_ == 2) { |
150
|
0
|
|
|
|
|
0
|
return $r->{'_notes'}{$k} |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
elsif (@_ == 1) { |
153
|
0
|
|
0
|
|
|
0
|
return ($r->{'_notes'} ||= {}); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
else { |
156
|
0
|
|
|
|
|
0
|
return err ('incorrect usage of %s notes object, r->notes(%s)', +__PACKAGE__, join(',', @_[1..$#_])); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub parsed_uri { |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
0
|
0
|
0
|
my $r=shift(); |
165
|
0
|
|
|
|
|
0
|
require URI; |
166
|
0
|
|
|
|
|
0
|
URI->new($r->uri()); |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub prev { |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
0
|
0
|
0
|
my $r=shift(); |
174
|
0
|
0
|
|
|
|
0
|
@_ ? $r->{'prev'}=shift() : $r->{'prev'}; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub print { |
180
|
|
|
|
|
|
|
|
181
|
10
|
|
|
10
|
0
|
26
|
my $r=shift(); |
182
|
10
|
|
50
|
|
|
28
|
my $fh=$r->{'select'} || \*STDOUT; |
183
|
10
|
50
|
|
|
|
26
|
CORE::print $fh ((ref($_[0]) eq 'SCALAR') ? ${$_[0]} : @_); |
|
10
|
|
|
|
|
112
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub register_cleanup { |
189
|
|
|
|
|
|
|
|
190
|
1
|
|
|
1
|
0
|
3
|
my $r=shift(); |
191
|
1
|
|
50
|
|
|
2
|
push @{$r->{'register_cleanup'} ||= []}, @_; |
|
1
|
|
|
|
|
8
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub run { |
197
|
|
|
|
|
|
|
|
198
|
0
|
|
|
0
|
0
|
0
|
my ($r, $self)=@_; |
199
|
0
|
|
0
|
|
|
0
|
(ref($self) || $self)->handler($r); |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub status { |
205
|
|
|
|
|
|
|
|
206
|
20
|
|
|
20
|
0
|
36
|
my $r=shift(); |
207
|
20
|
50
|
50
|
|
|
156
|
@_ ? $r->{'status'}=shift() : $r->{'status'} || RC_OK; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub uri { |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
0
|
0
|
0
|
shift()->{'filename'} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
0
|
0
|
|
sub debug { |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# Stub |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
0
|
0
|
|
sub output_filters { |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# Stub |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
231
|
|
|
|
10
|
0
|
|
sub location { |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# Stub |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
10
|
0
|
|
sub header_only { |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# Stub |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
0
|
0
|
|
sub set_handlers { |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# Stub |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub noheader { |
250
|
|
|
|
|
|
|
|
251
|
0
|
|
|
0
|
0
|
0
|
my $r=shift(); |
252
|
0
|
0
|
|
|
|
0
|
@_ ? $r->{'noheader'}=shift() : $r->{'noheader'}; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub send_http_header { |
258
|
|
|
|
|
|
|
|
259
|
10
|
|
|
10
|
0
|
18
|
my $r=shift(); |
260
|
10
|
50
|
|
|
|
27
|
return if $r->{'noheader'}; |
261
|
0
|
|
0
|
|
|
0
|
my $fh=$r->{'select'} || \*STDOUT; |
262
|
0
|
|
|
|
|
0
|
CORE::printf $fh ("Status: %s\n", $r->status()); |
263
|
0
|
|
|
|
|
0
|
while (my ($header, $value)=each(%{$r->{'headers_out'}})) { |
|
0
|
|
|
|
|
0
|
|
264
|
0
|
|
|
|
|
0
|
CORE::print $fh ("$header: $value\n"); |
265
|
|
|
|
|
|
|
} |
266
|
0
|
|
|
|
|
0
|
CORE::print $fh "\n"; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub content_type { |
272
|
|
|
|
|
|
|
|
273
|
10
|
|
|
10
|
0
|
28
|
my ($r, $content_type)=@_; |
274
|
10
|
|
|
|
|
41
|
$r->{'header'}{'Content-Type'}=$content_type; |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
#CORE::print("Content-Type: $content_type\n"); |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
sub custom_response { |
282
|
|
|
|
|
|
|
|
283
|
0
|
|
|
0
|
0
|
0
|
my ($r, $status)=(shift, shift); |
284
|
0
|
|
|
|
|
0
|
$r->status($status); |
285
|
0
|
|
|
|
|
0
|
$r->send_http_header(); |
286
|
0
|
|
|
|
|
0
|
$r->print(@_); |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub AUTOLOAD { |
292
|
|
|
|
|
|
|
|
293
|
0
|
|
|
0
|
|
0
|
my ($r, $v)=@_; |
294
|
0
|
|
0
|
|
|
0
|
my $k=($AUTOLOAD=~/([^:]+)$/) && $1; |
295
|
0
|
|
|
|
|
0
|
warn(sprintf("Unhandled '%s' method, using AUTOLOAD", $k)); |
296
|
0
|
0
|
|
|
|
0
|
$v ? $r->{$k}=$v : $r->{$k}; |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
} |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub DESTROY { |
303
|
|
|
|
|
|
|
|
304
|
21
|
|
|
21
|
|
31327
|
my $r=shift(); |
305
|
21
|
100
|
|
|
|
219
|
if (my $cr_ar=delete $r->{'register_cleanup'}) { |
306
|
1
|
|
|
|
|
2
|
foreach my $cr (@{$cr_ar}) { |
|
1
|
|
|
|
|
7
|
|
307
|
1
|
|
|
|
|
5
|
$cr->($r); |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
} |