1 package Catalyst::Engine::CGI::Base;
4 use base 'Catalyst::Engine';
9 __PACKAGE__->mk_accessors('cgi');
13 Catalyst::Engine::CGI::Base - Base class for CGI Engines
17 This is a base class for CGI engines.
25 This config parameter contains the C<CGI> object.
29 =head1 OVERLOADED METHODS
31 This class overloads some methods from C<Catalyst::Engine>.
35 =item $c->finalize_body
37 Prints the response output to STDOUT.
43 print $c->response->output;
46 =item $c->finalize_headers
50 sub finalize_headers {
53 $c->response->header( Status => $c->response->status );
55 print $c->response->headers->as_string("\015\012");
59 =item $c->prepare_connection
63 sub prepare_connection {
65 $c->request->address( $ENV{REMOTE_ADDR} );
66 $c->request->hostname( $ENV{REMOTE_HOST} );
67 $c->request->protocol( $ENV{SERVER_PROTOCOL} );
69 if ( $ENV{HTTPS} || $ENV{SERVER_PORT} == 443 ) {
70 $c->request->secure(1);
74 =item $c->prepare_headers
81 while ( my ( $header, $value ) = each %ENV ) {
83 next unless $header =~ /^(HTTP|CONTENT)/i;
85 ( my $field = $header ) =~ s/^HTTPS?_//;
87 $c->req->headers->header( $field => $value );
90 $c->req->method( $ENV{REQUEST_METHOD} || 'GET' );
93 =item $c->prepare_path
102 my $scheme = $c->request->secure ? 'https' : 'http';
103 my $host = $ENV{HTTP_HOST} || $ENV{SERVER_NAME};
104 my $port = $ENV{SERVER_PORT} || 80;
105 my $path = $ENV{SCRIPT_NAME} || '/';
107 unless ( $path =~ /\/$/ ) {
112 $base->scheme($scheme);
117 $base = $base->canonical->as_string;
120 my $path = $ENV{PATH_INFO} || '/';
121 $path =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
124 $c->req->base($base);
125 $c->req->path($path);
132 sub run { shift->handler }
142 Sebastian Riedel, C<sri@cpan.org>
143 Christian Hansen, C<ch@ngmedia.com>
147 This program is free software, you can redistribute it and/or modify it under
148 the same terms as Perl itself.