I'm porting a site from Apache::Registry to mod_perl handlers, using
Apache 1.3.12 and mod_perl 1.21. I've noticed a problem with POST
requests: if a ContentHandler reads the POST body with $r->content and
subsequently returns NOT_FOUND, Apache will hang trying to read the
content again.
The simplest handler that exhibits this behavior is:
package TestHandler;
use strict;
use Apache::Constants qw(:common NOT_FOUND);
sub handler {
my $r = shift;
my $c = $r->content
if $r->method eq 'POST' &&
$r->header_in('Content-type') eq 'application/x-www-form-urlencoded';
return NOT_FOUND;
}
1;
POSTing to this handler hangs Apache, unless the content is extremely
short. A strace shows that it's stuck read()ing from the client socket.
I've looked with gdb, and it looks like ap_die calls
ap_discard_request_body, which calls ap_setup_client_block, which
re-reads r->remaining from the Content-length header.
As a work-around, I've added a
$r->header_in("Content-length", 0);
just before returning NOT_FOUND, and it seems to work. But this doesn't
look like a clean solution to me. Maybe ap_setup_client_block should
silently return OK if it gets called more than once in a request...
--
Roger Espel Llima, [EMAIL PROTECTED]
http://www.iagora.com/~espel/index.html