add test for multiple files and make it pass
Hans Dieter Pearcey [Wed, 29 Apr 2009 03:18:26 +0000 (03:18 +0000)]
lib/Catalyst/Controller/WrapCGI.pm
t/lib/TestApp/Controller/Root.pm
t/wrap-cgi.t

index 2f757de..63f07c9 100644 (file)
@@ -169,11 +169,10 @@ sub wrap_cgi {
               undef,
               $upl->filename,
               Content => $upl->slurp,
-              'Content-Type' => $upl->type || 'application/octet-stream',
-              map (
-                $_ => $upl->headers->header($_)
-              ), grep !/^Content-(?:Type|Disposition)$/,
-                            $upl->headers->header_field_names
+              map {
+                my $header = $_;
+                map { $header => $_ } $upl->headers->header($header)
+              } $upl->headers->header_field_names
             ]
           } keys %uploads
         ];
index 7d82a37..318c890 100644 (file)
@@ -13,6 +13,10 @@ my $cgi = sub {
       local $/;
       print ' baz:',<$fh>;
     }
+    if (my $fh = $cgi->param('quux')) {
+      local $/;
+      print ' quux:',<$fh>;
+    }
     die $cgi->cgi_error if $cgi->cgi_error;
 };
 
index 098ff5e..200b106 100644 (file)
@@ -36,10 +36,11 @@ $response = request POST '/cgi-bin/test.cgi',
         'Content-Type' => 'text/plain',
         Content => 3
     ],
+    quux => [ undef, quux => Content => 4 ],
   ],
   'Content-Type' => 'form-data';
 
-is($response->content, 'foo:1 bar:2 baz:3', 'POST with file upload');
+is($response->content, 'foo:1 bar:2 baz:3 quux:4', 'POST with file upload');
 
 $response = request '/cgi-bin/test_pathinfo.cgi/path/%2Finfo';
 is($response->content, '/path/%2Finfo', 'PATH_INFO is correct');