You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by st...@apache.org on 2002/11/25 23:46:29 UTC

cvs commit: modperl-2.0 Changes

stas        2002/11/25 14:46:29

  Modified:    t/filter .cvsignore
               src/modules/perl modperl_filter.c modperl_types.h
               t/filter/TestFilter reverse.pm
               .        Changes
  Added:       t/htdocs/filter reverse.txt
               t/filter reverse.t
  Log:
  Allow output streaming filters to append data to the end of the stream, by
  postponing the propogation of the EOS bucket down the stream till the
  handler is returned. + tests
  
  Revision  Changes    Path
  1.1                  modperl-2.0/t/htdocs/filter/reverse.txt
  
  Index: reverse.txt
  ===================================================================
  zyxwvutsrqponmlkjihgfedcba
  9876543210
  
  
  
  1.3       +1 -1      modperl-2.0/t/filter/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/filter/.cvsignore,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- .cvsignore	12 Sep 2001 17:11:48 -0000	1.2
  +++ .cvsignore	25 Nov 2002 22:46:29 -0000	1.3
  @@ -3,4 +3,4 @@
   input_body.t
   input_msg.t
   lc.t
  -reverse.t
  +
  
  
  
  1.3       +28 -3     modperl-2.0/t/filter/reverse.t
  
  
  
  
  1.39      +14 -2     modperl-2.0/src/modules/perl/modperl_filter.c
  
  Index: modperl_filter.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- modperl_filter.c	19 Aug 2002 20:07:01 -0000	1.38
  +++ modperl_filter.c	25 Nov 2002 22:46:29 -0000	1.39
  @@ -157,6 +157,17 @@
   
       MP_TRACE_f(MP_FUNC, "%s returned %d\n", handler->name, status);
   
  +    /* when the streaming filter is invoked it should be able to send
  +     * extra data, after the read in a while() loop is finished.
  +     * Therefore we need to postpone propogating the EOS bucket, up
  +     * until the filter handler is returned and only then send the EOS
  +     * bucket if the stream had one.
  +     */
  +    if (filter->seen_eos) {
  +        filter->eos = 1;
  +        filter->seen_eos = 0;
  +    }
  +
       if (filter->mode == MP_OUTPUT_FILTER_MODE) {
           modperl_output_filter_flush(filter);
       }
  @@ -213,7 +224,8 @@
           return 1;
       }
       else if (MP_FILTER_IS_EOS(filter)) {
  -        filter->eos = 1;
  +        MP_TRACE_f(MP_FUNC, "received EOS bucket\n");
  +        filter->seen_eos = 1;
           return 1;
       }
       else if (filter->bucket != MP_FILTER_SENTINEL(filter)) {
  @@ -281,7 +293,7 @@
   
           if (MP_FILTER_IS_EOS(filter)) {
               MP_TRACE_f(MP_FUNC, "received EOS bucket\n");
  -            filter->eos = 1;
  +            filter->seen_eos = 1;
               break;
           }
           else if (MP_FILTER_IS_FLUSH(filter)) {
  
  
  
  1.63      +1 -0      modperl-2.0/src/modules/perl/modperl_types.h
  
  Index: modperl_types.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_types.h,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- modperl_types.h	15 Sep 2002 23:30:06 -0000	1.62
  +++ modperl_types.h	25 Nov 2002 22:46:29 -0000	1.63
  @@ -184,6 +184,7 @@
   } modperl_filter_mode_e;
   
   typedef struct {
  +    int seen_eos;
       int eos;
       int flush;
       ap_filter_t *f;
  
  
  
  1.4       +16 -5     modperl-2.0/t/filter/TestFilter/reverse.pm
  
  Index: reverse.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/reverse.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- reverse.pm	11 Apr 2002 11:08:43 -0000	1.3
  +++ reverse.pm	25 Nov 2002 22:46:29 -0000	1.4
  @@ -7,7 +7,7 @@
   use Apache::RequestIO ();
   use Apache::Filter ();
   
  -use Apache::Const -compile => 'OK';
  +use Apache::Const -compile => qw(OK M_POST);
   
   sub handler {
       my $filter = shift;
  @@ -18,21 +18,32 @@
               $filter->print("\n");
           }
       }
  +    $filter->print("Reversed by mod_perl 2.0\n");
   
  -    0;
  +    return Apache::OK;
   }
   
   sub response {
       my $r = shift;
   
       $r->content_type('text/plain');
  -    $r->puts(scalar reverse "1..1\n");
  -    $r->puts(scalar reverse "ok 1\n");
   
  -    Apache::OK;
  +    if ($r->method_number == Apache::M_POST) {
  +        my $data = ModPerl::Test::read_post($r);
  +        $r->puts($data);
  +    }
  +
  +    return Apache::OK;
   }
   
   1;
   __DATA__
  +<Base>
  +    <LocationMatch "/filter/reverse.txt">
  +        PerlOutputFilterHandler TestFilter::reverse
  +    </LocationMatch>
  +</Base>
  +
   SetHandler modperl
   PerlResponseHandler TestFilter::reverse::response
  +
  
  
  
  1.63      +3 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- Changes	25 Nov 2002 01:31:00 -0000	1.62
  +++ Changes	25 Nov 2002 22:46:29 -0000	1.63
  @@ -10,6 +10,9 @@
   
   =item 1.99_08-dev
   
  +Allow output streaming filters to append data to the end of the stream
  +[Stas Bekman]
  +
   fixes to compile with ActivePerl 5.8 beta
   [Randy Kobes <ra...@theoryx5.uwinnipeg.ca>]