Skip to content

Processing POST-data doesn't work #10

Description

@jari-omniata

Suggesting following patch to make form work. Example code:

  return {
      # There will be a request-object as 1st parameter, but it cannot be used.
      form => sub { my (undef, $body) = @_; return do_post($request, $body) }
  };

Patch:

--- lib/AnyEvent/HTTP/Server.pm 2015-01-27 08:19:47.000000000 +0000
+++ perl-5.15.5/lib/site_perl/5.15.5/AnyEvent/HTTP/Server.pm      2015-01-27 15:15:44.000000000 +0000
@@ -490,6 +490,7 @@

                                                                                elsif (  exists $rv[0]{form} ) {
                                                                                        my $body = '';
+                                                                                       my $rq = $req; 
                                                                                        $r{on_body} = sub {
                                                                                                my ($last,$part) = @_;
                                                                                                if ( length($body) + length($$part) > $self->{max_body_size} ) {
@@ -497,7 +498,7 @@  
                                                                                                }
                                                                                                $body .= $$part;
                                                                                                if ($last) {
-                                                                                                       $rv[0]{form}( $req->form($body), $body );
+                                                                                                       $rv[0]{form}( $rq->form($body), $body );        
                                                                                                        delete $r{on_body};
                                                                                                }
                                                                                        };

This will fix the run-time error of $req being unset. The $req will be set to cb-code, but it is stale and really doesn't function.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions