httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: httpd-2.0/modules/http http_protocol.c
Date Sun, 17 Dec 2000 18:04:14 GMT
rbb         00/12/17 10:04:14

  Modified:    .        CHANGES
               modules/http http_protocol.c
  Log:
  Get byterange requests working with data that is generated by a handler
  that does not add a content-length.  For example, mod_autoindex doesn't
  set a content-length, but the byterange filter requires one.  We fix this
  by computing the content-length in the byterange filter.
  
  Revision  Changes    Path
  1.8       +5 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CHANGES	2000/12/15 15:02:34	1.7
  +++ CHANGES	2000/12/17 18:04:13	1.8
  @@ -1,4 +1,9 @@
   Changes with Apache 2.0b1
  +  *) Get byterange requests working with responses that do not have a
  +     content-length.  Because of the way byterange requests work, we have to
  +     have all of the data before we can actually do the byterange, so we
  +     can compute the content-length in the byterange filter.
  +     [Ryan Bloom]
   
     *) Get exe CGI's working again on Windows.
        [Allan Edwards]
  
  
  
  1.256     +19 -4     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.255
  retrieving revision 1.256
  diff -u -r1.255 -r1.256
  --- http_protocol.c	2000/12/08 01:26:31	1.255
  +++ http_protocol.c	2000/12/17 18:04:14	1.256
  @@ -223,6 +223,7 @@
       apr_off_t range_end;
       char *current;
       const char *bound_head;
  +    int clength = 0;
   
       if (!ctx) {
           int num_ranges = ap_set_byterange(r);
  @@ -267,11 +268,26 @@
       bb = ctx->bb;
       ctx->bb = NULL;     /* ### strictly necessary? call brigade_destroy? */
   
  +    /* It is possible that we won't have a content length yet, so we have to
  +     * compute the length before we can actually do the byterange work.
  +     */
  +    AP_BRIGADE_FOREACH(e, bb) {
  +        const char *ignore;
  +        apr_size_t len;
  +
  +        if (e->length >= 0) {
  +            clength += e->length;
  +            continue;
  +        }
  +        ap_bucket_read(e, &ignore, &len, AP_NONBLOCK_READ);
  +        clength += e->length;
  +    }
  +
       /* this brigade holds what we will be sending */
       bsend = ap_brigade_create(r->pool);
   
       while ((current = ap_getword(r->pool, &r->range, ',')) &&
  -           parse_byterange(current, r->clength, &range_start, &range_end)) {
  +           parse_byterange(current, clength, &range_start, &range_end)) {
           const char *str;
           apr_size_t n;
           const char *range;
  @@ -348,7 +364,7 @@
               AP_BRIGADE_INSERT_TAIL(bsend, e);
   
               ts = apr_psprintf(r->pool, BYTERANGE_FMT CRLF CRLF,
  -                              range_start, range_end, r->clength);
  +                              range_start, range_end, clength);
               e = ap_bucket_create_pool(ts, strlen(ts), r->pool);
               AP_BRIGADE_INSERT_TAIL(bsend, e);
           }
  @@ -2343,8 +2359,7 @@
       apr_off_t range_end;
       int num_ranges;
   
  -    /* ### this test for r->clength is probably a Bad Thing. need to fix */
  -    if (!r->clength || r->assbackwards)
  +    if (r->assbackwards)
           return 0;
   
       /* Check for Range request-header (HTTP/1.1) or Request-Range for
  
  
  

Mime
View raw message