25
#Apache->request($r); #PerlOptions +GlobalRequest takes care
26
my $gr = Apache->request;
29
#Apache2::RequestUtil->request($r); #PerlOptions +GlobalRequest takes care
30
my $gr = Apache2::RequestUtil->request;
30
my $newr = Apache::RequestRec->new($r->connection, $r->pool);
31
Apache->request($newr);
32
$gr = Apache->request;
34
my $newr = Apache2::RequestRec->new($r->connection, $r->pool);
35
Apache2::RequestUtil->request($newr);
36
$gr = Apache2::RequestUtil->request;
40
Apache2::RequestUtil->request($r);
38
42
ok $r->pool->isa('APR::Pool');
40
ok $r->connection->isa('Apache::Connection');
44
ok $r->connection->isa('Apache2::Connection');
42
ok $r->server->isa('Apache::Server');
46
ok $r->server->isa('Apache2::ServerRec');
44
48
for (qw(next prev main)) {
45
ok (! $r->$_()) || $r->$_()->isa('Apache::RequestRec');
49
ok (! $r->$_()) || $r->$_()->isa('Apache2::RequestRec');
48
ok $r->the_request || 1;
50
ok $r->assbackwards || 1;
54
ok $r->header_only || 1;
54
ok !$r->proxyreq; # see also TestModules::proxy
56
58
ok $r->protocol =~ /http/i;
61
ok t_cmp $r->proto_num, 1000, 't->proto_num';
63
ok t_cmp lc($r->hostname), lc($r->get_server_name), '$r->hostname';
66
my $old_hostname = $r->hostname("other.hostname");
67
ok t_cmp $r->hostname, "other.hostname", '$r->hostname rw';
68
$r->hostname($old_hostname);
62
71
ok $r->request_time;
101
96
ok $r->ap_auth_type || 1;
103
98
ok $r->no_cache || 1;
100
ok !$r->no_local_copy;
107
ok 11 == $r->print("# buffered\n");
104
ok t_cmp $r->print("# buffered\n"), 11, "buffered print";
105
ok t_cmp $r->print(), "0E0", "buffered print";
110
ok 15 == $r->print('#',' ','n','o','t',' ','b','u','f','f','e','r','e','d',"\n");
121
my $location = '/' . Apache::TestRequest::module2path(__PACKAGE__);
122
ok t_cmp($location, $r->location, "location");
124
my $mtime = (stat __FILE__)[9];
127
ok $r->mtime == $mtime;
129
ok $r->path_info || 1;
108
my $string = "# not buffered\n";
109
ok t_cmp $r->print(split //, $string), length($string),
113
# GET header components
115
my $args = "my_args=3";
116
my $path_info = "/my_path_info";
117
my $base_uri = "/TestAPI__request_rec";
119
ok t_cmp $r->unparsed_uri, "$base_uri$path_info?$args";
121
ok t_cmp $r->uri, "$base_uri$path_info", '$r->uri';
123
ok t_cmp $r->path_info, $path_info, '$r->path_info';
125
ok t_cmp $r->args, $args, '$r->args';
127
ok t_cmp $r->the_request, "GET $base_uri$path_info?$args HTTP/1.0",
132
my $location = '/' . Apache::TestRequest::module2path(__PACKAGE__);
133
ok t_cmp $r->location, $location, '$r->location';
139
my $sent = $r->bytes_sent;
140
t_debug "sent so far: $sent bytes";
141
# at least 100 chars were sent already
147
my $mtime = (stat __FILE__)[9];
149
ok t_cmp $r->mtime, $mtime, "mtime";
154
my $finfo = APR::Finfo::stat(__FILE__, APR::Const::FINFO_NORM, $r->pool);
156
# just one field test, all accessors are fully tested in
158
ok t_cmp($r->finfo->fname,
165
$r->allowed(1 << Apache2::Const::M_GET);
167
ok $r->allowed & (1 << Apache2::Const::M_GET);
168
ok ! ($r->allowed & (1 << Apache2::Const::M_PUT));
170
$r->allowed($r->allowed | (1 << Apache2::Const::M_PUT));
171
ok $r->allowed & (1 << Apache2::Const::M_PUT);
176
my $def = [qw(fr)]; #default value
177
my $l = [qw(fr us cn)]; #new value
179
if (have_module('mod_mime')) {
180
ok t_cmp $r->content_languages, $def, '$r->content_languages';
183
skip "Need mod_mime", 0;
186
my $old = $r->content_languages($l);
187
if (have_module('mod_mime')) {
188
ok t_cmp $old, $def, '$r->content_languages';
191
skip "Need mod_mime", 0;
194
ok t_cmp $r->content_languages, $l, '$r->content_languages';
196
eval { $r->content_languages({}) };
197
ok t_cmp $@, qr/Not an array reference/,
198
'$r->content_languages(invalid)';
203
my $r = bless {}, "Apache2::RequestRec";
204
my $err = q[method `uri' invoked by a `Apache2::RequestRec' ] .
205
q[object with no `r' key!];
207
ok t_cmp $@, qr/$err/, "invalid $r object";
210
my $r = bless {}, "NonExisting";
211
my $err = q[method `uri' invoked by a `NonExisting' ] .
212
q[object with no `r' key!];
213
eval { Apache2::RequestRec::uri($r) };
214
ok t_cmp $@, qr/$err/, "invalid $r object";
218
my $err = q[method `uri' invoked by a `unknown' ] .
219
q[object with no `r' key!];
220
eval { Apache2::RequestRec::uri($r) };
221
ok t_cmp $@, qr/$err/, "invalid $r object";
226
my $newr = Apache2::RequestRec->new($r->connection, APR::Pool->new);
229
# try to overwrite the pool
230
my $table = APR::Table::make(APR::Pool->new, 50);
231
$table->set($_ => $_) for 'aa'..'za';
233
# check if $newr is still OK
234
ok $newr->connection->isa('Apache2::Connection');
237
# tested in other tests
238
# - input_filters: TestAPI::in_out_filters
239
# - output_filters: TestAPI::in_out_filters
240
# - per_dir_config: in several other tests
241
# - content_encoding: TestAPI::content_encoding
242
# - user: TestHooks::authz / TestHooks::authen
149
PerlOptions +GlobalRequest
255
<Location /TestAPI__request_rec>
256
PerlOptions +GlobalRequest
257
<IfModule mod_mime.c>
261
PerlResponseHandler TestAPI::request_rec