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/02 21:09:52 UTC

cvs commit: modperl-docs/src/docs/2.0/api/Apache Const.pod Filter.pod FilterRec.pod

stas        2004/06/02 12:09:52

  Modified:    src/docs/2.0/user/handlers protocols.pod
               src/docs/2.0/api/APR Const.pod
               src/docs/2.0/api/Apache Const.pod Filter.pod FilterRec.pod
  Log:
  Apache::FilterRec and Apache::Filter manpages and other updates
  
  Revision  Changes    Path
  1.20      +15 -0     modperl-docs/src/docs/2.0/user/handlers/protocols.pod
  
  Index: protocols.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/user/handlers/protocols.pod,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -u -r1.19 -r1.20
  --- protocols.pod	21 May 2004 22:03:51 -0000	1.19
  +++ protocols.pod	2 Jun 2004 19:09:52 -0000	1.20
  @@ -460,6 +460,21 @@
   handler is filtered by the outgoing filter and which transforms it to
   be all lowercase.
   
  +Also it's worth mentioning
  +C<L<fflush()|docs::2.0::api::Apache::Filter/C_fflush_>>, which can
  +replace 3 lines of code:
  +
  +          my $b = APR::Bucket::flush_create($c->bucket_alloc);
  +          $bb_out->insert_tail($b);
  +          $c->output_filters->pass_brigade($bb_out);
  +
  +with just one line:
  +
  +          $c->output_fiilters->fflush($bb_out);
  +
  +
  +
  +
   
   
   
  
  
  
  1.20      +5 -0      modperl-docs/src/docs/2.0/api/APR/Const.pod
  
  Index: Const.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/APR/Const.pod,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -u -r1.19 -r1.20
  --- Const.pod	28 May 2004 04:43:25 -0000	1.19
  +++ Const.pod	2 Jun 2004 19:09:52 -0000	1.20
  @@ -1875,6 +1875,11 @@
   
   
   
  +
  +
  +
  +
  +
   =head2 C<:shutdown_how>
   
     use APR::Const -compile => qw(:shutdown_how);
  
  
  
  1.12      +25 -0     modperl-docs/src/docs/2.0/api/Apache/Const.pod
  
  Index: Const.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/Apache/Const.pod,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -u -r1.11 -r1.12
  --- Const.pod	22 May 2004 02:03:27 -0000	1.11
  +++ Const.pod	2 Jun 2004 19:09:52 -0000	1.12
  @@ -1026,6 +1026,8 @@
   
   
   
  +
  +
   =head3 C<Apache::MODE_EATCRLF>
   
   =over
  @@ -1034,6 +1036,10 @@
   
   =back
   
  +See
  +C<L<Apache::Filter::get_brigade()|docs::2.0::api::Apache::Filter/C_get_brigade_>>.
  +
  +
   
   
   
  @@ -1046,6 +1052,9 @@
   
   =back
   
  +See
  +C<L<Apache::Filter::get_brigade()|docs::2.0::api::Apache::Filter/C_get_brigade_>>.
  +
   
   
   
  @@ -1058,6 +1067,9 @@
   
   =back
   
  +See
  +C<L<Apache::Filter::get_brigade()|docs::2.0::api::Apache::Filter/C_get_brigade_>>.
  +
   
   
   
  @@ -1070,6 +1082,9 @@
   
   =back
   
  +See
  +C<L<Apache::Filter::get_brigade()|docs::2.0::api::Apache::Filter/C_get_brigade_>>.
  +
   
   
   
  @@ -1082,6 +1097,9 @@
   
   =back
   
  +See
  +C<L<Apache::Filter::get_brigade()|docs::2.0::api::Apache::Filter/C_get_brigade_>>.
  +
   
   
   
  @@ -1093,6 +1111,13 @@
   =item since: 1.99_12
   
   =back
  +
  +See
  +C<L<Apache::Filter::get_brigade()|docs::2.0::api::Apache::Filter/C_get_brigade_>>.
  +
  +
  +
  +
   
   
   
  
  
  
  1.14      +537 -199  modperl-docs/src/docs/2.0/api/Apache/Filter.pod
  
  Index: Filter.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/Apache/Filter.pod,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -u -r1.13 -r1.14
  --- Filter.pod	22 May 2004 02:03:27 -0000	1.13
  +++ Filter.pod	2 Jun 2004 19:09:52 -0000	1.14
  @@ -8,8 +8,39 @@
   =head1 Synopsis
   
     use Apache::Filter ();
  +  
  +  # filter attributes
  +  my $c = $f->c;
  +  my $r = $f->r;
  +  my $frec = $f->frec();
  +  my $next_f = $f->next;
  +  
  +  my $ctx = $f->ctx;
  +  $f->ctx($ctx);
  +  
  +  # bucket brigade filtering API
  +  $rc = $f->next->get_brigade($bb, $mode, $block, $readbytes);
  +  $rc = $f->next->pass_brigade($bb);
  +  $rc = $f->fflush($bb);
  +  
  +  # streaming filtering API
  +  while ($filter->read(my $buffer, $wanted)) {
  +      # transform $buffer here
  +      $filter->print($buffer);
  +  }
  +  if ($f->seen_eos) {
  +      $filter->print("filter signature");
  +  }
  +  
  +  # filter manipulations
  +  $r->add_input_filter(\&callback);
  +  $c->add_input_filter(\&callback);
  +  $r->add_output_filter(\&callback);
  +  $c->add_output_filter(\&callback);
  +  $f->remove;
  +
  +
   
  -META: to be completed
   
   
   
  @@ -17,7 +48,7 @@
   =head1 Description
   
   
  -C<Apache::Filter> provides the Perl API for Apache 2.0 filtering
  +C<Apache::Filter> provides Perl API for Apache 2.0 filtering
   framework.
   
   Make sure to read C<the Filtering
  @@ -35,40 +66,49 @@
   
   =head2 C<c>
   
  -The current connection object can be retrieved from a connection or a
  -request filter with:
  +Get the current connection object from a connection or a request
  +filter:
   
     $c = $f->c;
   
   =over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
  -=item ret: C<$c> (C<L<Apache::Connection|docs::2.0::api::Apache::Connection>>)
  +=item ret: C<$c>
  +( C<L<Apache::Connection object|docs::2.0::api::Apache::Connection>> )
  +
  +=item since: 1.99_10
   
   =back
   
   
   
   
  +
  +
   =head2 C<ctx>
   
  -Get and set the filter context data.
  +Get/set the filter context data.
   
     $ctx = $f->ctx;
  -  $f->ctx($ctx);
  +         $f->ctx($ctx);
   
   =over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
  -=item opt arg2: C<$ctx> (scalar)
  +=item opt arg2: C<$ctx> ( SCALAR )
   
  -Could be any perl SCALAR.
  +next context
   
  -=item ret: C<$ctx> (scalar)
  +=item ret: C<$ctx> ( SCALAR )
   
  -Could be any perl SCALAR.
  +current context
  +
  +=item since: 1.99_10
   
   =back
   
  @@ -105,14 +145,20 @@
   META: later we might make it a TIEd-variable interface, so it'll be
   stored automatically.
   
  -Besides its usage to store data between filter invocations, this
  -method is also useful when as a flag. For example here is how to
  -ensure that something happens only once during the filter's life:
  -
  -      unless ($f->ctx) {
  -          do_something_once();
  -          $f->ctx(1);
  -      }
  +Besides its primary purpose of storing context data across multiple
  +filter invocations, this method is also useful when used as a
  +flag. For example here is how to ensure that something happens only
  +once during the filter's life:
  +
  +  unless ($f->ctx) {
  +      do_something_once();
  +      $f->ctx(1);
  +  }
  +
  +
  +
  +
  +
   
   
   
  @@ -122,37 +168,50 @@
   Get/set the C<L<Apache::FilterRec|docs::2.0::api::Apache::FilterRec>>
   (filter record) object.
   
  -  my $frec = $f->frec();
  -  $f->frec($frec);
  +  $frec = $f->frec();
   
   =over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
  -=item opt arg2: C<$frec> (C<L<Apache::FilterRec|docs::2.0::api::Apache::FilterRec>>)
  +=item ret: C<$frec>
  +( C<L<Apache::FilterRec object|docs::2.0::api::Apache::FilterRec>> )
   
  -=item opt ret: C<$frec> (C<L<Apache::FilterRec|docs::2.0::api::Apache::FilterRec>>)
  +=item since: 1.99_10
   
   =back
   
  +For example you can call
  +C<L<$frec-E<gt>name|docs::2.0::api::Apache::FilterRec/C_name_>> to get
  +filter's name.
  +
  +
   
   
   
   
   =head2 C<next>
   
  -Returns the C<Apache::Filter> object of the next filter in chain.
  +Return the C<Apache::Filter> object of the next filter in chain.
   
     $next_f = $f->next;
   
   =over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
  -=item ret: C<$next_f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +The current filter object
   
  -=back
  +=item ret: C<$next_f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  +
  +The next filter object in chain
   
  +=item since: 1.99_10
  +
  +=back
   
   Since Apache inserts several core filters at the end of each chain,
   normally this method always returns an object. However if it's not a
  @@ -162,12 +221,11 @@
   C<L<frec|/C_frec_>> and C<L<next|/C_next_>>. If you call other methods
   the behavior is undefined.
   
  -META: I doubt anybody will ever need to mess with other filters, from
  -within a mod_perl filter. but if the need arises it's easy to tell a
  -mod_perl filter from non-mod_perl one by calling
  -C<$f-E<gt>frec-E<gt>name> (it'll return one of the following four
  -names: I<modperl_request_output>, I<modperl_request_input>,
  -I<modperl_connection_output> or I<modperl_connection_input>).
  +The next filter can be a mod_perl one or not, it's easy to tell which
  +one is that by calling
  +C<L<$f-E<gt>frec-E<gt>name|docs::2.0::api::Apache::FilterRec/C_name_>>.
  +
  +
   
   
   
  @@ -181,19 +239,26 @@
   
   =over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
  -=item ret: C<$r> (C<L<Apache::RequestRec|docs::2.0::api::Apache::RequestRec>>)
  +=item ret: C<$r>
  +( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  +
  +=item since: 1.99_10
   
   =back
   
  -If a sub-request adds filters, then the sub-request is the request
  +If a sub-request adds filters, then that sub-request object is
   associated with the filter.
   
   
   
   
   
  +
  +
  +
   =head2 C<remove>
   
   Remove the current filter from the filter chain (for the current
  @@ -203,7 +268,8 @@
   
   =over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
   =item ret: no return value
   
  @@ -225,13 +291,24 @@
   you rely on.
   
   Remember that if the connection is
  -C<L<$c-E<gt>keepalive|docs::2.0::api::Apache::Connection/C_keepalive_>>)
  -and the connection filter is removed, it won't be added untill the
  +C<L<$c-E<gt>keepalive|docs::2.0::api::Apache::Connection/C_keepalive_>>
  +) and the connection filter is removed, it won't be added until the
   connection is closed. Which may happen after many HTTP requests. You
   may want to keep the filter in place and pass the data through
   unmodified, by returning C<Apache::DECLINED>. If you need to reset the
   whole or parts of the filter context between requests, use the
  -L<technique based on C<$c-E<gt>keepalives> counting|docs::2.0::user::handler::filters>.
  +L<technique based on C<$c-E<gt>keepalives>
  +counting|docs::2.0::user::handler::filters>.
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
   
   
   
  @@ -246,24 +323,51 @@
   
   =head2 C<fflush>
   
  -Flush the C<$bb> brigade down the filter stack.
  +Flush a bucket brigade down the filter stack.
   
  -  $ret = $f->fflush($bb);
  +  $rc = $f->fflush($bb);
   
   =over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
   The current filter
   
  -=item arg1: C<$bb> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item arg1: C<$bb>
  +( C<L<Apache::Brigade object|docs::2.0::api::APR::Brigade>> )
   
   The brigade to flush
   
  -=item ret: XXX
  +=item ret:  C<$rc> ( C<L<APR::Const status
  +constant|docs::2.0::api::APR::Const>> )
  +
  +Refer to the C<L<pass_brigade()|/C_pass_brigade_>> entry.
  +
  +=item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  +
  +Exceptions are thrown only when this function is called in the void
  +context. Refer to the C<L<get_brigade()|/C_get_brigade_>> entry for
  +details.
  +
  +=item since: 1.99_10
   
   =back
   
  +C<fflush> is a shortcut method. So instead of doing:
  +
  +  my $b = APR::Bucket::flush_create($f->c->bucket_alloc);
  +  $bb->insert_tail($b);
  +  $f->pass_brigade($bb);
  +
  +one can just write:
  +
  +  $f->fflush($bb);
  +
  +
  +
  +
  +
   
   
   
  @@ -272,61 +376,214 @@
   This is a method to use in bucket brigade input filters. It acquires a
   bucket brigade from the upstream input filter.
   
  -  $ret = $next_f->get_brigade($bb, $mode, $block, $readbytes);
  +  $rc = $next_f->get_brigade($bb, $mode, $block, $readbytes);
  +  $rc = $next_f->get_brigade($bb, $mode, $block);
  +  $rc = $next_f->get_brigade($bb, $mode)
  +  $rc = $next_f->get_brigade($bb);
   
   =over 4
   
  -=item obj: C<$next_f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$next_f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  +
  +The next filter in the filter chain.
  +
  +Inside L<filter handlers|docs::2.0::user::handlers::filters> it's
  +usually C<L<$f-E<gt>next|/C_next_>>. Inside L<protocol
  +handlers|docs::2.0::user::handlers::protocols>:
  +C<L<$c-E<gt>input_filters|docs::2.0::api::Apache::Connection/C_input_filters_>>.
  +
  +
  +=item arg1: C<$bb>
  +( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  +
  +The original bucket brigade passed to C<get_brigade()>, which must be
  +empty.
  +
  +Inside L<input filter
  +handlers|docs::2.0::user::handlers::filters> it's usually the second
  +argument to the filter handler.
  +
  +Otherwise it should be created:
  +
  +  my $bb = APR::Brigade->new($c->pool, $c->bucket_alloc);
  +
  +On return it gets populated with the next bucket brigade. That brigade
  +may contain nothing if there was no more data to read. The return
  +status tells the outcome.
  +
  +
  +=item opt arg2: C<$mode> ( C<L<Apache::Const :input_mode
  +constant|docs::2.0::api::Apache::Const/C__input_mode_>> )
  +
  +The filter mode in which the data should be read.
  +
  +If inside the filter handler, you should normally pass the same mode
  +that was passed to the filter handler (the third argument).
   
  -The next filter in the chain
  +At the end of this section the available modes are presented.
   
  -=item arg1: C<$bb> (C<L<APR::Brigade|docs::2.0::api::APR::Brigade>>)
  +If the argument C<$mode> is not passed,
  +C<L<Apache::MODE_READBYTES|docs::2.0::api::Apache::Const/C_Apache__MODE_READBYTES_>>
  +is used as a default value.
   
  -The original brigade passed to get_brigade() must be empty.  On return
  -it gets populated with the next bucket brigade, or nothing if there is
  -no more data to read.
   
  -=item arg2: C<$mode> (integer)
  +=item opt arg3: C<$block> ( C<L<APR::Const :read_type
  +constant|docs::2.0::api::APR::Const/C__input_mode_>> )
   
  -The way in which the data should be read
  +You may ask the reading operation to be blocking:
  +C<L<APR::BLOCK_READ|docs::2.0::api::APR::Const/C_APR__BLOCK_READ_>>,
  +or nonblocking:
  +C<L<APR::NONBLOCK_READ|docs::2.0::api::APR::Const/C_APR__NONBLOCK_READ_>>.
   
  -=item arg3: C<$block> (integer)
  +If inside the filter handler, you should normally pass the same
  +blocking mode argument that was passed to the filter handler (the
  +forth argument).
   
  -How the operations should be performed APR::BLOCK_READ,
  -APR::NONBLOCK_READ
  +If the argument C<$block> is not passed,
  +C<L<APR::BLOCK_READ|docs::2.0::api::APR::Const/C_APR__BLOCK_READ_>> is
  +used as a default value.
   
  -=item arg4: C<$readbytes> (integer)
  +
  +=item opt arg4: C<$readbytes> ( integer )
   
   How many bytes to read from the next filter.
   
  -=item ret: C<$ret> (integer)
  +If inside the filter handler, you may want the same number of bytes,
  +as the upstream filter, i.e. the argument that was passed to the
  +filter handler (the fifth argument).
  +
  +If the argument C<$block> is not passed, 8192 is used as a default
  +value.
  +
  +
  +=item ret: C<$rc> ( C<L<APR::Const status
  +constant|docs::2.0::api::APR::Const>> )
  +
  +On success,
  +C<L<APR::SUCCESS|docs::2.0::api::APR::Const/C_APR__SUCCESS_>> is
  +returned and C<$bb> is populated (see the C<$bb> entry).
   
  -It returns C<APR::SUCCESS> on success, otherwise a failure code, in
  -which case it should be returned to the caller.
  +In case of a failure -- a failure code is returned, in which case
  +normally it should be returned to the caller.
   
   If the bottom-most filter doesn't read from the network, then
  -Apache::NOBODY_READ is returned (META: need to add this constant).
  +C<Apache::NOBODY_READ> is returned (META: need to add this constant).
  +
  +Inside L<protocol handlers|docs::2.0::user::handlers::protocols> the
  +return code can also be C<APR::EOF>, which is success as well.
  +
  +
  +=item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  +
  +You don't have to ask for the return value. If this function is called
  +in the void context, e.g.:
  +
  +  $f->next->get_brigade($bb, $mode, $block, $readbytes);
  +
  +mod_perl will do the error checking on your behalf, and if the return
  +code is not
  +C<L<APR::SUCCESS|docs::2.0::api::APR::Const/C_APR__SUCCESS_>>, an
  +C<L<APR::Error exception|docs::2.0::api::APR::Error>> will be thrown.
  +The only time you want to do the error checking yourself, is when
  +return codes besides
  +C<L<APR::SUCCESS|docs::2.0::api::APR::Const/C_APR__SUCCESS_>> are
  +considered as successful and you want to manage them by yourself.
  +
  +=item since: 1.99_15
   
   =back
   
  -For example:
   
  +Available input filter modes (the optional second argument C<$mode>)
  +are:
  +
  +=over
  +
  +=item * C<L<Apache::MODE_READBYTES|docs::2.0::api::Apache::Const/C_Apache__MODE_READBYTES_>>
  +
  +The filter should return at most readbytes data
  +
  +=item * C<L<Apache::MODE_GETLINE|docs::2.0::api::Apache::Const/C_Apache__MODE_GETLINE_>>
  +
  +The filter should return at most one line of CRLF data.  (If a
  +potential line is too long or no CRLF is found, the filter may return
  +partial data).
  +
  +=item * C<L<Apache::MODE_EATCRLF|docs::2.0::api::Apache::Const/C_Apache__MODE_EATCRLF_>>
  +
  +The filter should implicitly eat any CRLF pairs that it sees.
  +
  +=item * C<L<Apache::MODE_SPECULATIVE|docs::2.0::api::Apache::Const/C_Apache__MODE_SPECULATIVE_>>
  +
  +The filter read should be treated as speculative and any returned data
  +should be stored for later retrieval in another mode.
  +
  +=item * C<L<Apache::MODE_EXHAUSTIVE|docs::2.0::api::Apache::Const/C_Apache__MODE_EXHAUSTIVE_>>
  +
  +The filter read should be exhaustive and read until it can not read
  +any more. Use this mode with extreme caution.
  +
  +=item * C<L<Apache::MODE_INIT|docs::2.0::api::Apache::Const/C_Apache__MODE_INIT_>>
  +
  +The filter should initialize the connection if needed, NNTP or FTP
  +over SSL for example.
  +
  +=back
  +
  +Either compile all these constants with:
  +
  +  use Apache::Const -compile => qw(:input_mode);
  +
  +But it's a bit more efficient to compile only those constants that you
  +need.
  +
  +Example:
  +
  +Here is a fragment of a filter handler, that receives a bucket brigade
  +from the upstream filter:
  +
  +  use Apache::Filter ();
  +  use APR::Const    -compile => qw(SUCCESS);
  +  use Apache::Const -compile => qw(OK);
     sub filter {
         my($f, $bb, $mode, $block, $readbytes) = @_;
         
  -      my $rv = $f->next->get_brigade($bb, $mode, $block, $readbytes);
  -      return $rv unless $rv == APR::SUCCESS;
  +      my $rc = $f->next->get_brigade($bb, $mode, $block, $readbytes);
  +      return $rc unless $rc == APR::SUCCESS;
         
         # ... process $bb
         
         return Apache::OK;
     }
   
  -Normally arguments C<$mode>, C<$block>, C<$readbytes> are the same as
  +Usually arguments C<$mode>, C<$block>, C<$readbytes> are the same as
   passed to the filter itself.
   
  -It returns C<APR::SUCCESS> on success, otherwise a failure code, in
  -which case it should be returned to the caller.
  +You can see that in case of a failure, the handler returns immediately
  +with that failure code, which gets propagated to the downstream
  +filter.
  +
  +If you decide not check the return code, you can write it as:
  +
  +  sub filter {
  +      my($f, $bb, $mode, $block, $readbytes) = @_;
  +      
  +      $f->next->get_brigade($bb, $mode, $block, $readbytes);
  +      
  +      # ... process $bb
  +      
  +      return Apache::OK;
  +  }
  +
  +and the error checking will be done on your behalf.
  +
  +You will find many more examples in C<the filter
  +handlers|docs::2.0::user::handlers::filters> and
  +C<the protocol
  +handlers|docs::2.0::user::handlers::protocols> tutorials.
  +
  +
   
   
   
  @@ -336,40 +593,74 @@
   This is a method to use in bucket brigade output filters.  It passes
   the current bucket brigade to the downstream output filter.
   
  -  $ret = $next_f->pass_brigade($bb);
  +  $rc = $next_f->pass_brigade($bb);
   
   =over 4
   
  -=item obj: C<$next_f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$next_f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  +
  +The next filter in the filter chain.
  +
  +Inside L<output filter handlers|docs::2.0::user::handlers::filters>
  +it's usually C<L<$f-E<gt>next|/C_next_>>. Inside L<protocol
  +handlers|docs::2.0::user::handlers::protocols>:
  +C<L<$c-E<gt>output_filters|docs::2.0::api::Apache::Connection/C_output_filters_>>.
   
  -The next filter in the chain
  +=item arg1: C<$bb>
  +( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
   
  -=item arg1: C<$bb> (C<L<APR::Brigade|docs::2.0::api::APR::Brigade>>)
  +The bucket brigade to pass.
   
  -The current bucket brigade
  +Inside L<output filter
  +handlers|docs::2.0::user::handlers::filters> it's usually the second 
  +argument to the filter handler (after potential manipulations).
   
  -=item ret: C<$ret> (integer)
  +=item ret: C<$rc> ( C<L<APR::Const status
  +constant|docs::2.0::api::APR::Const>> )
   
  -It returns C<APR::SUCCESS> on success, otherwise a failure code, in
  -which case it should be returned to the caller.
  +On success,
  +C<L<APR::SUCCESS|docs::2.0::api::APR::Const/C_APR__SUCCESS_>> is
  +returned.
  +
  +In case of a failure -- a failure code is returned, in which case
  +normally it should be returned to the caller.
   
   If the bottom-most filter doesn't write to the network, then
  -Apache::NOBODY_WROTE is returned (META: need to add this constant).
  +C<Apache::NOBODY_WROTE> is returned (META: need to add this constant).
  +
  +Also refer to the C<L<get_brigade()|/C_get_brigade_>> entry to see how
  +to avoid checking the errors explicitly.
  +
  +=item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  +
  +Exceptions are thrown only when this function is called in the void
  +context. Refer to the C<L<get_brigade()|/C_get_brigade_>> entry for
  +details.
  +
  +=item since: 1.99_15
   
   =back
   
   The caller relinquishes ownership of the brigade (i.e. it may get
  -destroyed/overwritten/etc by the callee).
  +destroyed/overwritten/etc. by the callee).
   
  -For example:
  +Example:
   
  +Here is a fragment of a filter handler, that passes a bucket brigade
  +to the downstream filter (after some potential processing of the
  +buckets in the bucket brigade):
  +
  +  use Apache::Filter ();
  +  use APR::Const    -compile => qw(SUCCESS);
  +  use Apache::Const -compile => qw(OK);
     sub filter {
         my($f, $bb) = @_;
         
         # ... process $bb
         
  -      my $rv = $f->next->pass_brigade($bb);
  -      return $rv unless $rv == APR::SUCCESS;
  +      my $rc = $f->next->pass_brigade($bb);
  +      return $rc unless $rc == APR::SUCCESS;
         
         # process $bb
         return Apache::OK;
  @@ -382,65 +673,52 @@
   
   
   
  +
  +
  +
  +
   =head1 Streaming Filter API
   
   The following methods can be called from any filter, which uses the
   simplified streaming functionality:
   
  -=head2 C<seen_eos>
   
  -This methods returns a true value when the EOS bucket is seen by the
  -C<L<read|/C_read_>> method.
   
  -  $ret = $f->seen_eos;
   
  -=over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=head2 C<print>
   
  -The filter to remove
  +Send the contents of C<$buffer> to the next filter in chain (via
  +internal buffer).
   
  -=item ret: C<$ret> (integer)
  +  $sent = $f->print($buffer);
   
  -a true value if seen, otherwise a false value
  +=over 4
   
  -=back
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
  -This method only works in streaming filters which
  -exhaustively C<L<$f-E<gt>read|/C_read_>> all the incoming data in a
  -while loop, like so:
  +=item arg1: C<$buffer> ( string )
   
  -      while ($f->read(my $buffer, $read_len)) {
  -          # do something with $buffer
  -      }
  -      if ($f->seen_eos) {
  -          # do something
  -      }
  +The data to send.
   
  -This method is useful when a streaming filter wants to append
  -something to the very end of data, or do something at the end of the
  -last filter invocation. After the EOS bucket is read, the filter
  -should expect not to be invoked again.
  +=item ret: C<$sent> ( integer )
   
  -If an input streaming filter doesn't consume all data in the bucket
  -brigade (or even in several bucket brigades), it has to generate the
  -EOS event by itself. So when the filter is done it has to set the EOS
  -flag:
  +How many characters were sent. There is no need to check, since all
  +should go through and if something goes work an exception will be
  +thrown.
   
  -  $f->seen_eos(1);
  +=item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  +
  +=item since: 1.99_10
  +
  +=back
  +
  +This method should be used only in L<streaming
  +filters|docs::2.0::user::handlers::filters>.
   
  -when the filter handler returns, internally mod_perl will take care of
  -creating and sending the EOS bucket to the upstream input filter.
   
  -A similar logic may apply for output filters.
   
  -In most other cases you shouldn't set this flag.  When this flag is
  -prematurely set (before the real EOS bucket has arrived) in the
  -current filter invocation, instead of invoking the filter again,
  -mod_perl will create and send the EOS bucket to the next filter,
  -ignoring any other bucket brigades that may have left to consume. As
  -mentioned earlier this special behavior is useful in writing special
  -tests that test abnormal situations.
   
   
   
  @@ -448,23 +726,45 @@
   
   Read data from the filter
   
  -  $ret = $f->read(my $buffer, $read_len);
  +  $read = $f->recv($buffer, $wanted);
   
   =over 4
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  +
  +=item arg1: C<$buffer> ( SCALAR )
  +
  +The buffer to fill. All previous data will be lost.
  +
  +=item opt arg2: C<$wanted> ( integer )
   
  -=item arg1: C<$buffer> (scalar)
  +How many bytes to attempt to read.
   
  -=item arg2: C<$read_len> (integer)
  +If this optional argument is not specified -- the default 8192 will be
  +used.
   
  -=item ret: C<$ret> (number)
  +=item ret: C<$read> ( integer )
  +
  +How many bytes were actually read.
  +
  +C<$buffer> gets populated with the string that is read. It will
  +contain an empty string if there was nothing to read.
  +
  +=item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  +
  +=item since: 1.99_10
   
   =back
   
  -Reads at most C<$read_len> characters into C<$buffer>. It returns a
  -true value as long as it had something to read, or a false value
  -otherwise.
  +Reads at most C<$wanted> characters into C<$buffer>. The returned
  +value C<$read> tells exactly how many were read, making it easy to use
  +it in a while loop:
  +
  +  while ($filter->read(my $buffer, $wanted)) {
  +      # transform $buffer here
  +      $filter->print($buffer);
  +  }
   
   This is a streaming filter method, which acquires a single bucket
   brigade behind the scenes and reads data from all its
  @@ -476,46 +776,66 @@
   
   
   
  -=head2 C<fputs>
   
  -META: Autogenerated - needs to be reviewed/completed
   
  -  $ret = $f->fputs($bb, $str);
   
  -=over 4
  +=head2 C<seen_eos>
   
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +This methods returns a true value when the EOS bucket is seen by the
  +C<L<read|/C_read_>> method.
   
  -=item arg1: C<$bb> (C<L<APR::Brigade|docs::2.0::api::APR::Brigade>>)
  +  $ok = $f->seen_eos;
   
  -=item arg2: C<$str> (string)
  +=over 4
   
  -=item ret: C<$ret> (integer)
  +=item obj: C<$f>
  +( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
   
  -=back
  +The filter to remove
   
  +=item ret: C<$ok> ( true/false )
   
  +a true value if EOS has been seen, otherwise a false value
   
  -=head2 C<print>
  +=item since: 1.99_10
   
  -Send the contents of C<$buffer> to the next filter in chain (via
  -internal buffer).
  +=back
   
  -  $f->print($buffer);
  +This method only works in streaming filters which exhaustively
  +C<L<$f-E<gt>read|/C_read_>> all the incoming data in a while loop,
  +like so:
   
  -=over 4
  -
  -=item obj: C<$f> (C<L<Apache::Filter|docs::2.0::api::Apache::Filter>>)
  +      while ($f->read(my $buffer, $wanted)) {
  +          # do something with $buffer
  +      }
  +      if ($f->seen_eos) {
  +          # do something
  +      }
   
  -=item arg1: C<$buffer> (scalar)
  +The technique in this example is useful when a streaming filter wants
  +to append something to the very end of data, or do something at the
  +end of the last filter invocation. After the EOS bucket is read, the
  +filter should expect not to be invoked again.
   
  -=item ret: XXX
  +If an input streaming filter doesn't consume all data in the bucket
  +brigade (or even in several bucket brigades), it has to generate the
  +EOS event by itself. So when the filter is done it has to set the EOS
  +flag:
   
  -=back
  +  $f->seen_eos(1);
   
  -This method should be used only in streaming filters.
  +when the filter handler returns, internally mod_perl will take care of
  +creating and sending the EOS bucket to the upstream input filter.
   
  +A similar logic may apply for output filters.
   
  +In most other cases you shouldn't set this flag.  When this flag is
  +prematurely set (before the real EOS bucket has arrived) in the
  +current filter invocation, instead of invoking the filter again,
  +mod_perl will create and send the EOS bucket to the next filter,
  +ignoring any other bucket brigades that may have left to consume. As
  +mentioned earlier this special behavior is useful in writing special
  +tests that test abnormal situations.
   
   
   
  @@ -539,11 +859,15 @@
   
   =over 4
   
  -=item obj: C<$c> (C<L<Apache::Connection|docs::2.0::api::Apache::Connection>>) or C<$r> (C<L<Apache::RequestRec|docs::2.0::api::Apache::RequestRec>>)
  +=item obj: C<$c>
  +( C<L<Apache::Connection object|docs::2.0::api::Apache::Connection>> ) or C<$r>
  +( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
   
   =item arg1: C<&callback> (CODE ref)
   
  -=item ret: XXX
  +=item ret: no return value
  +
  +=item since: 1.99_10
   
   =back
   
  @@ -573,40 +897,15 @@
   
   =over 4
   
  -=item obj: C<$c> (C<L<Apache::Connection|docs::2.0::api::Apache::Connection>>) or C<$r> (C<L<Apache::RequestRec|docs::2.0::api::Apache::RequestRec>>)
  +=item obj: C<$c>
  +( C<L<Apache::Connection object|docs::2.0::api::Apache::Connection>> ) or C<$r>
  +( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
   
   =item arg1: C<&callback> (CODE ref)
   
  -=item ret: XXX
  -
  -=back
  -
  -
  -
  -
  -
  -=head1 TIE Interface
  -
  -C<Apache::Filter> also implements a tied interface, so you can work
  -with the C<$f> object as a hash reference.
  -
  -META: complete
  -
  -
  -
  -=head2 C<TIEHANDLE>
  -
  -META: Autogenerated - needs to be reviewed/completed
  -
  -  $ret = TIEHANDLE($stashsv, $sv);
  -
  -=over 4
  -
  -=item obj: C<$stashsv> (scalar)
  -
  -=item arg1: C<$sv> (scalar)
  +=item ret: no return value
   
  -=item ret: C<$ret> (scalar)
  +=item since: 1.99_10
   
   =back
   
  @@ -614,23 +913,6 @@
   
   
   
  -=head2 C<PRINT>
  -
  -META: Autogenerated - needs to be reviewed/completed
  -
  -  $ret = PRINT(...);
  -
  -=over 4
  -
  -=item obj: C<...> (XXX)
  -
  -=item ret: C<$ret> (integer)
  -
  -=back
  -
  -
  -
  -
   
   =head1 Filter Handler Attributes
   
  @@ -780,6 +1062,62 @@
   
   See
   C<L<PerlSetInputFilter|docs::2.0::user::handlers::filters/C_PerlSetInputFilter_>>.
  +
  +
  +
  +
  +
  +
  +
  +=head1 TIE Interface
  +
  +C<Apache::Filter> also implements a tied interface, so you can work
  +with the C<$f> object as a hash reference.
  +
  +The TIE interface is mostly unimplemented and might be implemented
  +post 2.0 release.
  +
  +
  +
  +=head2 C<TIEHANDLE>
  +
  +  $ret = TIEHANDLE($stashsv, $sv);
  +
  +=over 4
  +
  +=item obj: C<$stashsv> ( SCALAR )
  +
  +=item arg1: C<$sv> ( SCALAR )
  +
  +=item ret: C<$ret> ( SCALAR )
  +
  +=item since: 1.99_10
  +
  +=back
  +
  +
  +
  +
  +
  +=head2 C<PRINT>
  +
  +  $ret = PRINT(...);
  +
  +=over 4
  +
  +=item obj: C<...> (XXX)
  +
  +=item ret: C<$ret> ( integer )
  +
  +=item since: 1.99_10
  +
  +=back
  +
  +
  +
  +
  +
  +
   
   
   =head1 See Also
  
  
  
  1.7       +32 -19    modperl-docs/src/docs/2.0/api/Apache/FilterRec.pod
  
  Index: FilterRec.pod
  ===================================================================
  RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/Apache/FilterRec.pod,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- FilterRec.pod	22 May 2004 02:03:27 -0000	1.6
  +++ FilterRec.pod	2 Jun 2004 19:09:52 -0000	1.7
  @@ -7,16 +7,26 @@
   
   =head1 Synopsis
   
  +  use Apache::Filter ();
     use Apache::FilterRec ();
  -
  -META: to be completed
  +  
  +  my $frec = $filter->frec;
  +  print "filter name is:", $frec->name;
   
   
   
   
   =head1 Description
   
  -META: to be completed
  +C<Apache::FilterRec> provides an access to the filter record
  +structure.
  +
  +The C<Apache::FilterRec> object is retrieved by calling
  +C<L<frec()|docs::2.0::api::Apache::Filter/C_frec_>>:
  +
  +  $frec = $filter->frec;
  +
  +
   
   
   
  @@ -30,39 +40,42 @@
   
   =head2 C<name>
   
  -META: Autogenerated - needs to be reviewed/completed
  -
   The registered name for this filter
   
     $name = $frec->name();
   
   =over 4
   
  -=item obj: C<$frec> (C<L<Apache::FilterRec|docs::2.0::api::Apache::FilterRec>>)
  +=item obj: C<$frec>
  +( C<L<Apache::FilterRec object|docs::2.0::api::Apache::FilterRec>> )
   
   =item ret: C<$name> (string)
   
  -=back
  -
  -
  -
  +=item since: 1.99_10
   
  +=back
   
  -=head2 C<next>
  +mod_perl filters have four names:
   
  -META: Autogenerated - needs to be reviewed/completed
  +  modperl_request_output
  +  modperl_request_input
  +  modperl_connection_output
  +  modperl_connection_input
   
  -The next filter_rec in the list
  +You can see the names of the non-mod_perl filters as well. By calling
  +C<L<$filter-E<gt>next-E<gt>frec-E<gt>name|docs::2.0::api::Apache::Filter/C_next_>>
  +you can get the name of the next filter in the chain.
   
  -  $next_frec = $frec->next();
  +Example:
   
  -=over 4
  +Let's print the name of the current and the filter that follows it:
   
  -=item obj: C<$frec> (C<L<Apache::FilterRec|docs::2.0::api::Apache::FilterRec>>)
  -
  -=item ret: C<$next_frec> (C<L<Apache::FilterRec|docs::2.0::api::Apache::FilterRec>>)
  +  use Apache::Filter ();
  +  use Apache::FilterRec ();
  +  for my $frec ($filter->frec, $filter->next->frec) {
  +      print "Name: ", $frec->name;
  +  }
   
  -=back
   
   
   
  
  
  

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