line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mock::Apache::Emulation; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
############################################################################## |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package # hide from PAUSE indexer |
7
|
|
|
|
|
|
|
Apache; |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
26
|
use Carp; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
372
|
|
10
|
5
|
|
|
5
|
|
2735
|
use HTTP::Request; |
|
5
|
|
|
|
|
2801
|
|
|
5
|
|
|
|
|
129
|
|
11
|
5
|
|
|
5
|
|
27
|
use Readonly; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
239
|
|
12
|
5
|
|
|
5
|
|
35
|
use Scalar::Util qw(weaken); |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
457
|
|
13
|
5
|
|
|
5
|
|
29
|
use URI; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
125
|
|
14
|
5
|
|
|
5
|
|
4196
|
use URI::QueryParam; |
|
5
|
|
|
|
|
4295
|
|
|
5
|
|
|
|
|
165
|
|
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
32
|
use parent qw(Class::Accessor); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
41
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw( log |
19
|
|
|
|
|
|
|
_env |
20
|
|
|
|
|
|
|
_uri |
21
|
|
|
|
|
|
|
_mock_client |
22
|
|
|
|
|
|
|
_output |
23
|
|
|
|
|
|
|
)); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $server; |
26
|
|
|
|
|
|
|
our $request; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Create a new Apache request |
29
|
|
|
|
|
|
|
# Apache->_new_request($mock_client, @params) |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _new_request { |
32
|
4
|
|
|
4
|
|
8
|
my $class = shift; |
33
|
4
|
|
|
|
|
8
|
my $mock_client = shift; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Set up environment for later - %ENV entries will be localized |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
74
|
my $env = { GATEWAY_INTERFACE => 'CGI-Perl/1.1', |
38
|
|
|
|
|
|
|
MOD_PERL => '1.3', |
39
|
|
|
|
|
|
|
SERVER_SOFTWARE => 'Apache emulation (Mock::Apache)', |
40
|
|
|
|
|
|
|
REMOTE_ADDR => $mock_client->remote_addr, |
41
|
|
|
|
|
|
|
REMOTE_HOST => $mock_client->remote_host }; |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
227
|
my $r = $class->SUPER::new( { request_time => time, |
44
|
|
|
|
|
|
|
is_initial_req => 1, |
45
|
|
|
|
|
|
|
is_main => 1, |
46
|
|
|
|
|
|
|
server => $mock_client->mock_apache->server, |
47
|
|
|
|
|
|
|
connection => $mock_client->connection, |
48
|
|
|
|
|
|
|
_mock_client => $mock_client, |
49
|
|
|
|
|
|
|
_env => $env, |
50
|
|
|
|
|
|
|
_output => '', |
51
|
|
|
|
|
|
|
} ); |
52
|
|
|
|
|
|
|
|
53
|
4
|
|
|
|
|
279
|
local $Mock::Apache::DEBUG = 0; |
54
|
|
|
|
|
|
|
|
55
|
4
|
|
33
|
|
|
58
|
$r->{log} ||= $r->{server}->log; |
56
|
4
|
|
|
|
|
249
|
$r->{notes} = Apache::Table->new($r); |
57
|
4
|
|
|
|
|
16
|
$r->{pnotes} = Apache::Table->new($r, 1); |
58
|
4
|
|
|
|
|
14
|
$r->{headers_in} = Apache::Table->new($r); |
59
|
4
|
|
|
|
|
14
|
$r->{headers_out} = Apache::Table->new($r); |
60
|
4
|
|
|
|
|
16
|
$r->{err_headers_out} = Apache::Table->new($r); |
61
|
4
|
|
|
|
|
14
|
$r->{subprocess_env} = Apache::Table->new($r); |
62
|
|
|
|
|
|
|
|
63
|
4
|
|
|
|
|
7
|
$request = $r; |
64
|
4
|
|
|
|
|
10
|
$server = $r->{server}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Having set up a skeletal request object, see about fleshing out the detail |
67
|
|
|
|
|
|
|
|
68
|
4
|
100
|
|
|
|
73
|
my $initializer = (@_ == 1) ? shift : HTTP::Request->new(@_); |
69
|
4
|
50
|
|
|
|
41472
|
croak('request initializer must be an HTTP:Request object') |
70
|
|
|
|
|
|
|
unless $initializer->isa('HTTP::Request'); |
71
|
4
|
|
|
|
|
27
|
$r->_initialize_from_http_request_object($initializer); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Expand the environment with information from server object |
75
|
|
|
|
|
|
|
|
76
|
4
|
|
33
|
|
|
42
|
$env->{DOCUMENT_ROOT} ||= $r->document_root; |
77
|
4
|
|
33
|
|
|
39
|
$env->{SERVER_ADMIN} ||= $server->server_admin; |
78
|
4
|
|
33
|
|
|
37
|
$env->{SERVER_NAME} ||= $server->server_hostname; |
79
|
4
|
|
33
|
|
|
33
|
$env->{SERVER_PORT} ||= $r->get_server_port; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# TODO: AUTH_TYPE, CONTENT_LENGTH, CONTENT_TYPE, PATH_INFO, |
82
|
|
|
|
|
|
|
# PATH_TRANSLATED, QUERY_STRING, REMOTE_IDENT, REMOTE_USER, |
83
|
|
|
|
|
|
|
# REQUEST_METHOD, SCRIPT_NAME, SERVER_PROTOCOL, UNIQUE_ID |
84
|
|
|
|
|
|
|
|
85
|
4
|
|
|
|
|
25
|
while (my($key, $val) = each %$env) { |
86
|
36
|
|
|
|
|
607
|
$r->{subprocess_env}->set($key, $val); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
4
|
|
|
|
|
130
|
return $r; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _initialize_from_http_request_object { |
93
|
4
|
|
|
4
|
|
10
|
my ($r, $http_req) = @_; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# $DB::single=1; |
96
|
|
|
|
|
|
|
|
97
|
4
|
|
|
|
|
25
|
my $uri = $http_req->uri; |
98
|
4
|
50
|
|
|
|
49
|
$uri = URI->new($uri) unless ref $uri; |
99
|
|
|
|
|
|
|
|
100
|
4
|
|
|
|
|
21
|
$r->{method} = $http_req->method; |
101
|
4
|
|
|
|
|
71
|
$r->{_uri} = $uri; |
102
|
4
|
|
|
|
|
48
|
($r->{uri} = $uri->path) =~ s{^/}{}; |
103
|
4
|
|
|
|
|
593
|
$r->{protocol} = 'HTTP/1.1'; |
104
|
4
|
|
|
|
|
37
|
$r->{content} = $http_req->content; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$http_req->headers->scan( sub { |
107
|
0
|
|
|
0
|
|
0
|
my ($key, $value) = @_; |
108
|
0
|
|
|
|
|
0
|
$r->headers_in->set($key, $value); |
109
|
0
|
|
|
|
|
0
|
(my $header_env = "HTTP_$key") =~ s/-/_/g; |
110
|
0
|
|
|
|
|
0
|
$r->{subprocess_env}->set($header_env, $value); |
111
|
4
|
|
|
|
|
82
|
} ); |
112
|
|
|
|
|
|
|
|
113
|
4
|
|
|
|
|
143
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
################################################################################ |
117
|
|
|
|
|
|
|
# |
118
|
|
|
|
|
|
|
# The Request Object MPPR p23 |
119
|
|
|
|
|
|
|
# |
120
|
|
|
|
|
|
|
# Handlers are called with a reference to the current request object (Apache), |
121
|
|
|
|
|
|
|
# which by convention is named $r. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# $r = Apache->request([$r]) MPPR p23 |
124
|
|
|
|
|
|
|
# Returns a reference to the request object. Perl handlers are called with a |
125
|
|
|
|
|
|
|
# reference to the request object as the first argument. |
126
|
|
|
|
|
|
|
sub request { |
127
|
0
|
|
|
0
|
0
|
0
|
DEBUG('Apache->request => ' . $request); |
128
|
0
|
|
|
|
|
0
|
return $request |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# $bool = $r->is_initial_req MPPR p23 |
132
|
|
|
|
|
|
|
# Returns true if the current request is the initial request, and false if it is |
133
|
|
|
|
|
|
|
# a subrequest or an internal redirect. |
134
|
|
|
|
|
|
|
sub is_initial_req { |
135
|
2
|
|
|
2
|
0
|
783
|
my ($r) = @_; |
136
|
2
|
|
|
|
|
5
|
my $bool = $r->{is_initial_req}; |
137
|
2
|
50
|
|
|
|
15
|
DEBUG('$r->is_initial_req => %s', $bool ? 'true' : 'false'); |
138
|
2
|
|
|
|
|
7
|
return $bool; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# $bool = $r->is_main MPPR p23 |
142
|
|
|
|
|
|
|
# Returns true if the current request is the initial request or an internal |
143
|
|
|
|
|
|
|
# redirect, and false if it is a subrequest. |
144
|
|
|
|
|
|
|
sub is_main { |
145
|
2
|
|
|
2
|
0
|
4
|
my ($r) = @_; |
146
|
2
|
|
|
|
|
5
|
my $bool = $r->{is_main}; |
147
|
2
|
50
|
|
|
|
12
|
DEBUG('$r->is_main => %s', $bool ? 'true' : 'false'); |
148
|
2
|
|
|
|
|
8
|
return $bool; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# $req = $r->last MPPR p24 |
152
|
|
|
|
|
|
|
# Returns a reference to the last request object in the chain. When used in a |
153
|
|
|
|
|
|
|
# logging handler, this is the request object that generated the final result. |
154
|
|
|
|
|
|
|
sub last { |
155
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
156
|
0
|
|
|
|
|
0
|
my $req = undef; |
157
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->last => %s', ref $req ? $req : 'undef'); |
158
|
0
|
|
|
|
|
0
|
return $req; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# $req = $r->main MPPR p24 |
162
|
|
|
|
|
|
|
# Returns a reference to the main (intitial) request object, or undef if $r is |
163
|
|
|
|
|
|
|
# the main request obeject. |
164
|
|
|
|
|
|
|
sub main { |
165
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
166
|
0
|
|
|
|
|
0
|
my $req = $r->{main}; |
167
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->main => %s', ref $req ? $req : 'undef'); |
168
|
0
|
|
|
|
|
0
|
return $req; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# $req = $r->next MPPR p24 |
172
|
|
|
|
|
|
|
# Returns a reference to the next request object in the chain. |
173
|
|
|
|
|
|
|
sub next { |
174
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
175
|
0
|
|
|
|
|
0
|
my $req = undef; |
176
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->next => %s', ref $req ? $req : 'undef'); |
177
|
0
|
|
|
|
|
0
|
return $req; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# $req = $r->prev MPPR p24 |
181
|
|
|
|
|
|
|
# Returns a reference to the previous request object in the chain. When used in |
182
|
|
|
|
|
|
|
# an error handler, this is the request that triggered the error. |
183
|
|
|
|
|
|
|
sub prev { |
184
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
185
|
0
|
|
|
|
|
0
|
my $req = undef; |
186
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->prev => %s', ref $req ? $req : 'undef'); |
187
|
0
|
|
|
|
|
0
|
return $req; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
################################################################################ |
192
|
|
|
|
|
|
|
# |
193
|
|
|
|
|
|
|
# The Apache::SubRequest Class MPPR p24 |
194
|
|
|
|
|
|
|
# |
195
|
|
|
|
|
|
|
# The Apache::SubRequest Class is a subclass of Apache and inherits its methods. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# $subr = $r->lookup_file($filename) MPPR p24 |
198
|
|
|
|
|
|
|
# Fetches a subrequest object by filename. |
199
|
|
|
|
|
|
|
sub lookup_file { |
200
|
0
|
|
|
0
|
0
|
0
|
my ($r, $file) = @_; |
201
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
0
|
$DB::single=1; |
203
|
0
|
|
|
|
|
0
|
return $r->new( uri => $file, |
204
|
|
|
|
|
|
|
is_initial_req => 0 ); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# $subr = $r->lookup_uri($uri) MPPR p24 |
208
|
|
|
|
|
|
|
# Fetches a subrequest object by URI. |
209
|
|
|
|
|
|
|
sub lookup_uri { |
210
|
0
|
|
|
0
|
0
|
0
|
my ($r, $uri) = @_; |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
0
|
$DB::single=1; |
213
|
0
|
|
|
|
|
0
|
return $r->new( uri => $uri, |
214
|
|
|
|
|
|
|
is_initial_req => 0 ); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# $subr->run MPPR p24 |
219
|
|
|
|
|
|
|
# Invokes the subrequest's content handler and the returns the content handler's |
220
|
|
|
|
|
|
|
# status code. |
221
|
|
|
|
|
|
|
{ |
222
|
|
|
|
|
|
|
package |
223
|
|
|
|
|
|
|
Apache::SubRequest; |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
our @ISA = qw(Apache); |
226
|
|
|
|
|
|
|
sub run { |
227
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
228
|
0
|
|
|
|
|
0
|
NYI_DEBUG('$r->run'); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
################################################################################ |
234
|
|
|
|
|
|
|
# |
235
|
|
|
|
|
|
|
# Client request methods MPPR p24 |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# {$str|@arr} = $r->args MPPR p24 |
238
|
|
|
|
|
|
|
# FIXME: query_form_hash does not return the right data if keys are repeated |
239
|
|
|
|
|
|
|
sub args { |
240
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
241
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->args => %s', wantarray ? '( @list )' : $r->_uri->query); |
242
|
0
|
0
|
|
|
|
0
|
return wantarray ? $r->_uri->query_form_hash : $r->_uri->query; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# $c = $r->connection MPPR p25 |
246
|
|
|
|
|
|
|
sub connection { |
247
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
248
|
0
|
|
|
|
|
0
|
my $connection = $r->{connection}; |
249
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->connection => %s', ref $connection ? $connection : 'undef'); |
250
|
0
|
|
|
|
|
0
|
return $connection; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
# {$str|@arr} = $r->content MPPR p25 |
254
|
|
|
|
|
|
|
sub content { |
255
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
256
|
0
|
|
|
|
|
0
|
my $content = $r->{content}; |
257
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->content => %s', |
258
|
|
|
|
|
|
|
wantarray ? '( \'' . substr($content, 0, 20) . '...\'' : substr($content, 0, 20) . '...'); |
259
|
0
|
0
|
|
|
|
0
|
return wantarray ? split(qr{\n}, $content) : $content; |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# $str = $r->filename([$newfilename]) MPPR p25 |
264
|
|
|
|
|
|
|
sub filename { |
265
|
0
|
|
|
0
|
0
|
0
|
my ($r, $newfilename) = @_; |
266
|
0
|
|
|
|
|
0
|
my $filename = $r->{filename}; |
267
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->filename(%s)%s', |
|
|
0
|
|
|
|
|
|
268
|
|
|
|
|
|
|
@_ > 1 ? "'$newfilename'" : '', |
269
|
|
|
|
|
|
|
defined wantarray ? " => $filename" : ''); |
270
|
0
|
0
|
|
|
|
0
|
$r->{filename} = $newfilename if @_ > 1; |
271
|
0
|
|
|
|
|
0
|
return $filename; |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
# $handle = $r->finfo() MPPR p25 |
275
|
|
|
|
|
|
|
sub finfo { |
276
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
277
|
0
|
|
|
|
|
0
|
NYI_DEBUG('$r->finfo'); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
# $str = $r->get_remote_host([$lookup_type]) MPPR p25 |
281
|
|
|
|
|
|
|
# FIXME: emulate lookups properly |
282
|
|
|
|
|
|
|
sub get_remote_host { |
283
|
0
|
|
|
0
|
0
|
0
|
my ($r, $type) = @_; |
284
|
0
|
|
|
|
|
0
|
DEBUG('$r->get_remote_host(%s)', $type); |
285
|
0
|
0
|
0
|
|
|
0
|
if (@_ == 0 or $type == $Apache::Constant::REMOTE_HOST) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
286
|
0
|
|
|
|
|
0
|
return $r->_mock_client->remote_host; |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
elsif ($type == $Apache::Constant::REMOTE_ADDR) { |
289
|
0
|
|
|
|
|
0
|
return $r->_mock_client->remote_addr; |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
elsif ($type == $Apache::Constant::REMOTE_NOLOOKUP) { |
292
|
0
|
|
|
|
|
0
|
return $r->_mock_client->remote_addr; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
elsif ($type == $Apache::Constant::REMOTE_DOUBLE_REV) { |
295
|
0
|
|
|
|
|
0
|
return $r->_mock_client->remote_addr; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
else { |
298
|
0
|
|
|
|
|
0
|
croak "unknown lookup type"; |
299
|
|
|
|
|
|
|
} |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# $str = $r->get_remote_logname MPPR p26 |
303
|
|
|
|
|
|
|
sub get_remote_logname { |
304
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
305
|
0
|
|
|
|
|
0
|
NYI_DEBUG('$r->get_remote_logname'); |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
# $str = $r->header_in($key[, $value]) MPPR p26 |
309
|
|
|
|
|
|
|
# $str = $r->header_out($key[, $value]) MPPR p26 |
310
|
|
|
|
|
|
|
# $str = $r->err_header_out($key[, $value]) MPPR p26 |
311
|
0
|
|
|
0
|
0
|
0
|
sub header_in { shift->{headers_in}->_get_or_set(@_); } |
312
|
9
|
|
|
9
|
0
|
74
|
sub header_out { shift->{headers_out}->_get_or_set(@_); } |
313
|
0
|
|
|
0
|
0
|
0
|
sub err_header_out { shift->{err_headers_out}->_get_or_set(@_); } |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
# {$href|%hash} = $r->headers_in MPPR p26 |
316
|
|
|
|
|
|
|
# {$href|%hash} = $r->headers_out MPPR p26 |
317
|
|
|
|
|
|
|
# {$href|%hash} = $r->err_headers_out MPPR p26 |
318
|
0
|
|
|
0
|
0
|
0
|
sub headers_in { shift->{headers_in}->_hash_or_list; } |
319
|
9
|
|
|
9
|
0
|
28
|
sub headers_out { shift->{headers_out}->_hash_or_list; } |
320
|
0
|
|
|
0
|
0
|
0
|
sub err_headers_out { shift->{err_headers_out}->_hash_or_list; } |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
# $bool = $r->header_only MPPR p26 |
324
|
|
|
|
|
|
|
sub header_only { |
325
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
326
|
0
|
|
|
|
|
0
|
my $bool = $r->{method} eq 'HEAD'; |
327
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->header_only => %s', $bool ? 'true' : 'false'); |
328
|
0
|
|
|
|
|
0
|
return $bool; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
# $str = $r->method([$newval]) MPPR p26 |
332
|
|
|
|
|
|
|
# FIXME: method should be settable |
333
|
|
|
|
|
|
|
sub method { |
334
|
0
|
|
|
0
|
0
|
0
|
my ($r, $newval) = @_; |
335
|
0
|
|
|
|
|
0
|
my $val = $r->{method}; |
336
|
0
|
|
|
|
|
0
|
DEBUG('\$r->(\'%s\') => \'%s\'', $newval, $val); |
337
|
0
|
0
|
|
|
|
0
|
if (@_ > 1) { |
338
|
0
|
|
|
|
|
0
|
$r->{method} = $newval; |
339
|
|
|
|
|
|
|
} |
340
|
0
|
|
|
|
|
0
|
return $val; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
# $num = $r->method_number([$newval]) MPPR p26 |
344
|
|
|
|
|
|
|
# FIXME: deal with newval (need to update method) |
345
|
|
|
|
|
|
|
sub method_number { |
346
|
0
|
|
|
0
|
0
|
0
|
my ($r, $newval) = @_; |
347
|
0
|
|
|
|
|
0
|
my $method = eval '&Apache::Constants::M_' . $_[0]->{method}; |
348
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->method_number(%s) => %d', @_ > 1 ? $newval : '', $method); |
349
|
0
|
|
|
|
|
0
|
return $method; |
350
|
|
|
|
|
|
|
} |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
# $str = $r->parsed_uri MPPR p26 |
353
|
|
|
|
|
|
|
sub parsed_uri { |
354
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
355
|
0
|
|
|
|
|
0
|
my $uri = $r->{_uri}; |
356
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->parsed_uri => %s', ref $uri ? $uri : 'undef'); |
357
|
0
|
|
|
|
|
0
|
return $uri; |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# $str = $r->path_info([$newval]) MPPR p26 |
361
|
|
|
|
|
|
|
sub path_info { |
362
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
363
|
0
|
|
|
|
|
0
|
my $str = $r->{_uri}->path_info; |
364
|
0
|
|
|
|
|
0
|
DEBUG('$r->path_info => \'%s\'', $str); |
365
|
0
|
|
|
|
|
0
|
return $str; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
# $str = $r->protocol MPPR p26 |
369
|
|
|
|
|
|
|
sub protocol { |
370
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
371
|
0
|
|
|
|
|
0
|
my $str = $r->{protocol}; |
372
|
0
|
|
|
|
|
0
|
DEBUG('$r->protocol => \'%s\'', $str); |
373
|
0
|
|
|
|
|
0
|
return $str; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
# $str = $r->the_request MPPR p26 |
377
|
|
|
|
|
|
|
sub the_request { |
378
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
379
|
0
|
|
|
|
|
0
|
my $str = eval { |
380
|
0
|
|
|
|
|
0
|
local $Mock::Apache::DEBUG = 0; |
381
|
0
|
|
|
|
|
0
|
sprintf("%s %s %s", $r->method, $r->{_uri}, $r->protocol); |
382
|
|
|
|
|
|
|
}; |
383
|
0
|
|
|
|
|
0
|
DEBUG('$r->the_request => \'%s\'', $str); |
384
|
0
|
|
|
|
|
0
|
return $str; |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
# $str = $r->uri([$newuri]) MPPR p27 |
388
|
|
|
|
|
|
|
sub uri { |
389
|
1
|
|
|
1
|
0
|
549
|
my ($r, $newuri) = @_; |
390
|
1
|
|
|
|
|
3
|
my $uri = $r->{uri}; |
391
|
1
|
50
|
|
|
|
8
|
DEBUG('$r->uri(%s) => %s', @_ > 1 ? "'$newuri'" : '', $uri); |
392
|
1
|
50
|
|
|
|
4
|
$r->{uri} = $newuri if @_ > 1; |
393
|
1
|
|
|
|
|
4
|
return $uri; |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
################################################################################ |
398
|
|
|
|
|
|
|
# |
399
|
|
|
|
|
|
|
# Server Response Methods MPPR p27 |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
# $str = $r->cgi_header_out MPPR p28 |
402
|
|
|
|
|
|
|
sub cgi_header_out { |
403
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('$r->cgi_header_out'); |
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
# $str = $r->content_encoding([$newval]) MPPR p28 |
407
|
|
|
|
|
|
|
sub content_encoding { |
408
|
0
|
|
|
0
|
0
|
0
|
my ($r, $newval) = @_; |
409
|
0
|
|
|
|
|
0
|
my $encoding = $r->{content_encoding}; |
410
|
0
|
0
|
0
|
|
|
0
|
DEBUG('$r->content_encoding(%s) => \'%s\'', @_ > 1 ? sprintf("'%s'", $newval || '') : '', $encoding); |
411
|
0
|
0
|
|
|
|
0
|
$r->{content_encoding} = $newval if @_ > 1; |
412
|
0
|
|
|
|
|
0
|
return $encoding; |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
sub content_languages { |
416
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('$r->content_languages'); |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
# $str = $r->content_type([$newval]) MPPR p28 |
420
|
|
|
|
|
|
|
sub content_type { |
421
|
1
|
|
|
1
|
0
|
10
|
my ($r, $newval) = @_; |
422
|
1
|
|
|
|
|
5
|
my $content_type = $r->{content_type}; |
423
|
1
|
50
|
|
|
|
8
|
DEBUG('$r->content_type(%s) => \'%s\'', @_ > 1 ? "'$newval'" : '', $content_type); |
424
|
1
|
50
|
|
|
|
3
|
if (@_ > 1) { |
425
|
1
|
|
|
|
|
3
|
$r->{content_type} = $newval; |
426
|
1
|
|
|
|
|
8
|
local $Mock::Apache::DEBUG = 0; |
427
|
1
|
|
|
|
|
6
|
$r->header_out('content-type' => $newval); |
428
|
|
|
|
|
|
|
} |
429
|
1
|
|
|
|
|
2
|
return $content_type; |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
# $num = $r->request_time MPPR p29 |
434
|
|
|
|
|
|
|
# Returns the time at which the request started as a Unix time value. |
435
|
|
|
|
|
|
|
sub request_time { |
436
|
6
|
|
|
6
|
0
|
16
|
my ($r) = @_; |
437
|
6
|
|
|
|
|
13
|
my $num = $r->{request_time}; |
438
|
6
|
|
|
|
|
24
|
DEBUG('$r->request_time => %d', $num); |
439
|
6
|
|
|
|
|
30
|
return $num; |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
# $num = $r->status([$newval]) MPPR p29 |
443
|
|
|
|
|
|
|
# Gets or sets the status code of the outgoing response. Symbolic names for |
444
|
|
|
|
|
|
|
# all standard status codes are provided by the Apache::Constants module. |
445
|
|
|
|
|
|
|
sub status { |
446
|
8
|
|
|
8
|
0
|
18
|
my ($r, $newval) = @_; |
447
|
8
|
|
|
|
|
18
|
my $status = $r->{status}; |
448
|
8
|
100
|
|
|
|
38
|
DEBUG('$r->status(%s) => %d', @_ > 1 ? "$newval" : '', $status); |
449
|
8
|
100
|
|
|
|
31
|
$r->{status} = $r->{status_line} = $newval if @_ > 1; |
450
|
8
|
|
|
|
|
27
|
return $status; |
451
|
|
|
|
|
|
|
} |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
# $str = $r->status_line([$newstr]) MPPR p29 |
454
|
|
|
|
|
|
|
sub status_line { |
455
|
8
|
|
|
8
|
0
|
17
|
my ($r, $newval) = @_; |
456
|
8
|
|
|
|
|
16
|
my $status_line = $r->{status_line}; |
457
|
8
|
100
|
|
|
|
85
|
DEBUG('$r->status_line(%s) => %d', @_ > 1 ? "$newval" : '', $status_line); |
458
|
8
|
100
|
|
|
|
21
|
if (@_ > 1) { |
459
|
4
|
50
|
|
|
|
29
|
if (($r->{status_line} = $newval) =~ m{^(\d\d\d)}x) { |
460
|
4
|
|
|
|
|
13
|
$r->status($1); |
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
} |
463
|
8
|
|
|
|
|
30
|
return $status_line; |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
# FIXME: need better implementation of print |
468
|
|
|
|
|
|
|
sub print { |
469
|
0
|
|
|
0
|
0
|
0
|
my ($r, @list) = @_; |
470
|
0
|
|
|
|
|
0
|
foreach my $item (@list) { |
471
|
0
|
0
|
|
|
|
0
|
$r->{_output} .= ref $item eq 'SCALAR' ? $$item : $item; |
472
|
|
|
|
|
|
|
} |
473
|
0
|
|
|
|
|
0
|
return; |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
# $r->send_http_header([$content_type]) MPPR p30 |
477
|
|
|
|
|
|
|
sub send_http_header{ |
478
|
0
|
|
|
0
|
0
|
0
|
my ($r, $content_type) = @_; |
479
|
0
|
0
|
|
|
|
0
|
DEBUG('$r->send_http_header(%s)', @_ > 1 ? "'$content_type" : ''); |
480
|
0
|
|
|
|
|
0
|
return; |
481
|
|
|
|
|
|
|
} |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
# {$str|$href} = $r->notes([$key[,$val]]) MPPR p31 |
486
|
|
|
|
|
|
|
# with no arguments returns a reference to the notes table |
487
|
|
|
|
|
|
|
# otherwise gets or sets the named note |
488
|
|
|
|
|
|
|
sub notes { |
489
|
2
|
|
|
2
|
0
|
16
|
my $r = shift; |
490
|
2
|
|
|
|
|
4
|
my $notes = $r->{notes}; |
491
|
2
|
50
|
|
|
|
9
|
return @_ ? $notes->_get_or_set(@_) : $notes->_hash_or_list; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
# {$str|$href} = $r->pnotes([$key[,$val]]) MPPR p31 |
495
|
|
|
|
|
|
|
# with no arguments returns a reference to the pnotes table |
496
|
|
|
|
|
|
|
# otherwise gets or sets the named pnote |
497
|
|
|
|
|
|
|
sub pnotes { |
498
|
2
|
|
|
2
|
0
|
9
|
my $r = shift; |
499
|
2
|
|
|
|
|
11
|
my $pnotes = $r->{pnotes}; |
500
|
2
|
50
|
|
|
|
7
|
return @_ ? $pnotes->_get_or_set(@_) : $pnotes->_hash_or_list; |
501
|
|
|
|
|
|
|
} |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
# $str = $r->document_root MPPR p32 |
504
|
|
|
|
|
|
|
sub document_root { |
505
|
4
|
|
|
4
|
0
|
9
|
my $r = shift; |
506
|
4
|
|
|
|
|
15
|
my $str = $r->{server}->{document_root}; |
507
|
4
|
|
|
|
|
25
|
DEBUG('$r->document_root => \'%s\'', $str); |
508
|
4
|
|
|
|
|
17
|
return $str; |
509
|
|
|
|
|
|
|
} |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
# $num = $r->server_port MPPR p33 |
512
|
|
|
|
|
|
|
sub get_server_port { |
513
|
4
|
|
|
4
|
0
|
7
|
my $r = shift; |
514
|
4
|
|
|
|
|
14
|
my $port = $r->{server}->{server_port}; |
515
|
4
|
|
|
|
|
12
|
DEBUG('$r->server_port => \'%d\'', $port); |
516
|
4
|
|
|
|
|
12
|
return $port; |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
# $r->log_error($message) MPPR p34 |
520
|
|
|
|
|
|
|
sub log_error { |
521
|
0
|
|
|
0
|
0
|
0
|
my ($r, $message) = @_; |
522
|
0
|
|
|
|
|
0
|
DEBUG('$r->log_error(\%s\')', $message); |
523
|
0
|
|
|
|
|
0
|
$r->{log}->error($message); |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
# $s = $r->server MPPR p38 |
528
|
|
|
|
|
|
|
# $s = Apache->server |
529
|
|
|
|
|
|
|
sub server { |
530
|
7
|
|
|
7
|
0
|
1690
|
my $self = shift; |
531
|
7
|
50
|
|
|
|
51
|
DEBUG('%s->server => ' . $server, ref $self ? '$r' : 'Apache'); |
532
|
7
|
|
|
|
|
51
|
return $server; |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
sub subprocess_env { |
536
|
8
|
|
|
8
|
0
|
14
|
my $r = shift; |
537
|
8
|
|
|
|
|
16
|
my $subprocess_env = $r->{subprocess_env}; |
538
|
|
|
|
|
|
|
|
539
|
8
|
50
|
|
|
|
27
|
if (@_) { |
|
|
0
|
|
|
|
|
|
540
|
8
|
|
|
|
|
32
|
$subprocess_env->_get_or_set(@_); |
541
|
|
|
|
|
|
|
} |
542
|
|
|
|
|
|
|
elsif (defined wantarray) { |
543
|
0
|
|
|
|
|
0
|
return $subprocess_env->_hash_or_list; |
544
|
|
|
|
|
|
|
} |
545
|
|
|
|
|
|
|
else { |
546
|
0
|
|
|
|
|
0
|
$r->{subprocess_env} = Apache::Table->new($r); |
547
|
|
|
|
|
|
|
|
548
|
0
|
|
|
|
|
0
|
while (my($key, $val) = each %{$r->{_env}}) { |
|
0
|
|
|
|
|
0
|
|
549
|
0
|
|
|
|
|
0
|
$r->{subprocess_env}->set($key, $val); |
550
|
|
|
|
|
|
|
} |
551
|
0
|
|
|
|
|
0
|
return; |
552
|
|
|
|
|
|
|
} |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
sub dir_config { |
557
|
0
|
|
|
0
|
0
|
0
|
my ($r) = @_; |
558
|
0
|
|
|
|
|
0
|
NYI_DEBUG('$r->dir_config'); |
559
|
|
|
|
|
|
|
} |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
package |
566
|
|
|
|
|
|
|
Apache::STDOUT; |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
################################################################################ |
572
|
|
|
|
|
|
|
# |
573
|
|
|
|
|
|
|
# The Apache::Server Class MPPR p38 |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
package |
576
|
|
|
|
|
|
|
Apache::Server; |
577
|
|
|
|
|
|
|
|
578
|
5
|
|
|
5
|
|
18513
|
use parent 'Class::Accessor'; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
34
|
|
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(_mock_apache uid gid log)); |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
sub new { |
584
|
4
|
|
|
4
|
1
|
29
|
my ($class, $mock_apache, %params) = @_; |
585
|
4
|
|
|
|
|
38
|
$params{log} = Apache::Log->new(); |
586
|
4
|
|
|
|
|
12
|
$params{_mock_apache} = $mock_apache; |
587
|
4
|
|
|
|
|
60
|
return $class->SUPER::new(\%params); |
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
# $num = $s->gid MPPR p38 |
591
|
|
|
|
|
|
|
# Returns the numeric group ID under which the server answers requests. This is |
592
|
|
|
|
|
|
|
# the value of the Apache "Group" directive. |
593
|
|
|
|
|
|
|
sub gid { |
594
|
0
|
|
|
0
|
0
|
0
|
my $s = shift; |
595
|
0
|
|
|
|
|
0
|
my $gid = $s->{gid}; |
596
|
0
|
|
|
|
|
0
|
DEBUG('$s->gid => %d', $gid); |
597
|
0
|
|
|
|
|
0
|
return $gid; |
598
|
|
|
|
|
|
|
} |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
# $num = $s->port MPPR p39 |
601
|
|
|
|
|
|
|
# Returns the port number on which this server listens. |
602
|
|
|
|
|
|
|
sub port { |
603
|
0
|
|
|
0
|
0
|
0
|
my $s = shift; |
604
|
0
|
|
|
|
|
0
|
my $port = $s->{port}; |
605
|
0
|
|
|
|
|
0
|
DEBUG('$s->port => %d', $port); |
606
|
0
|
|
|
|
|
0
|
return $port; |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
# $str = $s->server_hostname MPPR p39 |
610
|
|
|
|
|
|
|
sub server_hostname { |
611
|
7
|
|
|
7
|
0
|
1219
|
my $s = shift; |
612
|
7
|
|
|
|
|
21
|
my $hostname = $s->{server_hostname}; |
613
|
7
|
|
|
|
|
24
|
DEBUG('$s->server_hostname => \'%s\'', $hostname); |
614
|
7
|
|
|
|
|
24
|
return $hostname; |
615
|
|
|
|
|
|
|
} |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
# $str = $s->server_admin MPPR p39 |
618
|
|
|
|
|
|
|
sub server_admin { |
619
|
9
|
|
|
9
|
0
|
16
|
my $s = shift; |
620
|
9
|
|
|
|
|
19
|
my $admin = $s->{server_admin}; |
621
|
9
|
|
|
|
|
34
|
DEBUG('$s->server_admin => \'%s\'', $admin); |
622
|
9
|
|
|
|
|
34
|
return $admin; |
623
|
|
|
|
|
|
|
} |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
sub names { |
627
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
628
|
0
|
0
|
|
|
|
0
|
return @{$self->{names} || []}; |
|
0
|
|
|
|
|
0
|
|
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
# $num = $s->uid MPPR p39 |
632
|
|
|
|
|
|
|
# Returns the numeric user ID under which the server answers requests. This is |
633
|
|
|
|
|
|
|
# the value of the Apache "User" directive. |
634
|
|
|
|
|
|
|
sub uid { |
635
|
0
|
|
|
0
|
0
|
0
|
my $s = shift; |
636
|
0
|
|
|
|
|
0
|
my $uid = $s->{uid}; |
637
|
0
|
|
|
|
|
0
|
DEBUG('$s->uid => %d', $uid); |
638
|
0
|
|
|
|
|
0
|
return $uid; |
639
|
|
|
|
|
|
|
} |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
# is_virtual |
642
|
|
|
|
|
|
|
# log |
643
|
|
|
|
|
|
|
# log_error |
644
|
|
|
|
|
|
|
# loglevel |
645
|
|
|
|
|
|
|
# names |
646
|
|
|
|
|
|
|
# next |
647
|
|
|
|
|
|
|
# port |
648
|
|
|
|
|
|
|
# timeout |
649
|
|
|
|
|
|
|
# warn |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
################################################################################ |
653
|
|
|
|
|
|
|
# |
654
|
|
|
|
|
|
|
# The Apache Connection Class MPPR p39 |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
package |
657
|
|
|
|
|
|
|
Apache::Connection; |
658
|
|
|
|
|
|
|
|
659
|
5
|
|
|
5
|
|
2234
|
use Scalar::Util qw(weaken); |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
357
|
|
660
|
5
|
|
|
5
|
|
27
|
use parent qw(Class::Accessor); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
23
|
|
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qr(_mock_client)); |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
sub new { |
665
|
4
|
|
|
4
|
1
|
11
|
my ($class, $mock_client) = @_; |
666
|
4
|
|
|
|
|
17
|
my $self = bless { _mock_client => $mock_client }, $class; |
667
|
4
|
|
|
|
|
33
|
weaken $self->{_mock_client}; |
668
|
4
|
|
|
|
|
20
|
return $self; |
669
|
|
|
|
|
|
|
} |
670
|
|
|
|
|
|
|
|
671
|
0
|
|
|
0
|
0
|
0
|
sub aborted { return $_[0]->{_aborted} } |
672
|
|
|
|
|
|
|
sub auth_type { |
673
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('$c->auth_type'); |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
sub fileno { |
677
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('$c->fileno'); |
678
|
|
|
|
|
|
|
} |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
sub local_addr { |
681
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('$c->local_addr'); |
682
|
|
|
|
|
|
|
} |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
sub remote_addr { |
685
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('$c->remote_addr'); |
686
|
|
|
|
|
|
|
} |
687
|
|
|
|
|
|
|
|
688
|
0
|
|
|
0
|
0
|
0
|
sub remote_host { $_->_mock_client->remote_host; } |
689
|
0
|
|
|
0
|
0
|
0
|
sub remote_ip { $_->_mock_client->remote_addr; } |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
sub remote_logname { |
692
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('$c->remote_logname'); |
693
|
0
|
|
|
|
|
0
|
return; |
694
|
|
|
|
|
|
|
} |
695
|
|
|
|
|
|
|
sub user { |
696
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('$c->remote_user'); |
697
|
0
|
|
|
|
|
0
|
return; |
698
|
|
|
|
|
|
|
} |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
############################################################################## |
701
|
|
|
|
|
|
|
# |
702
|
|
|
|
|
|
|
# Logging and the Apache::Log Class MPPR p34 |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
package |
705
|
|
|
|
|
|
|
Apache::Log; |
706
|
|
|
|
|
|
|
|
707
|
5
|
|
|
5
|
|
9347
|
use Log::Log4perl; |
|
5
|
|
|
|
|
328084
|
|
|
5
|
|
|
|
|
54
|
|
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
sub new { |
710
|
4
|
|
|
4
|
0
|
12
|
my ($class, %params) = @_; |
711
|
4
|
|
|
|
|
23
|
return bless \%params, $class; |
712
|
|
|
|
|
|
|
} |
713
|
|
|
|
|
|
|
|
714
|
0
|
|
|
0
|
0
|
0
|
sub log_reason {} |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
sub warn { |
717
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
718
|
0
|
|
|
|
|
0
|
print STDERR "[warn]: ", @_, "\n"; |
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
sub emerg { |
722
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
723
|
0
|
|
|
|
|
0
|
print STDERR "[emerg]: ", @_, "\n"; |
724
|
|
|
|
|
|
|
} |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
sub alert { |
727
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
728
|
0
|
|
|
|
|
0
|
print STDERR "[alert]: ", @_, "\n"; |
729
|
|
|
|
|
|
|
} |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
sub error { |
732
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
733
|
0
|
|
|
|
|
0
|
print STDERR "[error]: ", @_, "\n"; |
734
|
|
|
|
|
|
|
} |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
sub notice { |
737
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
738
|
0
|
|
|
|
|
0
|
print STDERR "[notice]: ", @_, "\n"; |
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
sub info { |
742
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
743
|
0
|
|
|
|
|
0
|
print STDERR "[info]: ", @_, "\n"; |
744
|
|
|
|
|
|
|
} |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
sub debug { |
747
|
0
|
|
|
0
|
0
|
0
|
my $r = shift; |
748
|
0
|
|
|
|
|
0
|
print STDERR "[debug]: ", @_, "\n"; |
749
|
|
|
|
|
|
|
} |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
############################################################################## |
753
|
|
|
|
|
|
|
# |
754
|
|
|
|
|
|
|
# The Apache::Table Class MPPR p40 |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
package |
757
|
|
|
|
|
|
|
Apache::Table; |
758
|
|
|
|
|
|
|
|
759
|
5
|
|
|
5
|
|
7125
|
use Apache::FakeTable; |
|
5
|
|
|
|
|
6781
|
|
|
5
|
|
|
|
|
165
|
|
760
|
5
|
|
|
5
|
|
36
|
use parent 'Apache::FakeTable'; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
51
|
|
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
sub new { |
763
|
24
|
|
|
24
|
1
|
42
|
my ($class, $r, $allow_refs) = @_; |
764
|
|
|
|
|
|
|
|
765
|
24
|
|
|
|
|
103
|
my $self = $class->SUPER::new($r); |
766
|
24
|
100
|
|
|
|
400
|
bless tied(%$self), 'Apache::FakeTableHash::RefsAllowed' |
767
|
|
|
|
|
|
|
if $allow_refs; |
768
|
24
|
|
|
|
|
78
|
return $self; |
769
|
|
|
|
|
|
|
} |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
sub _hash_or_list { |
772
|
9
|
|
|
9
|
|
13
|
my ($self) = @_; |
773
|
|
|
|
|
|
|
|
774
|
9
|
|
|
|
|
33
|
my $method_name = (caller(1))[3]; |
775
|
9
|
50
|
|
|
|
71
|
DEBUG("\$r->$method_name(%s) => %s", |
776
|
|
|
|
|
|
|
wantarray ? 'list' : $self); |
777
|
|
|
|
|
|
|
|
778
|
9
|
50
|
|
|
|
25
|
if (wantarray) { |
779
|
0
|
|
|
|
|
0
|
my @values; |
780
|
0
|
|
|
|
|
0
|
while (my ($key, $value) = each %$self) { |
781
|
0
|
|
|
|
|
0
|
push @values, $key, $value; |
782
|
|
|
|
|
|
|
} |
783
|
0
|
|
|
|
|
0
|
return @values; |
784
|
|
|
|
|
|
|
} |
785
|
|
|
|
|
|
|
else { |
786
|
9
|
|
|
|
|
59
|
return $self; |
787
|
|
|
|
|
|
|
} |
788
|
|
|
|
|
|
|
} |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
sub _get_or_set { |
792
|
21
|
|
|
21
|
|
44
|
my ($self, $key, @new_values) = @_; |
793
|
|
|
|
|
|
|
|
794
|
21
|
|
|
|
|
87
|
my $method_name = (caller(1))[3]; |
795
|
21
|
|
|
|
|
95
|
my @old_values = $self->get($key); |
796
|
21
|
100
|
|
|
|
363
|
DEBUG("\$r->$method_name('%s'%s)%s", $key, |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
797
|
|
|
|
|
|
|
@new_values ? join(',', '', @new_values) : '', |
798
|
|
|
|
|
|
|
defined wantarray ? ' => ' . (@old_values ? join(',', @old_values) : "''" ) : ''); |
799
|
21
|
100
|
|
|
|
53
|
if (@new_values) { |
800
|
7
|
|
|
|
|
22
|
$self->set($key, @new_values); |
801
|
|
|
|
|
|
|
} |
802
|
21
|
100
|
|
|
|
148
|
return unless defined wantarray; |
803
|
14
|
100
|
|
|
|
134
|
return wantarray ? @old_values : $old_values[0]; |
804
|
|
|
|
|
|
|
} |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
# Apache::FakeTableHash always stores values as strings in an array. |
807
|
|
|
|
|
|
|
# We need to allow references to be stored (for pnotes), so we rebless |
808
|
|
|
|
|
|
|
# the tied hash into our own Apache::FakeTableHash::RefsAllowed class, |
809
|
|
|
|
|
|
|
# which is a subclass of Apache::FakeTableHash. |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
package |
812
|
|
|
|
|
|
|
Apache::FakeTableHash::RefsAllowed; |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
our @ISA = qw(Apache::FakeTableHash); |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
sub STORE { |
817
|
1
|
|
|
1
|
|
9
|
my ($self, $key, $value) = @_; |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
# Issue a warning if the value is undefined. |
820
|
1
|
0
|
33
|
|
|
5
|
if (! defined $value and $^W) { |
821
|
0
|
|
|
|
|
0
|
require Carp; |
822
|
0
|
|
|
|
|
0
|
Carp::carp('Use of uninitialized value in null operation'); |
823
|
0
|
|
|
|
|
0
|
$value = ''; |
824
|
|
|
|
|
|
|
} |
825
|
1
|
|
|
|
|
7
|
$self->{lc $key} = [ $key => [$value] ]; |
826
|
|
|
|
|
|
|
} |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
sub _add { |
829
|
0
|
|
|
0
|
|
0
|
my ($self, $key, $value) = @_; |
830
|
0
|
|
|
|
|
0
|
my $ckey = lc $key; |
831
|
|
|
|
|
|
|
|
832
|
0
|
0
|
|
|
|
0
|
if (exists $self->{$ckey}) { |
833
|
|
|
|
|
|
|
# Add it to the array, |
834
|
0
|
|
|
|
|
0
|
push @{$self->{$ckey}[1]}, $value; |
|
0
|
|
|
|
|
0
|
|
835
|
|
|
|
|
|
|
} else { |
836
|
|
|
|
|
|
|
# It's a simple assignment. |
837
|
0
|
|
|
|
|
0
|
$self->{$ckey} = [ $key => [$value] ]; |
838
|
|
|
|
|
|
|
} |
839
|
|
|
|
|
|
|
} |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
############################################################################## |
842
|
|
|
|
|
|
|
# |
843
|
|
|
|
|
|
|
# The Apache::File Class MPPR p |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
package |
846
|
|
|
|
|
|
|
Apache::File; |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
############################################################################## |
851
|
|
|
|
|
|
|
# |
852
|
|
|
|
|
|
|
# The Apache::URI Class MPPR p41 |
853
|
|
|
|
|
|
|
package |
854
|
|
|
|
|
|
|
Apache::URI; |
855
|
|
|
|
|
|
|
|
856
|
5
|
|
|
5
|
|
14725
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
203
|
|
857
|
5
|
|
|
5
|
|
32
|
use URI; |
|
5
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
576
|
|
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
our @ISA = qw(URI); |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
sub parse { |
862
|
0
|
|
|
0
|
0
|
0
|
my ($r, $string_uri) = @_; |
863
|
0
|
|
|
|
|
0
|
DEBUG('$r->parse(%s)', $string_uri); |
864
|
0
|
|
|
|
|
0
|
$DB::single=1; |
865
|
0
|
|
|
|
|
0
|
croak("not yet implemented"); |
866
|
0
|
|
|
|
|
0
|
return; |
867
|
|
|
|
|
|
|
} |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
############################################################################## |
870
|
|
|
|
|
|
|
# |
871
|
|
|
|
|
|
|
# The Apache::Util Class MPPR p43 |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
package |
874
|
|
|
|
|
|
|
Apache::Util; |
875
|
|
|
|
|
|
|
|
876
|
5
|
|
|
5
|
|
32
|
use parent 'Exporter'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
29
|
|
877
|
|
|
|
|
|
|
our @EXPORT_OK = qw( escape_html escape_uri unescape_uri unescape_uri_info |
878
|
|
|
|
|
|
|
parsedate ht_time size_string validate_password ); |
879
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
sub escape_html { |
882
|
0
|
|
|
0
|
0
|
0
|
my ($html) = @_; |
883
|
0
|
|
|
|
|
0
|
my $out = $html; |
884
|
0
|
|
|
|
|
0
|
$out =~ s/&/&/g; |
885
|
0
|
|
|
|
|
0
|
$out =~ s/</g; |
886
|
0
|
|
|
|
|
0
|
$out =~ s/>/>/g; |
887
|
0
|
|
|
|
|
0
|
$out =~ s/"/"/g; |
888
|
0
|
|
|
|
|
0
|
DEBUG('Apache::Util::escape_html(\'%s\') => \'%s\'', $html, $out); |
889
|
0
|
|
|
|
|
0
|
return $out; |
890
|
|
|
|
|
|
|
} |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
sub escape_uri { |
893
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('escape_uri'); |
894
|
|
|
|
|
|
|
} |
895
|
|
|
|
|
|
|
sub ht_time { |
896
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('ht_time'); |
897
|
|
|
|
|
|
|
} |
898
|
|
|
|
|
|
|
sub parsedate { |
899
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('parsedate'); |
900
|
|
|
|
|
|
|
} |
901
|
|
|
|
|
|
|
sub size_string { |
902
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('size_string'); |
903
|
|
|
|
|
|
|
} |
904
|
|
|
|
|
|
|
sub unescape_uri { |
905
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('unescape_uri'); |
906
|
|
|
|
|
|
|
} |
907
|
|
|
|
|
|
|
sub unescape_uri_info { |
908
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('unescape_uri_info'); |
909
|
|
|
|
|
|
|
} |
910
|
|
|
|
|
|
|
sub validate_password { |
911
|
0
|
|
|
0
|
0
|
0
|
NYI_DEBUG('validate_password'); |
912
|
|
|
|
|
|
|
} |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
package |
916
|
|
|
|
|
|
|
Apache::ModuleConfig; |
917
|
|
|
|
|
|
|
|
918
|
0
|
|
|
0
|
0
|
0
|
sub new { |
919
|
|
|
|
|
|
|
} |
920
|
0
|
|
|
0
|
0
|
0
|
sub get { |
921
|
|
|
|
|
|
|
} |
922
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
############################################################################## |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
package |
927
|
|
|
|
|
|
|
Apache::Constants; |
928
|
|
|
|
|
|
|
|
929
|
5
|
|
|
5
|
|
6478
|
use parent 'Exporter'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1031
|
|
930
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
our @COMMON_CONSTS = qw( OK DECLINED DONE NOT_FOUND FORBIDDEN AUTH_REQUIRED SERVER_ERROR ); |
932
|
|
|
|
|
|
|
our @RESPONSE_CONSTS = qw( DOCUMENT_FOLLOWS MOVED REDIRECT USE_LOCAL_COPY |
933
|
|
|
|
|
|
|
BAD_REQUEST BAD_GATEWAY RESPONSE_CODES NOT_IMPLEMENTED |
934
|
|
|
|
|
|
|
CONTINUE NOT_AUTHORITATIVE ); |
935
|
|
|
|
|
|
|
our @METHOD_CONSTS = qw( METHODS M_CONNECT M_DELETE M_GET M_INVALID |
936
|
|
|
|
|
|
|
M_OPTIONS M_POST M_PUT M_TRACE M_PATCH |
937
|
|
|
|
|
|
|
M_PROPFIND M_PROPPATCH M_MKCOL M_COPY |
938
|
|
|
|
|
|
|
M_MOVE M_LOCK M_UNLOCK ); |
939
|
|
|
|
|
|
|
our @OPTIONS_CONSTS = qw( OPT_NONE OPT_INDEXES OPT_INCLUDES OPT_SYM_LINKS |
940
|
|
|
|
|
|
|
OPT_EXECCGI OPT_UNSET OPT_INCNOEXEC |
941
|
|
|
|
|
|
|
OPT_SYM_OWNER OPT_MULTI OPT_ALL ); |
942
|
|
|
|
|
|
|
our @SATISFY_CONSTS = qw( SATISFY_ALL SATISFY_ANY SATISFY_NOSPEC ); |
943
|
|
|
|
|
|
|
our @REMOTEHOST_CONSTS = qw( REMOTE_HOST REMOTE_NAME REMOTE_NOLOOKUP REMOTE_DOUBLE_REV ); |
944
|
|
|
|
|
|
|
our @HTTP_CONSTS = qw( HTTP_OK HTTP_MOVED_TEMPORARILY HTTP_MOVED_PERMANENTLY |
945
|
|
|
|
|
|
|
HTTP_METHOD_NOT_ALLOWED HTTP_NOT_MODIFIED HTTP_UNAUTHORIZED |
946
|
|
|
|
|
|
|
HTTP_FORBIDDEN HTTP_NOT_FOUND HTTP_BAD_REQUEST |
947
|
|
|
|
|
|
|
HTTP_INTERNAL_SERVER_ERROR HTTP_NOT_ACCEPTABLE HTTP_NO_CONTENT |
948
|
|
|
|
|
|
|
HTTP_PRECONDITION_FAILED HTTP_SERVICE_UNAVAILABLE |
949
|
|
|
|
|
|
|
HTTP_VARIANT_ALSO_VARIES ); |
950
|
|
|
|
|
|
|
our @SERVER_CONSTS = qw( MODULE_MAGIC_NUMBER SERVER_VERSION SERVER_BUILT ); |
951
|
|
|
|
|
|
|
our @CONFIG_CONSTS = qw( DECLINE_CMD ); |
952
|
|
|
|
|
|
|
our @TYPES_CONSTS = qw( DIR_MAGIC_TYPE ); |
953
|
|
|
|
|
|
|
our @OVERRIDE_CONSTS = qw( OR_NONE OR_LIMIT OR_OPTIONS OR_FILEINFO OR_AUTHCFG |
954
|
|
|
|
|
|
|
OR_INDEXES OR_UNSET OR_ALL ACCESS_CONF RSRC_CONF ); |
955
|
|
|
|
|
|
|
our @ARGS_HOW_CONSTS = qw( RAW_ARGS TAKE1 TAKE2 TAKE12 TAKE3 TAKE23 TAKE123 |
956
|
|
|
|
|
|
|
ITERATE ITERATE2 FLAG NO_ARGS ); |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
|
959
|
|
|
|
|
|
|
our @EXPORT = ( @COMMON_CONSTS ); |
960
|
|
|
|
|
|
|
our @EXPORT_OK = ( @COMMON_CONSTS, @RESPONSE_CONSTS, @METHOD_CONSTS, @OPTIONS_CONSTS, @SATISFY_CONSTS, |
961
|
|
|
|
|
|
|
@REMOTEHOST_CONSTS, @HTTP_CONSTS, @SERVER_CONSTS, @CONFIG_CONSTS, @TYPES_CONSTS, |
962
|
|
|
|
|
|
|
@OVERRIDE_CONSTS, @ARGS_HOW_CONSTS); |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( common => \@COMMON_CONSTS, |
965
|
|
|
|
|
|
|
response => [ @COMMON_CONSTS, @RESPONSE_CONSTS ], |
966
|
|
|
|
|
|
|
methods => \@METHOD_CONSTS, |
967
|
|
|
|
|
|
|
options => \@OPTIONS_CONSTS, |
968
|
|
|
|
|
|
|
satisfy => \@SATISFY_CONSTS, |
969
|
|
|
|
|
|
|
remotehost => \@REMOTEHOST_CONSTS, |
970
|
|
|
|
|
|
|
http => \@HTTP_CONSTS, |
971
|
|
|
|
|
|
|
server => \@SERVER_CONSTS, |
972
|
|
|
|
|
|
|
config => \@CONFIG_CONSTS, |
973
|
|
|
|
|
|
|
types => \@TYPES_CONSTS, |
974
|
|
|
|
|
|
|
override => \@OVERRIDE_CONSTS, |
975
|
|
|
|
|
|
|
args_how => \@ARGS_HOW_CONSTS, ); |
976
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
|
978
|
8
|
|
|
8
|
0
|
2855
|
sub OK { 0 } |
979
|
0
|
|
|
0
|
0
|
0
|
sub DECLINED { -1 } |
980
|
0
|
|
|
0
|
0
|
0
|
sub DONE { -2 } |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
# CONTINUE and NOT_AUTHORITATIVE are aliases for DECLINED. |
983
|
|
|
|
|
|
|
|
984
|
0
|
|
|
0
|
0
|
0
|
sub CONTINUE { 100 } |
985
|
0
|
|
|
0
|
0
|
0
|
sub DOCUMENT_FOLLOWS { 200 } |
986
|
0
|
|
|
0
|
0
|
0
|
sub NOT_AUTHORITATIVE { 203 } |
987
|
0
|
|
|
0
|
0
|
0
|
sub MOVED { 301 } |
988
|
0
|
|
|
0
|
0
|
0
|
sub REDIRECT { 302 } |
989
|
0
|
|
|
0
|
0
|
0
|
sub USE_LOCAL_COPY { 304 } |
990
|
0
|
|
|
0
|
0
|
0
|
sub BAD_REQUEST { 400 } |
991
|
0
|
|
|
0
|
0
|
0
|
sub AUTH_REQUIRED { 401 } |
992
|
0
|
|
|
0
|
0
|
0
|
sub FORBIDDEN { 403 } |
993
|
0
|
|
|
0
|
0
|
0
|
sub NOT_FOUND { 404 } |
994
|
0
|
|
|
0
|
0
|
0
|
sub SERVER_ERROR { 500 } |
995
|
0
|
|
|
0
|
0
|
0
|
sub NOT_IMPLEMENTED { 501 } |
996
|
0
|
|
|
0
|
0
|
0
|
sub BAD_GATEWAY { 502 } |
997
|
|
|
|
|
|
|
|
998
|
5
|
|
|
5
|
0
|
333
|
sub HTTP_OK { 200 } |
999
|
0
|
|
|
0
|
0
|
|
sub HTTP_NO_CONTENT { 204 } |
1000
|
0
|
|
|
0
|
0
|
|
sub HTTP_MOVED_PERMANENTLY { 301 } |
1001
|
0
|
|
|
0
|
0
|
|
sub HTTP_MOVED_TEMPORARILY { 302 } |
1002
|
0
|
|
|
0
|
0
|
|
sub HTTP_NOT_MODIFIED { 304 } |
1003
|
0
|
|
|
0
|
0
|
|
sub HTTP_BAD_REQUEST { 400 } |
1004
|
0
|
|
|
0
|
0
|
|
sub HTTP_UNAUTHORIZED { 401 } |
1005
|
0
|
|
|
0
|
0
|
|
sub HTTP_FORBIDDEN { 403 } |
1006
|
0
|
|
|
0
|
0
|
|
sub HTTP_NOT_FOUND { 404 } |
1007
|
0
|
|
|
0
|
0
|
|
sub HTTP_METHOD_NOT_ALLOWED { 405 } |
1008
|
0
|
|
|
0
|
0
|
|
sub HTTP_NOT_ACCEPTABLE { 406 } |
1009
|
0
|
|
|
0
|
0
|
|
sub HTTP_LENGTH_REQUIRED { 411 } |
1010
|
0
|
|
|
0
|
0
|
|
sub HTTP_PRECONDITION_FAILED { 412 } |
1011
|
0
|
|
|
0
|
0
|
|
sub HTTP_INTERNAL_SERVER_ERROR { 500 } |
1012
|
0
|
|
|
0
|
0
|
|
sub HTTP_NOT_IMPLEMENTED { 501 } |
1013
|
0
|
|
|
0
|
0
|
|
sub HTTP_BAD_GATEWAY { 502 } |
1014
|
0
|
|
|
0
|
0
|
|
sub HTTP_SERVICE_UNAVAILABLE { 503 } |
1015
|
0
|
|
|
0
|
0
|
|
sub HTTP_VARIANT_ALSO_VARIES { 506 } |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
# methods |
1018
|
|
|
|
|
|
|
|
1019
|
0
|
|
|
0
|
0
|
|
sub M_GET { 0 } |
1020
|
0
|
|
|
0
|
0
|
|
sub M_PUT { 1 } |
1021
|
0
|
|
|
0
|
0
|
|
sub M_POST { 2 } |
1022
|
0
|
|
|
0
|
0
|
|
sub M_DELETE { 3 } |
1023
|
0
|
|
|
0
|
0
|
|
sub M_CONNECT { 4 } |
1024
|
0
|
|
|
0
|
0
|
|
sub M_OPTIONS { 5 } |
1025
|
0
|
|
|
0
|
0
|
|
sub M_TRACE { 6 } |
1026
|
0
|
|
|
0
|
0
|
|
sub M_INVALID { 7 } |
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
# options |
1029
|
|
|
|
|
|
|
|
1030
|
0
|
|
|
0
|
0
|
|
sub OPT_NONE { 0 } |
1031
|
0
|
|
|
0
|
0
|
|
sub OPT_INDEXES { 1 } |
1032
|
0
|
|
|
0
|
0
|
|
sub OPT_INCLUDES { 2 } |
1033
|
0
|
|
|
0
|
0
|
|
sub OPT_SYM_LINKS { 4 } |
1034
|
0
|
|
|
0
|
0
|
|
sub OPT_EXECCGI { 8 } |
1035
|
0
|
|
|
0
|
0
|
|
sub OPT_UNSET { 16 } |
1036
|
0
|
|
|
0
|
0
|
|
sub OPT_INCNOEXEC { 32 } |
1037
|
0
|
|
|
0
|
0
|
|
sub OPT_SYM_OWNER { 64 } |
1038
|
0
|
|
|
0
|
0
|
|
sub OPT_MULTI { 128 } |
1039
|
0
|
|
|
0
|
0
|
|
sub OPT_ALL { 15 } |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
# satisfy |
1042
|
|
|
|
|
|
|
|
1043
|
0
|
|
|
0
|
0
|
|
sub SATISFY_ALL { 0 } |
1044
|
0
|
|
|
0
|
0
|
|
sub SATISFY_ANY { 1 } |
1045
|
0
|
|
|
0
|
0
|
|
sub SATISFY_NOSPEC { 2 } |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
# remotehost |
1048
|
|
|
|
|
|
|
|
1049
|
0
|
|
|
0
|
0
|
|
sub REMOTE_HOST { 0 } |
1050
|
0
|
|
|
0
|
0
|
|
sub REMOTE_NAME { 1 } |
1051
|
0
|
|
|
0
|
0
|
|
sub REMOTE_NOLOOKUP { 2 } |
1052
|
0
|
|
|
0
|
0
|
|
sub REMOTE_DOUBLE_REV { 3 } |
1053
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
|
1056
|
0
|
|
|
0
|
0
|
|
sub MODULE_MAGIC_NUMBER { "42" } |
1057
|
0
|
|
|
0
|
0
|
|
sub SERVER_VERSION { "1.x" } |
1058
|
0
|
|
|
0
|
0
|
|
sub SERVER_BUILT { "199908" } |
1059
|
|
|
|
|
|
|
|
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
############################################################################## |
1063
|
|
|
|
|
|
|
# |
1064
|
|
|
|
|
|
|
# Implementation of Apache::Request - a.k.a. libapreq |
1065
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
package |
1067
|
|
|
|
|
|
|
Apache::Request; |
1068
|
|
|
|
|
|
|
|
1069
|
5
|
|
|
5
|
|
13894
|
use URI::QueryParam; |
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
139
|
|
1070
|
5
|
|
|
5
|
|
27
|
use parent 'Apache'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
45
|
|
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
sub new { |
1073
|
0
|
|
|
0
|
1
|
|
my ($class, $r, %params) = @_; |
1074
|
|
|
|
|
|
|
|
1075
|
0
|
|
|
|
|
|
DEBUG('Apache::Request->new(%s) => %s', join(',', map { "$_=>'$params{$_}'" } keys %params ), $r); |
|
0
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
$r->{$_} = $params{$_} |
1077
|
0
|
|
|
|
|
|
for qw(POST_MAX DISABLE_UPLOADS TEMP_DIR HOOK_DATA UPLOAD_HOOK); |
1078
|
|
|
|
|
|
|
|
1079
|
0
|
|
|
|
|
|
return bless $r, $class; |
1080
|
|
|
|
|
|
|
} |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
sub instance { |
1083
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$apr->instance') |
1084
|
|
|
|
|
|
|
} |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
sub parse { |
1088
|
0
|
|
|
0
|
0
|
|
my $apr = shift; |
1089
|
0
|
|
|
|
|
|
DEBUG('$apr->parse'); |
1090
|
|
|
|
|
|
|
|
1091
|
0
|
|
|
|
|
|
my $params = $apr->{params} = Apache::Table->new($apr); |
1092
|
0
|
|
|
|
|
|
my $uri = $apr->_uri; |
1093
|
0
|
|
|
|
|
|
foreach my $key ($uri->query_param) { |
1094
|
0
|
|
|
|
|
|
foreach my $value ($uri->query_param($key)) { |
1095
|
0
|
|
|
|
|
|
$params->add($key, $value); |
1096
|
|
|
|
|
|
|
} |
1097
|
|
|
|
|
|
|
} |
1098
|
0
|
|
|
|
|
|
return; |
1099
|
|
|
|
|
|
|
} |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
sub param { |
1103
|
0
|
|
|
0
|
0
|
|
my $apr = shift; |
1104
|
0
|
|
|
|
|
|
NYI_DEBUG('$apr->param') |
1105
|
|
|
|
|
|
|
} |
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
sub parms { |
1109
|
0
|
|
|
0
|
0
|
|
my ($apr, $newval) = @_; |
1110
|
0
|
0
|
|
|
|
|
DEBUG('$apr->parms(%s)', @_ > 1 ? "$newval" : ''); |
1111
|
0
|
0
|
|
|
|
|
$apr->parse unless $apr->{params}; |
1112
|
0
|
|
|
|
|
|
return $apr->{params}; |
1113
|
|
|
|
|
|
|
} |
1114
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
sub upload { |
1116
|
0
|
|
|
0
|
0
|
|
my $apr = shift; |
1117
|
0
|
|
|
|
|
|
NYI_DEBUG('$apr->upload') |
1118
|
|
|
|
|
|
|
} |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
############################################################################### |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
package |
1123
|
|
|
|
|
|
|
Apache::Upload; |
1124
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
sub name { |
1126
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->name'); |
1127
|
|
|
|
|
|
|
} |
1128
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
sub filename { |
1130
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->filename'); |
1131
|
|
|
|
|
|
|
} |
1132
|
|
|
|
|
|
|
|
1133
|
|
|
|
|
|
|
sub fh { |
1134
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->fh'); |
1135
|
|
|
|
|
|
|
} |
1136
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
sub size { |
1138
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->size'); |
1139
|
|
|
|
|
|
|
} |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
sub info { |
1142
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->info'); |
1143
|
|
|
|
|
|
|
} |
1144
|
|
|
|
|
|
|
|
1145
|
|
|
|
|
|
|
sub type { |
1146
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->type'); |
1147
|
|
|
|
|
|
|
} |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
sub next { |
1150
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->next'); |
1151
|
|
|
|
|
|
|
} |
1152
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
sub tempname { |
1154
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->tempname'); |
1155
|
|
|
|
|
|
|
} |
1156
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
sub link { |
1158
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Upload->link'); |
1159
|
|
|
|
|
|
|
} |
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
################################################################################ |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
package |
1164
|
|
|
|
|
|
|
Apache::Cookie; |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
sub new { |
1167
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('Apache::Cookie->new'); |
1168
|
|
|
|
|
|
|
} |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
sub bake { |
1171
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->bake'); |
1172
|
|
|
|
|
|
|
} |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
sub parse { |
1175
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->parse'); |
1176
|
|
|
|
|
|
|
} |
1177
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
sub fetch { |
1179
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->fetch'); |
1180
|
|
|
|
|
|
|
} |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
sub as_string { |
1183
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->as_string'); |
1184
|
|
|
|
|
|
|
} |
1185
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
sub name { |
1187
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->name'); |
1188
|
|
|
|
|
|
|
} |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
sub value { |
1191
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->value'); |
1192
|
|
|
|
|
|
|
} |
1193
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
sub domain { |
1195
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->domain'); |
1196
|
|
|
|
|
|
|
} |
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
sub path { |
1199
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->path'); |
1200
|
|
|
|
|
|
|
} |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
sub expires { |
1203
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->expires'); |
1204
|
|
|
|
|
|
|
} |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
sub secure { |
1207
|
0
|
|
|
0
|
0
|
|
NYI_DEBUG('$c->secure'); |
1208
|
|
|
|
|
|
|
} |
1209
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
1; |