httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: httpd-2.0/modules/echo mod_echo.c
Date Wed, 06 Jun 2001 21:28:22 GMT
rbb         01/06/06 14:28:21

  Modified:    .        CHANGES
               modules/echo mod_echo.c
  Log:
  Make mod_echo use filters for all communication with clients.
  Submitted by:	Ryan Morgan <rmorgan@covalent.net>
  
  Revision  Changes    Path
  1.215     +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.214
  retrieving revision 1.215
  diff -u -d -b -w -u -r1.214 -r1.215
  --- CHANGES	2001/06/05 21:44:44	1.214
  +++ CHANGES	2001/06/06 21:28:17	1.215
  @@ -1,4 +1,8 @@
   Changes with Apache 2.0.19-dev
  +
  +  *) Modify mod_echo to make it use filters for input and output.
  +     [Ryan Morgan <rmorgan@covalent.net>]
  +
     *) Extend mod_headers to support conditional driven Header 
        add, append and set. Use SetEnvIf to set an envar and conditionally
        add/append/set headers based on this envar thusly:
  
  
  
  1.33      +18 -10    httpd-2.0/modules/echo/mod_echo.c
  
  Index: mod_echo.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/echo/mod_echo.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -d -b -w -u -r1.32 -r1.33
  --- mod_echo.c	2001/02/16 04:26:36	1.32
  +++ mod_echo.c	2001/06/06 21:28:20	1.33
  @@ -62,6 +62,8 @@
   #include "http_config.h"
   #include "http_connection.h"
   
  +#include "apr_buckets.h"
  +#include "util_filter.h"
   AP_DECLARE_DATA module echo_module;
   
   typedef struct {
  @@ -88,7 +90,10 @@
   
   static int process_echo_connection(conn_rec *c)
   {
  -    char buf[1024];
  +    apr_bucket_brigade *bb;
  +    apr_bucket *b;
  +    apr_status_t rv;
  +    int zero = 0;
       EchoConfig *pConfig = ap_get_module_config(c->base_server->module_config,
                                                  &echo_module);
   
  @@ -96,18 +101,21 @@
           return DECLINED;
       }
   
  +    bb = apr_brigade_create(c->pool);
  +
       for ( ; ; ) {
  -	apr_ssize_t r, w;
  -        r = sizeof(buf);
  -        apr_recv(c->client_socket, buf, &r);
  -	if (r <= 0) {
  -            break;
  -        }
  -        w = r;
  -	apr_send(c->client_socket, buf, &w);
  -	if (w != r) {
  +        /* Get a single line of input from the client */
  +        if ((rv = ap_get_brigade(c->input_filters, bb,
  +                                 AP_MODE_BLOCKING, &zero) != APR_SUCCESS || 
  +             APR_BRIGADE_EMPTY(bb))) {
  +            apr_brigade_destroy(bb);
   	    break;
           }
  +
  +        /* Make sure the data is flushed to the client */
  +        b = apr_bucket_flush_create();
  +        APR_BRIGADE_INSERT_TAIL(bb, b);
  +        ap_pass_brigade(c->output_filters, bb);    
       }
       return OK;
   }
  
  
  

Mime
View raw message