improved cgi engine docs
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / CGI.pm
index c6d387a..e682f6e 100644 (file)
@@ -7,6 +7,9 @@ use URI;
 require CGI::Simple;
 require CGI::Cookie;
 
+$CGI::Simple::POST_MAX        = 1048576;
+$CGI::Simple::DISABLE_UPLOADS = 0;
+
 __PACKAGE__->mk_accessors('cgi');
 
 =head1 NAME
@@ -15,12 +18,27 @@ Catalyst::Engine::CGI - The CGI Engine
 
 =head1 SYNOPSIS
 
+    #!/usr/bin/perl -w
+
+    use strict;
+    use lib '/path/to/MyApp/lib';
+    use MyApp;
+
+    MyApp->run;
+
 See L<Catalyst>.
 
 =head1 DESCRIPTION
 
 This is the CGI engine for Catalyst.
 
+The script shown above must be designated as a "Non-parsed Headers"
+script to function properly.
+To do this in Apache name the script starting with C<nph->.
+
+The performance of this way of using Catalyst is not expected to be
+useful in production applications, but it may be helpful for development.
+
 =head2 METHODS
 
 =head3 run
@@ -115,6 +133,10 @@ sub prepare_path {
     $c->req->{path} =~ s/^($loc)?\///;
     $c->req->{path} .= '/' if $c->req->path eq $loc;
     my $base = $c->cgi->url;
+    if ( $ENV{CATALYST_TEST} ) {
+        my $script = $c->cgi->script_name;
+        $base =~ s/$script$//i;
+    }
     $base = URI->new($base);
     $base->path('/') if ( $ENV{CATALYST_TEST} || !$base->path );
     $c->req->base( $base->as_string );
@@ -133,12 +155,10 @@ sub prepare_request { shift->cgi( CGI::Simple->new ) }
 sub prepare_uploads {
     my $c = shift;
     for my $name ( $c->cgi->upload ) {
-        my $filename = $c->req->params->{$name};
         $c->req->uploads->{$name} = {
-            fh       => $c->cgi->upload($filename),
-            filename => $filename,
-            size     => $c->cgi->upload_info( $filename, 'size' ),
-            type     => $c->cgi->upload_info( $filename, 'mime' )
+            fh   => $c->cgi->upload($name),
+            size => $c->cgi->upload_info( $name, 'size' ),
+            type => $c->cgi->upload_info( $name, 'mime' )
         };
     }
 }
@@ -161,4 +181,3 @@ the same terms as Perl itself.
 =cut
 
 1;
-## Please see file perltidy.ERR