perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Alonso Sánchez <>
Subject Apache2 filters questions
Date Wed, 03 Aug 2005 14:33:08 GMT
Hi all.

I'm fighting hard with Apache2 filters  + mod_perl, and I have some
doubts to ask you:

I want to analyze a POST request to my Apache2 server, analyze it, and
change the headers to redirect the POST to another uri, depending on
the content (body of the POST).

As I need body+headers, I'm using a Input Connection Filter.

The main problem is how to stop the buckets brigades. It's easy to
analyze the body, but when I process it, the brigades with headers
have just passed to the next filter (or the core).

In order to "stop" the previous brigades, I read all the brigades
using a loop which knows when the body finishes, reading
Content-Length header. As I use Connection Filter, and there isn't
EOS, it is the unique way to know WHEN the filter must stop getting
brigades .... Are there any way else to know it ??

This is the loop in the filter handler:

do {
        my $rv = $f->next->get_brigade($bb, $mode, $block, $readbytes);
        return $rv unless $rv == APR::Const::SUCCESS;

        my $b = $bb->last;
        if ($seen_body_separator && $seen_cl) {
                $remaining -= $b->length;
                if ($remaining == 0) {$seen_eos++;}
        $b->read(my $data);
        if (!$seen_cl and !$seen_body_separator and
              $data =~ /^Content-Length: (\d+)[\r\n]+$/)
             $remaining = $1;
        if ($data =~ /^[\r\n]+$/) {
        $brigade .= $data;
      } while (!$seen_eos);

With this filter, I have only ONE brigade, with ALL the buckets of the
request. The brigade pass to then next filter, but there is not
response of the apache core. It seems that they were waiting for a
EOS. If I stop the request (Ctrl+C, or STOP in the browser) the
brigade passes to the core. But here, I have another problem, because
the apache core says that it is a bad header request. The full brigade
arrive to the core, like the correct header.

Must be:
POST /uri HTTP/1.1

It is:
POST /uri HTTP/1.1\nTE: deflate\nContent-type ......

Why does the brigade need an artificial Ctrl-C?
Does Apache need one bucket brigade per HEADER?

Is there another way to modify the header of a request once processed
the body content?

Thanks in advance.

View raw message