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
|
|
121306
|
use strict qw(vars); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
67
|
|
21
|
2
|
|
|
2
|
|
10
|
use vars qw($VERSION $AUTOLOAD); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
102
|
|
22
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
23
|
2
|
|
|
2
|
|
8
|
no warnings qw(uninitialized); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# External modules |
27
|
|
|
|
|
|
|
# |
28
|
2
|
|
|
2
|
|
8
|
use Cwd qw(cwd); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
86
|
|
29
|
2
|
|
|
2
|
|
696
|
use Data::Dumper; |
|
2
|
|
|
|
|
10433
|
|
|
2
|
|
|
|
|
107
|
|
30
|
2
|
|
|
2
|
|
513
|
use HTTP::Status (RC_OK); |
|
2
|
|
|
|
|
6349
|
|
|
2
|
|
|
|
|
2016
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Version information |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
$VERSION='1.247'; |
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
|
72
|
my ($r, $key)=@_; |
54
|
20
|
|
|
|
|
90
|
return $ENV{$key}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub filename { |
60
|
|
|
|
|
|
|
|
61
|
24
|
|
|
24
|
0
|
39
|
my $r=shift(); |
62
|
24
|
|
|
|
|
52578
|
File::Spec->rel2abs($r->{'filename'}, cwd()); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub headers_out { |
68
|
|
|
|
|
|
|
|
69
|
10
|
|
|
10
|
0
|
29
|
my ($r, $k, $v)=@_; |
70
|
10
|
50
|
|
|
|
50
|
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
|
|
|
102
|
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
|
18
|
my $r=shift(); |
130
|
10
|
50
|
33
|
|
|
143
|
@_ ? $r->{'main'}=shift() : $r->{'main'} || $r; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub new { |
136
|
|
|
|
|
|
|
|
137
|
11
|
|
|
11
|
0
|
4338
|
my ($class, %r)=@_; |
138
|
11
|
|
|
|
|
48
|
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
|
19
|
my $r=shift(); |
182
|
10
|
|
50
|
|
|
28
|
my $fh=$r->{'select'} || \*STDOUT; |
183
|
10
|
50
|
|
|
|
57
|
CORE::print $fh ((ref($_[0]) eq 'SCALAR') ? ${$_[0]} : @_); |
|
10
|
|
|
|
|
137
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub register_cleanup { |
189
|
|
|
|
|
|
|
|
190
|
1
|
|
|
1
|
0
|
3
|
my $r=shift(); |
191
|
1
|
|
50
|
|
|
3
|
push @{$r->{'register_cleanup'} ||= []}, @_; |
|
1
|
|
|
|
|
11
|
|
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
|
39
|
my $r=shift(); |
207
|
20
|
50
|
50
|
|
|
169
|
@_ ? $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
|
15
|
my $r=shift(); |
260
|
10
|
50
|
|
|
|
32
|
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
|
|
|
|
|
52
|
$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
|
|
33048
|
my $r=shift(); |
305
|
21
|
100
|
|
|
|
206
|
if (my $cr_ar=delete $r->{'register_cleanup'}) { |
306
|
1
|
|
|
|
|
3
|
foreach my $cr (@{$cr_ar}) { |
|
1
|
|
|
|
|
4
|
|
307
|
1
|
|
|
|
|
6
|
$cr->($r); |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
} |