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
Date Wed, 11 Oct 2000 18:32:24 GMT
rbb         00/10/11 11:32:21

  Modified:    src      CHANGES
               src/main http_core.c http_protocol.c
  Log:
  Cleanup the input filtering a bit.  This does not work with telnet
  currently, but it is a step in the right direction.  Input filtering
  should be slowly improving from here on out.
  Submitted by:	Greg Ames, Ryan Bloom, Jeff Trawick
  
  Revision  Changes    Path
  1.268     +7 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.267
  retrieving revision 1.268
  diff -u -r1.267 -r1.268
  --- CHANGES	2000/10/10 04:11:35	1.267
  +++ CHANGES	2000/10/11 18:32:15	1.268
  @@ -1,4 +1,11 @@
   Changes with Apache 2.0a8
  +  *) 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,
  +     and http_filter returns a line at a time.  If it is not 0, then we are
  +     in body, and http_filter returns raw data, but only up to c->remaining
  +     bytes.  It can return less, but never more.
  +     [Greg Ames, Ryan Bloom, Jeff Trawick]
   
     *) mod_cgi: Write all of the request body to the child, not just what
        the kernel would accept on the first write.  [Jeff Trawick]
  
  
  
  1.161     +3 -25     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.160
  retrieving revision 1.161
  diff -u -r1.160 -r1.161
  --- http_core.c	2000/10/10 03:35:11	1.160
  +++ http_core.c	2000/10/11 18:32:17	1.161
  @@ -3305,37 +3305,15 @@
   
   static int core_input_filter(ap_filter_t *f, ap_bucket_brigade *b)
   {
  -    char *buff;
  -    apr_ssize_t length = HUGE_STRING_LEN;
       apr_socket_t *csock = NULL;
  -    apr_status_t rv;
       ap_bucket *e;
   
  -    /* As soon as we have pool buckets, this should become a palloc. */
  -    buff = apr_palloc(f->c->pool, HUGE_STRING_LEN);
       ap_bpop_socket(&csock, f->c->client);
  -
  -    rv = apr_recv(csock, buff, &length);
  -    if (rv == APR_SUCCESS) {
  -        if (length > 0) {
  -            /* This should probably be a pool bucket, but using a transient is 
  -             * actually okay here too.  We know the pool we are using will always 
  -             * be available as long as the connection is open.
  -             */
  -            e = ap_bucket_create_transient(buff, length);
  -            AP_BRIGADE_INSERT_TAIL(b, e);
  -        }
  -        else {
  -            /* XXX need to trigger EOS/EOF processing;
  -             * for now, return empty brigade because that is what
  -             * getline() looks for */
  -        }
  -    }
  -    else {
  -        return rv;
  -    }
  +    e = ap_bucket_create_socket(csock);
  +    AP_BRIGADE_INSERT_TAIL(b, e);
       return APR_SUCCESS;
   }
  +
   /* Default filter.  This filter should almost always be used.  Its only job
    * is to send the headers if they haven't already been sent, and then send
    * the actual data.
  
  
  
  1.157     +23 -23    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.156
  retrieving revision 1.157
  diff -u -r1.156 -r1.157
  --- http_protocol.c	2000/10/11 17:37:22	1.156
  +++ http_protocol.c	2000/10/11 18:32:19	1.157
  @@ -868,7 +868,6 @@
       char *buff;
       apr_ssize_t length;
       char *pos;
  -    int state = 0;
       http_ctx_t *ctx = f->ctx;
       ap_bucket_brigade *bb;
       apr_status_t rv;
  @@ -921,30 +920,19 @@
               return rv;
           }
   
  -        pos = buff + 1;
  +        pos = buff;
           while (pos < buff + length) {
  -
  -            /* We are at the start of one line, but it actually has data. */
  -            if ((*pos != ASCII_LF) && (*pos != ASCII_CR)) {
  -                state = 0;
  -            }
  -            else {
  -                if (*pos == ASCII_LF) {
  -                    state++;
  +            if (*pos == ASCII_LF) {
  +                if (*(pos - 1) == ASCII_CR) {
  +                    *(pos - 1) = ASCII_LF;
  +                    *pos = '\0';
                   }
  -            }
  -            
  -            if ((*pos == ASCII_LF) && (*(pos - 1) == ASCII_CR)) {
  -                *(pos - 1) = ASCII_LF;
  -                *pos = '\0';
  -            }
  -            pos++;
  -            if (state == 2) {
  -                e->split(e, pos - buff);
  +                e->split(e, pos - buff + (*pos == '\0'));
                   bb = ap_brigade_split(b, AP_BUCKET_NEXT(e));
                   ctx->b = bb;
                   return APR_SUCCESS;
               }
  +            pos++;
           }
       }
       return APR_SUCCESS;
  @@ -1003,8 +991,8 @@
       if (AP_BRIGADE_EMPTY(b)) {
           return -1;
       }
  -    e = AP_BRIGADE_FIRST(b); 
       while (1) {
  +        e = AP_BRIGADE_FIRST(b); 
           while (e->length == 0) {
               AP_BUCKET_REMOVE(e);
               ap_bucket_destroy(e);
  @@ -1028,13 +1016,25 @@
   	/* check for line end using ascii encoding, even on an ebcdic box
   	 * since this is raw protocol data fresh from the network
   	 */
  +/*XXX This needs to be scrubbed, but Greg Ames is going to do a lot to this
  +  *   code in a little while.  When he is done, it shouldn't need scrubbing
  +  *   any more.
  +  *
  +  *   GREG, this is where the breakage is!!!!
  +  */
           if ((toss = ap_strchr_c(temp, ASCII_LF)) != NULL) { 
  -            length = toss - temp + 1;
  -            e->split(e, length + (temp[length] == '\0'));
  +            length = (toss - temp) + (pos - s) + 1;
  +            e->split(e, length + (temp[length] == '\0')); 
  +            apr_cpystrn(pos, temp, length + 1);
  +            AP_BUCKET_REMOVE(e);
  +            ap_bucket_destroy(e);
  +        }
  +        else {
               apr_cpystrn(pos, temp, length + 1);
  -	    
  +            pos += length;
               AP_BUCKET_REMOVE(e);
               ap_bucket_destroy(e);
  +            continue;
           }
           c->input_data = b;
           e = AP_BRIGADE_FIRST(b); 
  
  
  

Mime
View raw message