I have a problem with a filter and a content handler: httpd.conf:
... PerlInputFilterHandler Apache::Filter1 PerlResponseHandler Apache::TestPost ... --------------------------%<-------------------------------------------- - Apache::Filter1.pm: package Apache::Filter1; use strict; use Apache2::Const qw(:common); use Apache2::Filter (); use Apache2::Log (); use Apache2::RequestRec (); sub handler { my $f = shift; my $r = $f->r; my $buffer; my $context = $f->ctx; if ($context) { $buffer = $context; } while ($f->read (my $input)) { $buffer .= $input; $r->log->debug ("read <<$input>>"); } if ($f->seen_eos) { $r->log->debug ("buffer = <<$buffer>>"); my $printed = $f->print($buffer); } else { $f->ctx ($buffer); $f->print(''); } Apache2::Const::OK; } 1; --------------------------%<-------------------------------------------- - Apache::TestPost.pm: # Post Test package Apache::TestPost; use strict; use Data::Dumper; use HTTP::Response; use Apache2::Const qw(:common :methods :http); use Apache2::Log (); use Apache2::URI (); use APR::Date (); use APR::Table (); use APR::URI (); sub handler { my $r = shift; # copy content data, if any my ($buf, $input, $ret); my $bufsize = 3; while ($ret = $r->read ($buf, $bufsize) > 0) { $input .= $buf; $r->log->debug ("read <<$buf>>, ret = $ret"); } $r->log->debug ("read <<$buf>>, ret = $ret"); $r->content_type ("text/plain"); print "Content\n$input\n-----------\n"; OK; } 1; --------------------------%<-------------------------------------------- - When I make a http-request, I get the following output: > POST / HTTP/1.1 > Content-type: text/xml > Content-Length: 10 > > 0123456789HTTP/1.1 200 OK < Date: Mon, 11 Jun 2007 11:01:23 GMT < Server: Apache < Transfer-Encoding: chunked < Content-Type: text/plain Content 012 ----------- I am postin 0123456789 but I see onle 012 in the response. The debugging output is: [Mon Jun 11 16:24:23 2007] [debug] Filter1.pm(25): read <<012>> [Mon Jun 11 16:24:23 2007] [debug] Filter1.pm(25): read <<345>> [Mon Jun 11 16:24:23 2007] [debug] Filter1.pm(25): read <<678>> [Mon Jun 11 16:24:23 2007] [debug] Filter1.pm(25): read <<9>> [Mon Jun 11 16:24:23 2007] [debug] Filter1.pm(28): buffer = <<0123456789>> [Mon Jun 11 16:24:23 2007] [debug] TestPost.pm(24): read <<012>>, ret = 1 [Mon Jun 11 16:24:23 2007] [debug] TestPost.pm(26): read <<>>, ret = What am I doing wrong? Yes, I could increase $bufsize, but if I set it to 10000 and the input is 10001 bytes, I have the same problem. My filter Filter1.pm needs the hole input in one string, because it makes an XML-transformation, therfore the input is collected and printet out as whole at the end. If I omit the line $f->print (''); in Filter1.pm, I get the following error: [Mon Jun 11 16:29:34 2007] [error] Apache2::RequestIO::read: Aborting read from client. One of the input filters is broken. It returned an empty bucket brigade for the APR_BLOCK_READ mode request at /magwien/gondor-mod-perl2-2.6.5/Apache/TestPost.pm line 22, <DATA> line 799. Why? Thanks, Peter