/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

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