You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Meir Yanovich <me...@gmail.com> on 2011/11/28 21:26:19 UTC

using mod_perl PerlResponseHandler on web proxy server gives 400 Bad Request

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