Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing POST-data doesn't work #10

Open
jari-omniata opened this issue Jan 28, 2015 · 0 comments
Open

Processing POST-data doesn't work #10

jari-omniata opened this issue Jan 28, 2015 · 0 comments

Comments

@jari-omniata
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant