release 0.035
[catagits/Catalyst-Controller-WrapCGI.git] / lib / Catalyst / Controller / WrapCGI.pm
index f1de732..d82896d 100644 (file)
@@ -6,10 +6,10 @@ use mro 'c3';
 
 extends 'Catalyst::Controller';
 
+use Catalyst::Exception ();
 use HTTP::Request::AsCGI ();
 use HTTP::Request ();
 use URI ();
-use Catalyst::Exception ();
 use URI::Escape;
 use HTTP::Request::Common;
 
@@ -21,7 +21,7 @@ Catalyst::Controller::WrapCGI - Run CGIs in Catalyst
 
 =cut
 
-our $VERSION = '0.029';
+our $VERSION = '0.035';
 
 =head1 SYNOPSIS
 
@@ -163,7 +163,7 @@ sub wrap_cgi {
   if ($body) { # Slurp from body filehandle
     local $/; $body_content = <$body>;
   } else {
-    my $body_params = $c->req->body_parameters;
+    my $body_params = $c->req->body_parameters || {};
 
     if (my %uploads = %{ $c->req->uploads }) {
       my $post = POST 'http://localhost/',
@@ -234,9 +234,12 @@ sub wrap_cgi {
 
     select($old);
 
-    Catalyst::Exception->throw(
-        message => "CGI invocation failed: $saved_error"
-    ) if $saved_error;
+    if( $saved_error ) {
+        die $saved_error if ref $saved_error;
+        Catalyst::Exception->throw(
+            message => "CGI invocation failed: $saved_error"
+           );
+    }
   }
 
   return $env->response;
@@ -385,9 +388,11 @@ Matt S. Trout C<< <mst at shadowcat.co.uk> >>
 
 =head1 CONTRIBUTORS
 
-Rafael Kitover C<< <rkitover at cpan.org> >>
+Caelum: Rafael Kitover <rkitover@cpan.org>
+
+confound: Hans Dieter Pearcey <hdp@cpan.org>
 
-Hans Dieter Pearcey C<< <hdp at cpan.org> >>
+rbuels: Robert Buels <rbuels@gmail.com>
 
 Some code stolen from Tatsuhiko Miyagawa's L<CGI::Compile>.