Inter-Corporate Computer & Network Services, Inc. Solutions Services Support Products Company Login Contact

KnowledgeBase   →   "Internal apreq error" in Apache 2 httpd error logs

After upgrading to APR libapreq2 v2.17, web pages generated by Perl scripts running in the modperl_2 v2.17 environment that attempt to utilize CGI parameters with the Apache2::Upload that don't contain any file upload data (or when malformed-or-missing HTTP headers are encountered), the process terminates and an "Internal apreq error" is recorded in the Apache httpd v2.4 error log (without indicating the problematic line number).

The error is triggered by the final line in the following code:

use Apache2::Request;
use Apache2::Upload;
my $req    = Apache2::Request->new($r);
my $upload = $req->upload("cgi-parameter-name");

The solution is to wrap the call to the $req->upload method in an eval{} block:

use Apache2::Request;
use Apache2::Upload;
my $req    = Apache2::Request->new($r);
my $upload; eval { $upload = $req->upload("cgi-parameter-name"); };

Although ignoring errors is normally a discouraged practice, in this case we're ignoring a situation where the user elected to not attach a file before submitting the HTML form (by way of the POST method with the enctype=multipart/form-data parameter).

Your code still needs to check whether a file was uploaded by testing whether the $upload variable is defined (consult the Apache2::Upload documentation for further information).

 
Home Solutions Services Support Products Company Login Contact
Copyright © 1992-2024 Inter-Corporate Computer & Network Services, Inc.  All rights reserved.  All trademarks are the property of their respective owners.  The information provided on this internet site does not constitute a contract with any person or entity unless otherwise specified.  Although reasonable efforts are made to present accurate information, we do not guarantee it.  Information may change without prior notice.