You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs-cvs@perl.apache.org by st...@apache.org on 2004/06/04 11:30:38 UTC

cvs commit: modperl-docs/src/docs/2.0/user/handlers filters.pod

stas        2004/06/04 02:30:38

  Modified:    src/docs/2.0/user/handlers filters.pod
  Log:
  various fixes
  
  Revision  Changes    Path
  1.42      +41 -19    modperl-docs/src/docs/2.0/user/handlers/filters.pod
  
  Index: filters.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/user/handlers/filters.pod,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -u -r1.41 -r1.42
  --- filters.pod	21 May 2004 22:03:51 -0000	1.41
  +++ filters.pod	4 Jun 2004 09:30:38 -0000	1.42
  @@ -1118,7 +1118,8 @@
     
     use Apache::RequestRec ();
     use Apache::RequestIO ();
  -  use APR::Table ();
  +  use APR::Brigade ();
  +  use APR::Bucket ();
     
     use Apache::Const -compile => qw(OK M_POST);
     
  @@ -1136,18 +1137,40 @@
         return Apache::OK;
     }
     
  +  use Apache::Const -compile => qw(MODE_READBYTES);
  +  use APR::Const    -compile => qw(SUCCESS BLOCK_READ);
  +  
  +  use constant IOBUFSIZE => 8192;
  +  
     sub content {
         my $r = shift;
     
  -      $r->setup_client_block;
  +      my $bb = APR::Brigade->new($r->pool, $r->connection->bucket_alloc);
  +  
  +      my $data = '';
  +      my $seen_eos = 0;
  +      do {
  +          $r->input_filters->get_brigade($bb,
  +              Apache::MODE_READBYTES, APR::BLOCK_READ, IOBUFSIZE);
  +  
  +          while (!$bb->is_empty) {
  +              my $b = $bb->first;
  +              $b->remove;
  +  
  +              if ($b->is_eos) {
  +                  $seen_eos++;
  +                  last;
  +              }
     
  -      return '' unless $r->should_client_block;
  +              my $buf = $b->read;
  +              $data .= $buf if length $buf;
  +          }
  +  
  +      } while (!$seen_eos);
     
  -      my $len = $r->headers_in->get('content-length');
  -      my $buf;
  -      $r->get_client_block($buf, $len);
  +      $bb->destroy;
     
  -      return $buf;
  +      return $data;
     }
     
    1;
  @@ -1222,9 +1245,7 @@
     
         my @data;
         for (my $b = $bb->first; $b; $b = $bb->next($b)) {
  -          my $data = $b->read;
  -          $bdata = '' unless defined $bdata;
  -          push @data, $b->type->name, $bdata;
  +          push @data, $b->type->name, $b->read;
         }
     
         # send the sniffed info to STDERR so not to interfere with normal
  @@ -1403,9 +1424,9 @@
     >>> connection output filter
         o bucket 1: HEAP
     [HTTP/1.1 200 OK
  -  Date: Tue, 19 Nov 2002 15:59:32 GMT
  -  Server: Apache/2.0.44-dev (Unix) mod_perl/1.99_08-dev 
  -  Perl/v5.8.0 mod_ssl/2.0.44-dev OpenSSL/0.9.6d DAV/2
  +  Date: Fri, 04 Jun 2004 09:13:26 GMT
  +  Server: Apache/2.0.50-dev (Unix) mod_perl/1.99_15-dev
  +  Perl/v5.8.4 mod_ssl/2.0.50-dev OpenSSL/0.9.7c DAV/2
     Connection: close
     Transfer-Encoding: chunked
     Content-Type: text/plain; charset=ISO-8859-1
  @@ -1595,9 +1616,11 @@
         return Apache::DECLINED;
     }
   
  -However, this can't be used with Apache 2.0.46 and lower, since it has
  +However, this can't be used with Apache 2.0.49 and lower, since it has
   a bug when trying to remove the edge connection filter (it doesn't
  -remove it). Don't know if it's going to be fixed in 2.0.47]
  +remove it). Most likely that problem will be not fixed in the 2.0
  +series due to design flows. I don't know if it's going to be fixed in
  +2.1 series.]
   
   If the job wasn't done yet, the filter calls C<get_brigade>, which
   populates the C<$bb> bucket brigade. Next, the filter steps through
  @@ -1765,7 +1788,7 @@
   then retrieved by the downstream filter when our handler returns.
   
   This filter doesn't need to know whether it was invoked for the first
  -time or whether it has already done something. It's state-less
  +time or whether it has already done something. It's a state-less
   handler, since it has to lower case everything that passes through
   it. Notice that this filter can't be used as the connection filter for
   HTTP requests, since it will invalidate the incoming request headers;
  @@ -2080,7 +2103,7 @@
     use APR::Bucket ();
     
     use Apache::Const -compile => 'OK';
  -  use APR::Const -compile => ':common';
  +  use APR::Const    -compile => ':common';
     
     sub handler : FilterRequestHandler {
         my($f, $bb) = @_;
  @@ -2098,8 +2121,7 @@
                 last;
             }
     
  -          my $data = $bucket->read;
  -          if ($data) {
  +          if (my $data = $bucket->read) {
                 $data = join "",
                     map {scalar(reverse $_), "\n"} split "\n", $data;
                 $bucket = APR::Bucket->new($data);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-cvs-help@perl.apache.org