Hello,

I am currently developing a modperl filter that uses the streaming
approach. I started off with the example in

http://perl.apache.org/docs/2.0/user/handlers/filters.html#Stream_oriented_Output_Filter

  sub handler {
      my $filter = shift;

      my $left_over = '';
      while ($filter->read(my $buffer, BUFF_LEN)) {
          $buffer = $left_over . $buffer;
          $left_over = '';
          while ($buffer =~ /([^\r\n]*)([\r\n]*)/g) {
              $left_over = $1, last unless $2;
              $filter->print(scalar(reverse $1), $2);
          }
      }
      $filter->print(scalar reverse $left_over) if length $left_over;

      Apache::OK;
  }

This seems to work OK when the file is small (smaller than 8192). When
the file is larger, then there is a line that gets cut. This is
because the handler gets called more than once for big requests. Is
there a nice way to overcome this problem?  I was thinking using
filter context to store variable $left_over, but then I dont know how
to detect the "real" end of the stream.

Thanks in advance

                           E             s          t      e    b  a n!


:wq


Reply via email to