3 package Test::WWW::Mechanize::CGI;
7 use base 'Test::WWW::Mechanize';
10 use HTTP::Request::AsCGI;
24 my ( $self, $request ) = @_;
26 $self->cookie_jar->add_cookie_header($request) if $self->cookie_jar;
28 my $c = HTTP::Request::AsCGI->new($request)->setup;
30 eval { $self->cgi->() };
35 $response = HTTP::Response->new(500);
36 $response->date( time() );
37 $response->content( $response->error_as_HTML );
40 $response = $c->restore->response;
43 $response->header( 'Content-Base', $request->uri );
44 $response->request($request);
45 $self->cookie_jar->extract_cookies($response) if $self->cookie_jar;
55 use Test::More tests => 3;
57 my $mech = Test::WWW::Mechanize::CGI->new;
63 $q->start_html('Hello World'),
64 $q->h1('Hello World'),
68 $mech->get_ok('http://localhost/');
69 $mech->title_is('Hello World');
70 $mech->content_contains('Hello World');