Bump required Module::Install version in everything. janus++
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index 347f781..b7b8be0 100644 (file)
@@ -314,7 +314,7 @@ sub prepare_body {
         unless ( $c->request->{_body} ) {
             my $type = $c->request->header('Content-Type');
             $c->request->{_body} = HTTP::Body->new( $type, $length );
-            $c->request->{_body}->{tmpdir} = $c->config->{uploadtmp}
+            $c->request->{_body}->tmpdir( $c->config->{uploadtmp} )
               if exists $c->config->{uploadtmp};
         }
         
@@ -452,13 +452,13 @@ sub prepare_query_parameters {
     # replace semi-colons
     $query_string =~ s/;/&/g;
     
-    my @params = split /&/, $query_string;
+    my @params = grep { length $_ } split /&/, $query_string;
 
     for my $item ( @params ) {
         
         my ($param, $value) 
             = map { $self->unescape_uri($_) }
-              split( /=/, $item );
+              split( /=/, $item, 2 );
           
         $param = $self->unescape_uri($item) unless defined $param;
         
@@ -625,6 +625,11 @@ sub write {
     my $len   = length($buffer);
     my $wrote = syswrite STDOUT, $buffer;
     
+    if ( !defined $wrote && $! == EWOULDBLOCK ) {
+        # Unable to write on the first try, will retry in the loop below
+        $wrote = 0;
+    }
+    
     if ( defined $wrote && $wrote < $len ) {
         # We didn't write the whole buffer
         while (1) {
@@ -653,10 +658,9 @@ as Apache may implement this using Apache's C-based modules, for example.
 
 sub unescape_uri {
     my ( $self, $str ) = @_;
-    
-    $str =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
-    $str =~ s/\+/ /g;
-    
+
+    $str =~ s/(?:%([0-9A-Fa-f]{2})|\+)/defined $1 ? chr(hex($1)) : ' '/eg;
+
     return $str;
 }