httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: httpd-2.0/server protocol.c
Date Sat, 29 Sep 2001 08:48:59 GMT
jerenkrantz    01/09/29 01:48:59

  Modified:    modules/http http_core.c http_protocol.c
               server   protocol.c
  Log:
  Remove the lameo create_req hack and delay the addition of the HTTP_IN
  filter until after we have read the headers.  This eliminates the status
  hack that was in http_protocol.c and makes it all around better.
  
  server/protocol.c now directly adds HTTP_IN filter - should we create a
  specific hook for this?  (Could we do this as a post_read_request hook?)
  I'm not terribly sure, but let's move it down to the lowest possible
  place in ap_read_request.  We can change this detail later as we see fit.
  
  Revision  Changes    Path
  1.284     +0 -11     httpd-2.0/modules/http/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_core.c,v
  retrieving revision 1.283
  retrieving revision 1.284
  diff -u -r1.283 -r1.284
  --- http_core.c	2001/09/29 08:17:11	1.283
  +++ http_core.c	2001/09/29 08:48:58	1.284
  @@ -301,15 +301,6 @@
       return OK;
   }
   
  -static int ap_http_create_req(request_rec *r)
  -{
  -    if (!r->main)
  -    {
  -        ap_add_input_filter("HTTP_IN", NULL, r, r->connection);
  -    }
  -    return OK;
  -}
  -
   static void ap_http_insert_filter(request_rec *r)
   {
       if (!r->main) {
  @@ -328,8 +319,6 @@
       ap_hook_map_to_storage(ap_send_http_trace,NULL,NULL,APR_HOOK_MIDDLE);
       ap_hook_http_method(http_method,NULL,NULL,APR_HOOK_REALLY_LAST);
       ap_hook_default_port(http_port,NULL,NULL,APR_HOOK_REALLY_LAST);
  -    ap_hook_create_request(ap_http_create_req, NULL, NULL, APR_HOOK_MIDDLE);
  -
       ap_hook_insert_filter(ap_http_insert_filter, NULL, NULL, APR_HOOK_REALLY_LAST);
       ap_register_input_filter("HTTP_IN", ap_http_filter, AP_FTYPE_CONNECTION);
       ap_register_output_filter("HTTP_HEADER", ap_http_header_filter, 
  
  
  
  1.365     +24 -36    httpd-2.0/modules/http/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
  retrieving revision 1.364
  retrieving revision 1.365
  diff -u -r1.364 -r1.365
  --- http_protocol.c	2001/09/29 08:29:18	1.364
  +++ http_protocol.c	2001/09/29 08:48:58	1.365
  @@ -484,7 +484,6 @@
   static long get_chunk_size(char *);
   
   typedef struct http_filter_ctx {
  -    int status;
       apr_size_t remaining;
       enum {
           BODY_NONE,
  @@ -493,8 +492,9 @@
       } state;
   } http_ctx_t;
   
  -/* Hi, I'm the main input filter for HTTP requests. 
  - * I handle chunked and content-length bodies. */
  +/* This is the input filter for HTTP requests.  It handles chunked and 
  + * content-length bodies.  This can only be inserted/used after the headers
  + * are successfully parsed. */
   apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode,
apr_off_t *readbytes)
   {
       apr_bucket *e;
  @@ -502,45 +502,32 @@
       apr_status_t rv;
   
       if (!ctx) {
  -        f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx));
  -        ctx->status = f->r->status;
  -    }
  +        const char *tenc, *lenp;
  +        f->ctx = ctx = apr_palloc(f->r->pool, sizeof(*ctx));
  +        ctx->state = BODY_NONE;
   
  -    /* Basically, we have to stay out of the way until server/protocol.c
  -     * says it is okay - which it does by setting r->status to OK. */
  -    if (f->r->status != ctx->status)
  -    {
  -        int old_status;
  -        /* Allow us to be reentrant! */
  -        old_status = ctx->status;
  -        ctx->status = f->r->status;
  +        tenc = apr_table_get(f->r->headers_in, "Transfer-Encoding");
  +        lenp = apr_table_get(f->r->headers_in, "Content-Length");
   
  -        if (old_status == HTTP_REQUEST_TIME_OUT && f->r->status == HTTP_OK)
  -        {
  -            const char *tenc, *lenp;
  -            tenc = apr_table_get(f->r->headers_in, "Transfer-Encoding");
  -            lenp = apr_table_get(f->r->headers_in, "Content-Length");
  -
  -            if (tenc) {
  -                if (!strcasecmp(tenc, "chunked")) {
  -                    char line[30];
  +        if (tenc) {
  +            if (!strcasecmp(tenc, "chunked")) {
  +                char line[30];
               
  -                    if ((rv = ap_getline(line, sizeof(line), f->r, 0)) < 0) {
  -                        return rv;
  -                    }
  -                    ctx->state = BODY_CHUNK;
  -                    ctx->remaining = get_chunk_size(line);
  +                if ((rv = ap_getline(line, sizeof(line), f->r, 0)) < 0) {
  +                    return rv;
                   }
  +                ctx->state = BODY_CHUNK;
  +                ctx->remaining = get_chunk_size(line);
               }
  -            else if (lenp) {
  -                const char *pos = lenp;
  +        }
  +        else if (lenp) {
  +            const char *pos = lenp;
   
  -                while (apr_isdigit(*pos) || apr_isspace(*pos))
  -                    ++pos;
  -                if (*pos == '\0') {
  -                    ctx->state = BODY_LENGTH;
  -                    ctx->remaining = atol(lenp);
  -                }
  +            while (apr_isdigit(*pos) || apr_isspace(*pos))
  +                ++pos;
  +            if (*pos == '\0') {
  +                ctx->state = BODY_LENGTH;
  +                ctx->remaining = atol(lenp);
               }
           }
       }
  @@ -575,6 +562,7 @@
   
                   if (!ctx->remaining)
                   {
  +                    /* Handle trailers by calling get_mime_headers again! */
                       e = apr_bucket_eos_create();
                       APR_BRIGADE_INSERT_TAIL(b, e);
                       return APR_SUCCESS;
  
  
  
  1.47      +2 -0      httpd-2.0/server/protocol.c
  
  Index: protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- protocol.c	2001/09/29 08:17:11	1.46
  +++ protocol.c	2001/09/29 08:48:59	1.47
  @@ -676,6 +676,8 @@
           }
       }
   
  +    ap_add_input_filter("HTTP_IN", NULL, r, r->connection);
  +
       if ((access_status = ap_run_post_read_request(r))) {
           ap_die(access_status, r);
           ap_run_log_transaction(r);
  
  
  

Mime
View raw message