http://www.perlmonks.org?node_id=1231238

evergreen has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I am using Apache2::Request to parse a multi-part Http post in a .mpl script running under apache mod_perl. The Http post comes from an upstream system.

Here is the relevant part of the script.

$r = shift; $cgi = Apache2::Request->new($r); $r->discard_request_body; # efficiently parses the request body my $parser_status = $cgi->param_status(); if ($parser_status ne 'Success') { $parser_error = $parser_status; }

The problem is that the call to param_status() returns "Internal apreq error" and further down in the script, it finds that an expected multi-part content is missing.

The post is retried by the upstream system until it succeeds, and after 10-15 retries it eventually succeeds, meaning there was no apreq error when it succeeded and the expected multi-part is present.

Is there any way to get more information about why there is an "Internal apreq error"?

Thanks.

Replies are listed 'Best First'.
Re: Apache2::Request Internal apreq error
by thanos1983 (Parson) on Mar 14, 2019 at 09:05 UTC

    Hello evergreen,

    My answer is not Perl related but my troubleshooting approach on this would be to capture a tcpdump (LinuxOS) if you are running on (WindowsOS) wireshark. By doing so you will see the package arriving and you will explicitly see what is the reply/error back.

    Update: From the documentation Apache2::Request/param this should give more data:

    $req->args_status(1); # set error state for query-string parser ok $req->param_status == 1; $foo = $req->param("foo"); ok $foo == 1; eval { @foo = $req->param("foo") }; ok $@->isa("Apache2::Request::Error"); undef $@; eval { my $not_found = $req->param("non-existent-param") }; ok $@->isa("Apache2::Request::Error"); $req->args_status(0); # reset query-string parser state to "success"

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
      Thanks thanos1983, I tried tcpdump and Wireshark, but the content of the post requests looks good and the multi-part attachments are there, but somehow it is not being parsed.

      I also see this in apache error log:
      [Thu Mar 14 18:40:04 2019] [error] [client 17.108.244.6] (70008)Partia +l results are valid but processing is incomplete: ap_get_brigade fail +ed during prefetch [Thu Mar 14 18:40:04 2019] [error] Internal apreq error
      Will update here if I find anything.