httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_protocol.c
Date Tue, 07 Nov 2000 22:41:20 GMT
gstein      00/11/07 14:41:16

  Modified:    src/include httpd.h http_protocol.h
               src/main http_protocol.c
  Log:
  Use apr_off_t for the content length, rather than long. Propagate through
  the byterange handling and ap_set_content_length().
  
  [ ap_each_byterange() remains as an apr_size_t* so we don't mess up callers ]
  
  Revision  Changes    Path
  1.112     +1 -1      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.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- httpd.h	2000/11/03 17:34:56	1.111
  +++ httpd.h	2000/11/07 22:40:53	1.112
  @@ -701,7 +701,7 @@
       /** The Range: header */
       const char *range;
       /** The "real" content length */
  -    long clength;
  +    apr_off_t clength;
   
       /** bytes left to read */
       long remaining;
  
  
  
  1.39      +9 -3      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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- http_protocol.h	2000/11/03 17:34:56	1.38
  +++ http_protocol.h	2000/11/07 22:40:56	1.39
  @@ -145,10 +145,10 @@
    * Set the content length for this request
    * @param r The current request
    * @param length The new content length
  - * @return Always 0, can be safely ignored
  - * @deffunc int ap_set_content_length(request_rec *r, long length)
  + * @deffunc void ap_set_content_length(request_rec *r, apr_off_t length)
    */
  -AP_DECLARE(int) ap_set_content_length(request_rec *r, long length);
  +AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length);
  +
   /**
    * Set the keepalive status for this request
    * @param r The current request
  @@ -156,6 +156,7 @@
    * @deffunc int ap_set_keepalive(request_rec *r)
    */
   AP_DECLARE(int) ap_set_keepalive(request_rec *r);
  +
   /**
    * Return the latest rational time from a request/mtime pair.  Mtime is 
    * returned unless it's in the future, in which case we return the current time.
  @@ -165,6 +166,7 @@
    * @deffunc apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime)
    */
   AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime);
  +
   /**
    * Construct an entity tag from the resource information.  If it's a real
    * file, build in some of the file characteristics.
  @@ -175,18 +177,21 @@
    * @deffunc char *ap_make_etag(request_rec *r, int force_weak)
    */ 
   AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
  +
   /**
    * Set the E-tag outgoing header
    * @param The current request
    * @deffunc void ap_set_etag(request_rec *r)
    */
   AP_DECLARE(void) ap_set_etag(request_rec *r);
  +
   /**
    * Set the last modified time for the file being sent
    * @param r The current request
    * @deffunc void ap_set_last_modified(request_rec *r)
    */
   AP_DECLARE(void) ap_set_last_modified(request_rec *r);
  +
   /**
    * Implements condition GET rules for HTTP/1.1 specification.  This function
    * inspects the client headers and determines if the response fulfills 
  @@ -220,6 +225,7 @@
    */
   AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, 
                                      apr_size_t length, apr_size_t *nbytes);
  +
   /**
    * Send an MMAP'ed file to the client
    * @param mm The MMAP'ed file to send
  
  
  
  1.232     +36 -21    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.231
  retrieving revision 1.232
  diff -u -r1.231 -r1.232
  --- http_protocol.c	2000/11/07 20:21:53	1.231
  +++ http_protocol.c	2000/11/07 22:41:09	1.232
  @@ -180,7 +180,8 @@
       return type;
   }
   
  -static int parse_byterange(char *range, long clength, long *start, long *end)
  +static int parse_byterange(char *range, apr_off_t clength,
  +                           apr_off_t *start, apr_off_t *end)
   {
       char *dash = strchr(range, '-');
   
  @@ -214,13 +215,18 @@
       return (*start > 0 || *end < clength - 1);
   }
   
  -static int internal_byterange(int, long *, request_rec *, const char **,
  -			      apr_off_t *, apr_size_t *);
  +/* forward declare */
  +static int internal_byterange(int realreq, apr_off_t *tlength, request_rec *r,
  +                              const char **r_range, apr_off_t *offset,
  +                              apr_size_t *length);
   
   AP_DECLARE(int) ap_set_byterange(request_rec *r)
   {
  -    const char *range, *if_range, *match;
  -    long range_start, range_end;
  +    const char *range;
  +    const char *if_range;
  +    const char *match;
  +    apr_off_t range_start;
  +    apr_off_t range_end;
   
       if (!r->clength || r->assbackwards)
           return 0;
  @@ -266,22 +272,26 @@
           r->byterange = 1;
   
           apr_table_setn(r->headers_out, "Content-Range",
  -	    apr_psprintf(r->pool, "bytes %ld-%ld/%ld",
  -		range_start, range_end, r->clength));
  +                       apr_psprintf(r->pool,
  +                                    "bytes %" APR_OFF_T_FMT "-%" APR_OFF_T_FMT
  +                                    "/%" APR_OFF_T_FMT,
  +                                    range_start, range_end, r->clength));
           apr_table_setn(r->headers_out, "Content-Length",
  -	    apr_psprintf(r->pool, "%ld", range_end - range_start + 1));
  +                       apr_psprintf(r->pool, "%" APR_OFF_T_FMT,
  +                                    range_end - range_start + 1));
       }
       else {
           /* a multiple range */
           const char *r_range = apr_pstrdup(r->pool, range + 6);
  -        long tlength = 0;
  +        apr_off_t tlength = 0;
   
           r->byterange = 2;
           r->boundary = apr_psprintf(r->pool, "%qx%lx",
   				r->request_time, (long) getpid());
  -        while (internal_byterange(0, &tlength, r, &r_range, NULL, NULL));
  +        while (internal_byterange(0, &tlength, r, &r_range, NULL, NULL))
  +            continue;
           apr_table_setn(r->headers_out, "Content-Length",
  -	    apr_psprintf(r->pool, "%ld", tlength));
  +                       apr_psprintf(r->pool, "%" APR_OFF_T_FMT, tlength));
       }
   
       r->status = HTTP_PARTIAL_CONTENT;
  @@ -306,11 +316,12 @@
    * Either case will return 1 if it should be called again, and 0
    * when done.
    */
  -static int internal_byterange(int realreq, long *tlength, request_rec *r,
  +static int internal_byterange(int realreq, apr_off_t *tlength, request_rec *r,
                                 const char **r_range, apr_off_t *offset,
  -			      apr_size_t *length)
  +                              apr_size_t *length)
   {
  -    long range_start, range_end;
  +    apr_off_t range_start;
  +    apr_off_t range_end;
       char *range;
   
       if (!**r_range) {
  @@ -332,17 +343,19 @@
       }
   
       range = ap_getword(r->pool, r_range, ',');
  -    if (!parse_byterange(range, r->clength, &range_start, &range_end))
  +    if (!parse_byterange(range, r->clength, &range_start, &range_end)) {
           /* Skip this one */
           return internal_byterange(realreq, tlength, r, r_range, offset,
                                     length);
  +    }
   
       if (r->byterange > 1) {
           const char *ct = make_content_type(r, r->content_type);
           char ts[MAX_STRING_LEN];
   
  -        apr_snprintf(ts, sizeof(ts), "%ld-%ld/%ld", range_start, range_end,
  -                    r->clength);
  +        apr_snprintf(ts, sizeof(ts),
  +                     "%" APR_OFF_T_FMT "-%" APR_OFF_T_FMT "/%" APR_OFF_T_FMT,
  +                     range_start, range_end, r->clength);
           if (realreq)
               (void) checked_bputstrs(r, CRLF "--", r->boundary,
                                       CRLF "Content-type: ", ct,
  @@ -355,7 +368,9 @@
   
       if (realreq) {
           *offset = range_start;
  -        *length = range_end - range_start + 1;
  +
  +        /* ### we need to change ap_each_byterange() to fix this */
  +        *length = (apr_size_t) (range_end - range_start + 1);
       }
       else {
           *tlength += range_end - range_start + 1;
  @@ -363,11 +378,11 @@
       return 1;
   }
   
  -AP_DECLARE(int) ap_set_content_length(request_rec *r, long clength)
  +AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t clength)
   {
       r->clength = clength;
  -    apr_table_setn(r->headers_out, "Content-Length", apr_psprintf(r->pool, "%ld",
clength));
  -    return 0;
  +    apr_table_setn(r->headers_out, "Content-Length",
  +                   apr_psprintf(r->pool, "%" APR_OFF_T_FMT, clength));
   }
   
   AP_DECLARE(int) ap_set_keepalive(request_rec *r)
  
  
  

Mime
View raw message