1 package Catalyst::Engine::Test;
4 use base 'Catalyst::Engine::CGI';
12 Catalyst::Engine::Test - Catalyst Test Engine
16 A script using the Catalyst::Engine::Test module might look like:
21 $ENV{CATALYST_ENGINE} = 'Test';
25 use lib '/path/to/MyApp/lib';
28 MyApp->run('/a/path');
32 This is the Catalyst engine specialized for testing.
34 =head1 OVERLOADED METHODS
36 This class overloads some methods from C<Catalyst::Engine::CGI>.
40 =item finalize_headers
44 sub finalize_headers {
45 my ( $self, $c ) = @_;
46 my $protocol = $c->request->protocol;
47 my $status = $c->response->status;
48 my $message = status_message($status);
49 print "$protocol $status $message\n";
50 $c->response->headers->date(time);
51 $self->NEXT::finalize_headers($c);
59 my ( $self, $class, $request ) = @_;
61 $request = Catalyst::Utils::request($request);
65 PATH_INFO => $request->uri->path || '',
66 QUERY_STRING => $request->uri->query || '',
67 REMOTE_ADDR => '127.0.0.1',
68 REMOTE_HOST => 'localhost',
69 REQUEST_METHOD => $request->method,
70 SERVER_NAME => 'localhost',
71 SERVER_PORT => $request->uri->port,
72 SERVER_PROTOCOL => 'HTTP/1.1',
77 for my $header ( $request->header_field_names ) {
78 my $name = uc $header;
79 $name = 'COOKIE' if $name eq 'COOKIES';
81 $name = 'HTTP_' . $name
82 unless $name =~ m/\A(?:CONTENT_(?:LENGTH|TYPE)|COOKIE)\z/;
83 my $value = $request->header($header);
84 if ( exists $ENV{$name} ) {
85 $ENV{$name} .= "; $value";
94 my $input = $request->content;
95 open STDIN, '<', \$input;
100 open STDOUT, '>', \$output;
103 $class->handle_request;
106 return HTTP::Response->parse($output);
109 =item $self->read_chunk($c, $buffer, $length)
113 sub read_chunk { shift; shift; *STDIN->read(@_); }
123 Sebastian Riedel, <sri@cpan.org>
125 Christian Hansen, <ch@ngmedia.com>
127 Andy Grundman, <andy@hybridized.org>
131 This program is free software, you can redistribute it and/or modify it under
132 the same terms as Perl itself.