PageRenderTime 32ms CodeModel.GetById 12ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 1ms

/t/response/TestModPerl/Whole.pm

http://github.com/http-engine/HTTP-Engine
Perl | 48 lines | 38 code | 10 blank | 0 comment | 0 complexity | 4d04872b0d3c97ab1c221c5595d3c397 MD5 | raw file
 1package TestModPerl::Whole;
 2use strict;
 3use Apache::Test;
 4use HTTP::Engine::Interface::ModPerl;
 5use APR::Table ();
 6
 7our $REQ;
 8sub handler : method {
 9    my ($class, $r) = @_;
10    plan( $r, tests => 10 );
11
12    local $REQ;
13
14    my $res = HTTP::Engine::Interface::ModPerl::handler( $class, $r );
15    ok $r->headers_in->get('User-Agent');
16
17    ok $REQ->uri =~ qr{http://localhost:\d+/};
18    ok ref($REQ->uri) eq q{URI::WithBase};
19
20    ok $REQ->address eq '127.0.0.1';
21    ok $REQ->protocol, 'HTTP/1.0', 'protocol';
22    ok $REQ->method, 'GET', "method";
23    ok $REQ->port =~ /^\d+$/;
24    ok $REQ->_https_info, undef, '_https_info'; # XXX
25    ok $REQ->user, undef, 'user';
26
27    ok $REQ->hostname, 'localhost', 'hostname';
28
29    $res;
30}
31
32sub create_engine {
33    my ( $class, $r ) = @_;
34
35    HTTP::Engine->new(
36        interface => HTTP::Engine::Interface::ModPerl->new(
37            request_handler => sub {
38                my $req = shift;
39                $REQ = $req;
40                HTTP::Engine::Response->new(
41                    status => 200,
42                );
43            },
44        )
45    );
46}
47
481;