using mod_perl PerlResponseHandler on web proxy server gives 400 Bad Request

Meir Yanovich <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CA+-hL2VMF0xmT9uBStcjy8-No_jBsbehhHxCDAUaG-9vcUQ7kQ@mail.gmail.com>
im using mod_perl with apache both the newest versions . on my proxy
server the PerlInputFilterHandler filter is working great and capture
the request and send it to application server , but the responset got
not handled by the PerlResponseHandler . the response error im getting
:
HTTP/1.1 400 Bad Request
Date: Mon, 28 Nov 2011 20:13:45 GMT
Server: test_server/1.06
Content-type: text/html
Via: 1.1 192.xxx.1.xx:80xx
Vary: Accept-Encoding
Content-Encoding: gzip
Connection: close
Transfer-Encoding: chunked

here is my configuration in the httpd.conf
<Location */*>
      SetHandler modperl
      PerlResponseHandler +MyApache2::Dump
      PerlInputFilterHandler +MyApache2::InputRequestFilterLC2
</Location>

here is short code of my Dump script :
package MyApache2::Dump;

  use strict;
  use warnings;
  use Apache2::RequestRec ();
  use Apache2::RequestIO ();
  use Apache2::Filter ();
  use APR::Brigade ();
  use APR::Bucket ();
  use Apache2::Const -compile => qw(OK M_POST);
  use utf8;
  require Compress::Zlib;


  sub handler {
      my $r = shift;
      my $buffer="";
      my $bufferContaier = "";
      my $data  ="";

      $r->content_type('text/xml');

      if ($r->method_number == Apache2::Const::M_POST) {
         $buffer = content($r);
         $data = Compress::Zlib::memGunzip($buffer) ;
         if (defined $data && $data ne '') {

             $data =~ s/[\r\n]+//g;
             my $newStrToClient = $data;
             $r->print($newStrToClient);
        }
        else
        {
         print STDERR "$buffer is undefined\n";
        }

      }
       return Apache2::Const::OK;
  }

  use Apache2::Connection ();
  use Apache2::Const -compile => qw(MODE_READBYTES);
  use APR::Const     -compile => qw(SUCCESS BLOCK_READ);
  use constant IOBUFSIZE => 8192;
  sub content {
      my $r = shift;
      my $bb = APR::Brigade->new($r->pool, $r->connection->bucket_alloc);
      my $data = '';
      my $seen_eos = 0;
      do {
          $r->input_filters->get_brigade($bb, Apache2::Const::MODE_READBYTES,
                                         APR::Const::BLOCK_READ, IOBUFSIZE);

          for (my $b = $bb->first; $b; $b = $bb->next($b)) {
              if ($b->is_eos) {
                  $seen_eos++;
                  last;
              }

              if ($b->read(my $buf)) {
                  $data .= $buf;

              }
              $b->remove; # optimization to reuse memory
          }
      } while (!$seen_eos);
      $bb->destroy;
      return $data;
  }

in simple request / response setup every thing is working fine , only
when i setup as proxy im getting :HTTP/1.1 400 Bad Request
Thanks for helping
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.