httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_core.c http_protocol.c util_filter.c
Date Thu, 12 Oct 2000 16:35:41 GMT
rbb         00/10/12 09:35:40

  Modified:    src      CHANGES
               src/include http_protocol.h httpd.h util_filter.h
               src/main http_core.c http_protocol.c util_filter.c
  Log:
  Implement a length argument on input filters.  There are three possible
  values for the length, -1, 0, and a positive number.  -1 means that the
  next filter should return all the data it has, the current filter will
  take care to ensure that the protocol is followed.  Most filters will
  never use this, because it implies they are implementing a conn_based
  input filter.  0 means give me exactly one line of data.  A positive
  number means give me a maximum of n bytes.
  
  Revision  Changes    Path
  1.269     +12 -0     apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.268
  retrieving revision 1.269
  diff -u -r1.268 -r1.269
  --- CHANGES	2000/10/11 18:32:15	1.268
  +++ CHANGES	2000/10/12 16:35:36	1.269
  @@ -1,4 +1,16 @@
   Changes with Apache 2.0a8
  +  *) Input filtering now has a third argument.  This is the amount of data
  +     to read from lower filters.  This argument can be -1, 0, or a positive
  +     number.  -1 means give me all the data you have, I'll deal with it and
  +     let you know if I need more.  0 means give me one line and one line
  +     only.  A positive number means I want no more than this much data.
  +
  +     Currently, only 0 and a positive number are implemented.  This allows
  +     us to remove the remaining field from the conn_rec structure, which
  +     has also been done.
  +     [Ryan Bloom] 
  +    
  +
     *) Big cleanup of the input filtering.  The goal is that http_filter
        understands two conditions, headers and body.  It knows where it is
        based on c->remaining.  If c->remaining is 0, then we are in headers,
  
  
  
  1.28      +1 -1      apache-2.0/src/include/http_protocol.h
  
  Index: http_protocol.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/http_protocol.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- http_protocol.h	2000/10/08 00:55:46	1.27
  +++ http_protocol.h	2000/10/12 16:35:37	1.28
  @@ -529,7 +529,7 @@
    */
   API_EXPORT(const char *) ap_method_name_of(int methnum);
   
  -int http_filter(ap_filter_t *f, ap_bucket_brigade *b);
  +int http_filter(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t length);
   
     /* Hooks */
     /*
  
  
  
  1.99      +0 -2      apache-2.0/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- httpd.h	2000/10/12 04:47:21	1.98
  +++ httpd.h	2000/10/12 16:35:38	1.99
  @@ -906,8 +906,6 @@
       /** A list of output filters to be used for this connection
        *  @defvar ap_filter_t *filters */
       struct ap_filter_t *output_filters;
  -    /** bytes left to read in the current request body */
  -    long remaining;
   };
   
   /* Per-vhost config... */
  
  
  
  1.25      +27 -7     apache-2.0/src/include/util_filter.h
  
  Index: util_filter.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/util_filter.h,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- util_filter.h	2000/10/09 17:39:10	1.24
  +++ util_filter.h	2000/10/12 16:35:38	1.25
  @@ -74,6 +74,12 @@
   #define AP_NOBODY_WROTE         -1
   #define AP_NOBODY_READ          -2
   
  +/* Input filtering macros */
  +#define AP_GET_LINE                0  /* Get one line from the next filter */
  +#define AP_GET_ANY_AMOUNT         -1  /* Get as much data as the next filter
  +                                       * is willing to give up.
  +                                       */
  +
   /*
    * FILTER CHAIN
    *
  @@ -125,7 +131,12 @@
    *
    * The return value of a filter should be an APR status value.
    */
  -typedef apr_status_t (*ap_filter_func)(ap_filter_t *f, ap_bucket_brigade *b);
  +typedef apr_status_t (*ap_out_filter_func)(ap_filter_t *f, ap_bucket_brigade *b);
  +typedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t
length);
  +typedef union ap_filter_func {
  +    ap_out_filter_func out_func;
  +    ap_in_filter_func in_func;
  +} ap_filter_func;
   
   /*
    * ap_filter_type:
  @@ -232,10 +243,19 @@
    * filter doesn't write to the network, then AP_NOBODY_READ is returned.
    * @param filter The next filter in the chain
    * @param bucket The current bucket brigade
  + * @param length The maximum amount of data to be returned from the next
  + *               lowest filter.  If filter a requests 15 bytes
  + *               from the filter b, that doesn't stop the b
  + *               from requesting 30 bytes from filter c.  It just
  + *               stops b from returning more that 15 bytes to a.  The other
  + *               15 must be stored by b.  A value of AP_GET_LINE (0) tells 
  + *               the filter to only ever return a single line.  A value of
  + *               AP_GET_ANY_AMOUNT (-1) tells a filter to return everything
  + *               it has.
    * @return apr_status_t value
  - * @deffunc apr_status_t ap_get_brigade(ap_filter_t *filter, ap_bucket_brigade *bucket)
  + * @deffunc apr_status_t ap_get_brigade(ap_filter_t *filter, ap_bucket_brigade *bucket,
int length)
    */
  -API_EXPORT(apr_status_t) ap_get_brigade(ap_filter_t *filter, ap_bucket_brigade *bucket);
  +API_EXPORT(apr_status_t) ap_get_brigade(ap_filter_t *filter, ap_bucket_brigade *bucket,
int length);
   
   /**
    * Pass the current bucket brigade down to the next filter on the filter
  @@ -264,10 +284,10 @@
    * @param name The name to attach to the filter function
    * @param filter_func The filter function to name
    * @param The type of filter function, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION
  - * @deffunc void ap_register_input_filter(const char *name, ap_filter_func filter_func,
ap_filter_type ftype)
  + * @deffunc void ap_register_input_filter(const char *name, ap_in_filter_func filter_func,
ap_filter_type ftype)
    */
   API_EXPORT(void) ap_register_input_filter(const char *name,
  -                                          ap_filter_func filter_func,
  +                                          ap_in_filter_func filter_func,
                                             ap_filter_type ftype);
   /*
    * ap_register_output_filter():
  @@ -285,10 +305,10 @@
    * @param name The name to attach to the filter function
    * @param filter_func The filter function to name
    * @param The type of filter function, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION
  - * @deffunc void ap_register_output_filter(const char *name, ap_filter_func filter_func,
ap_filter_type ftype)
  + * @deffunc void ap_register_output_filter(const char *name, ap_out_filter_func filter_func,
ap_filter_type ftype)
    */
   API_EXPORT(void) ap_register_output_filter(const char *name,
  -                                           ap_filter_func filter_func,
  +                                           ap_out_filter_func filter_func,
                                              ap_filter_type ftype);
   
   /*
  
  
  
  1.164     +6 -1      apache-2.0/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
  retrieving revision 1.163
  retrieving revision 1.164
  diff -u -r1.163 -r1.164
  --- http_core.c	2000/10/12 03:17:36	1.163
  +++ http_core.c	2000/10/12 16:35:39	1.164
  @@ -3303,7 +3303,12 @@
       return APR_SUCCESS;
   }
   
  -static int core_input_filter(ap_filter_t *f, ap_bucket_brigade *b)
  +/* This function only understands a length of AP_GET_ANY_AMOUNT.  It will
  + * ignore length values and always return the entire brigade.  This is
  + * pretty safe to do, because we know there always needs to be an intervening
  + * filter just above this that will only make requests for AP_GET_ANY_AMOUNT
  + */
  +static int core_input_filter(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t length)
   {
       apr_socket_t *csock = NULL;
       ap_bucket *e;
  
  
  
  1.164     +10 -14    apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.163
  retrieving revision 1.164
  diff -u -r1.163 -r1.164
  --- http_protocol.c	2000/10/12 05:40:46	1.163
  +++ http_protocol.c	2000/10/12 16:35:39	1.164
  @@ -860,13 +860,13 @@
       ap_bucket_brigade *b;
   } http_ctx_t;
   
  -apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b)
  +apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t length)
   {
   #define ASCII_CR '\015'
   #define ASCII_LF '\012'
       ap_bucket *e;
       char *buff;
  -    apr_ssize_t length;
  +    apr_ssize_t len;
       char *pos;
       http_ctx_t *ctx = f->ctx;
       ap_bucket_brigade *bb;
  @@ -874,7 +874,7 @@
   
       if (!ctx) {
           f->ctx = ctx = apr_pcalloc(f->c->pool, sizeof(*ctx));
  -        if ((rv = ap_get_brigade(f->next, b)) != APR_SUCCESS) {
  +        if ((rv = ap_get_brigade(f->next, b, AP_GET_ANY_AMOUNT)) != APR_SUCCESS) {
               return rv;
           }
       }
  @@ -884,14 +884,14 @@
               ctx->b = NULL; /* XXX we just leaked a brigade structure */
           }
           else {
  -            if ((rv = ap_get_brigade(f->next, b)) != APR_SUCCESS) {
  +            if ((rv = ap_get_brigade(f->next, b, AP_GET_LINE)) != APR_SUCCESS) {
                   return rv;
               }
           }
       }
   
  -    if (f->c->remaining > 0) {
  -        int remain = f->c->remaining;
  +    if (length > 0) {
  +        int remain = length;
           e = AP_BRIGADE_FIRST(b);
           while (remain > e->length && e != AP_BRIGADE_SENTINEL(b)) {
               remain -= e->length;
  @@ -903,24 +903,22 @@
                   remain = 0;
               }
               bb = ap_brigade_split(b, AP_BUCKET_NEXT(e));
  -            f->c->remaining = remain;
               ctx->b = bb;
               return APR_SUCCESS;
           }
           else {
  -            f->c->remaining = remain;
               ctx->b = NULL;
               return APR_SUCCESS;
           }
       }
   
       AP_BRIGADE_FOREACH(e, b) {
  -        if ((rv = e->read(e, (const char **)&buff, &length, 0)) != APR_SUCCESS)
{
  +        if ((rv = e->read(e, (const char **)&buff, &len, 0)) != APR_SUCCESS)
{
               return rv;
           }
   
           pos = buff;
  -        while (pos < buff + length) {
  +        while (pos < buff + len) {
               if (*pos == ASCII_LF) {
                   e->split(e, pos - buff + 1);
                   bb = ap_brigade_split(b, AP_BUCKET_NEXT(e));
  @@ -960,7 +958,7 @@
   
       while (1) {
           if (AP_BRIGADE_EMPTY(b)) {
  -            if (ap_get_brigade(c->input_filters, b) != APR_SUCCESS) {
  +            if (ap_get_brigade(c->input_filters, b, AP_GET_LINE) != APR_SUCCESS) {
                   return -1;
               }
           }
  @@ -2286,7 +2284,6 @@
           }
   
           r->remaining = atol(lenp);
  -        r->connection->remaining = r->remaining;
       }
   
       if ((r->read_body == REQUEST_NO_BODY) &&
  @@ -2407,8 +2404,7 @@
               if (AP_BRIGADE_EMPTY(bb)) {
                   apr_getsocketopt(r->connection->client->bsock, APR_SO_TIMEOUT,
&timeout);
                   apr_setsocketopt(r->connection->client->bsock, APR_SO_TIMEOUT,
0);
  -                r->connection->remaining = len_to_read;
  -                if (ap_get_brigade(r->input_filters, bb) != APR_SUCCESS) {
  +                if (ap_get_brigade(r->input_filters, bb, len_to_read) != APR_SUCCESS)
{
                       /* if we actually fail here, we want to just return and
                        * stop trying to read data from the client.
                        */
  
  
  
  1.28      +12 -7     apache-2.0/src/main/util_filter.c
  
  Index: util_filter.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util_filter.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- util_filter.c	2000/10/05 16:55:10	1.27
  +++ util_filter.c	2000/10/12 16:35:39	1.28
  @@ -103,18 +103,22 @@
   }
   
   API_EXPORT(void) ap_register_input_filter(const char *name,
  -                                          ap_filter_func filter_func,
  +                                          ap_in_filter_func filter_func,
                                             ap_filter_type ftype)
   {
  -    register_filter(name, filter_func, ftype, 
  +    ap_filter_func f;
  +    f.in_func = filter_func;
  +    register_filter(name, f, ftype, 
                       &registered_input_filters);
   }                                                                    
   
   API_EXPORT(void) ap_register_output_filter(const char *name,
  -                                           ap_filter_func filter_func,
  +                                           ap_out_filter_func filter_func,
                                              ap_filter_type ftype)
   {
  -    register_filter(name, filter_func, ftype, 
  +    ap_filter_func f;
  +    f.out_func = filter_func;
  +    register_filter(name, f, ftype, 
                       &registered_output_filters);
   }
   
  @@ -191,10 +195,11 @@
    * save data off to the side should probably create their own temporary
    * brigade especially for that use.
    */
  -API_EXPORT(apr_status_t) ap_get_brigade(ap_filter_t *next, ap_bucket_brigade *bb)
  +API_EXPORT(apr_status_t) ap_get_brigade(ap_filter_t *next, 
  +                                        ap_bucket_brigade *bb, int length)
   {
       if (next) {
  -        return next->frec->filter_func(next, bb);
  +        return next->frec->filter_func.in_func(next, bb, length);
       }
       return AP_NOBODY_READ;
   }
  @@ -210,7 +215,7 @@
           if (AP_BRIGADE_LAST(bb)->type == AP_BUCKET_EOS && next->r) {
               next->r->eos_sent = 1;
           }
  -        return next->frec->filter_func(next, bb);
  +        return next->frec->filter_func.out_func(next, bb);
       }
       return AP_NOBODY_WROTE;
   }
  
  
  

Mime
View raw message