perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0/t/protocol/TestProtocol echo_filter.pm
Date Thu, 03 Jun 2004 08:20:13 GMT
stas        2004/06/03 01:20:13

  Modified:    t/protocol echo_filter.t
               t/protocol/TestProtocol echo_filter.pm
  Log:
  adjust the test to actually do what the name suggests: filtering in
  protocol handlers
  
  Revision  Changes    Path
  1.4       +1 -1      modperl-2.0/t/protocol/echo_filter.t
  
  Index: echo_filter.t
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/protocol/echo_filter.t,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- echo_filter.t	25 Mar 2004 20:51:15 -0000	1.3
  +++ echo_filter.t	3 Jun 2004 08:20:13 -0000	1.4
  @@ -16,5 +16,5 @@
   for (@test_strings) {
       print $socket "$_\n";
       chomp(my $reply = <$socket>||'');
  -    ok t_cmp($_, $reply);
  +    ok t_cmp(uc($_), $reply);
   }
  
  
  
  1.14      +29 -13    modperl-2.0/t/protocol/TestProtocol/echo_filter.pm
  
  Index: echo_filter.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/protocol/TestProtocol/echo_filter.pm,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -u -r1.13 -r1.14
  --- echo_filter.pm	1 Jun 2004 23:36:47 -0000	1.13
  +++ echo_filter.pm	3 Jun 2004 08:20:13 -0000	1.14
  @@ -1,34 +1,46 @@
   package TestProtocol::echo_filter;
   
  +# see also TestFilter::both_str_con_add
  +
   use strict;
   use warnings FATAL => 'all';
   
   use Apache::Connection ();
  +use APR::Socket ();
   use APR::Bucket ();
   use APR::Brigade ();
  -use APR::Util ();
   use APR::Error ();
  -use Apache::Filter ();
   
  -use APR::Const    -compile => qw(SUCCESS EOF);
  +use base qw(Apache::Filter);
  +
  +use APR::Const    -compile => qw(SUCCESS EOF SO_NONBLOCK);
   use Apache::Const -compile => qw(OK MODE_GETLINE);
   
  +use constant BUFF_LEN => 1024;
  +
  +sub uc_filter : FilterConnectionHandler {
  +    my $filter = shift;
  +
  +    while ($filter->read(my $buffer, BUFF_LEN)) {
  +        $filter->print(uc $buffer);
  +    }
  +
  +    return Apache::OK;
  +}
  +
   sub handler {
  -    my Apache::Connection $c = shift;
  +    my $c = shift;
   
  -    # XXX: workaround to a problem on some platforms (solaris, bsd,
  -    # etc), where Apache 2.0.49+ forgets to set the blocking mode on
  -    # the socket
  -    require APR::Socket;
  -    BEGIN { use APR::Const -compile => qw(SO_NONBLOCK); }
  +    # starting from Apache 2.0.49 several platforms require you to set
  +    # the socket to a blocking IO mode
       $c->client_socket->opt_set(APR::SO_NONBLOCK => 0);
   
       my $bb = APR::Brigade->new($c->pool, $c->bucket_alloc);
   
  -    for (;;) {
  -        my $rv = $c->input_filters->get_brigade($bb, Apache::MODE_GETLINE);
  -        if ($rv != APR::SUCCESS && $rv != APR::EOF) {
  -            my $error = APR::Error::strerror($rv);
  +    while (1) {
  +        my $rc = $c->input_filters->get_brigade($bb, Apache::MODE_GETLINE);
  +        if ($rc != APR::SUCCESS && $rc != APR::EOF) {
  +            my $error = APR::Error::strerror($rc);
               warn __PACKAGE__ . ": get_brigade: $error\n";
               last;
           }
  @@ -49,3 +61,7 @@
   }
   
   1;
  +__END__
  +PerlModule              TestProtocol::echo_filter
  +PerlOutputFilterHandler TestProtocol::echo_filter::uc_filter
  +
  
  
  

Mime
View raw message