httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: httpd-2.0/modules/http http_protocol.c
Date Fri, 09 Feb 2001 12:19:48 GMT
gstein      01/02/09 04:19:48

  Modified:    modules/http http_protocol.c
  Log:
  *) minor changes, simplifications
  *) fix terminate_header: don't assume anything about the brigade (especially
     that its last bucket is a shared/heap bucket)
  
  Revision  Changes    Path
  1.294     +22 -28    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.293
  retrieving revision 1.294
  diff -u -u -r1.293 -r1.294
  --- http_protocol.c	2001/02/09 07:17:53	1.293
  +++ http_protocol.c	2001/02/09 12:19:47	1.294
  @@ -225,7 +225,8 @@
       apr_off_t range_end;
       char *current;
       char *bound_head;
  -    int clength = 0;
  +    apr_ssize_t bb_length;
  +    apr_off_t clength = 0;
       apr_status_t rv;
       int found = 0;
   
  @@ -286,18 +287,9 @@
       /* 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.
        */
  -    APR_BRIGADE_FOREACH(e, bb) {
  -        const char *ignore;
  -        apr_size_t len;
  +    (void) apr_brigade_length(bb, 1, &bb_length);
  +    clength = (apr_off_t)bb_length;
   
  -        if (e->length >= 0) {
  -            clength += e->length;
  -            continue;
  -        }
  -        apr_bucket_read(e, &ignore, &len, APR_NONBLOCK_READ);
  -        clength += e->length;
  -    }
  -
       /* this brigade holds what we will be sending */
       bsend = apr_brigade_create(r->pool);
   
  @@ -1791,7 +1783,7 @@
   }
   
   typedef struct header_struct {
  -    request_rec *r;
  +    apr_pool_t *pool;
       apr_bucket_brigade *bb;
   } header_struct;
   
  @@ -1801,13 +1793,13 @@
    * It returns true unless there was a write error of some kind.
    */
   static int form_header_field(header_struct *h,
  -    const char *fieldname, const char *fieldval)
  +                             const char *fieldname, const char *fieldval)
   {
       char *headfield;
   
  -    headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL);
  +    headfield = apr_pstrcat(h->pool, fieldname, ": ", fieldval, CRLF, NULL);
       ap_xlate_proto_to_ascii(headfield, strlen(headfield));
  -    apr_brigade_write(h->bb, NULL, NULL, headfield, strlen(headfield));
  +    apr_brigade_puts(h->bb, NULL, NULL, headfield);
       return 1;
   }
   
  @@ -1848,12 +1840,12 @@
   
       tmp = apr_pstrcat(r->pool, protocol, " ", r->status_line, CRLF, NULL);
       ap_xlate_proto_to_ascii(tmp, strlen(tmp));
  -    apr_brigade_write(bb, NULL, NULL, tmp, strlen(tmp));
  +    apr_brigade_puts(bb, NULL, NULL, tmp);
   
       date = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
       apr_rfc822_date(date, r->request_time);
   
  -    h.r = r;
  +    h.pool = r->pool;
       h.bb = bb;
       form_header_field(&h, "Date", date);
       form_header_field(&h, "Server", ap_get_server_version());
  @@ -1889,17 +1881,18 @@
    */
   static void terminate_header(apr_bucket_brigade *bb)
   {
  -    char *tmp = "X-Pad: avoid browser bug" CRLF;
  -    char *crlf = CRLF;
  -    apr_bucket *b = APR_BRIGADE_LAST(bb);
  -    apr_bucket_shared *s = b->data;
  +    char tmp[] = "X-Pad: avoid browser bug" CRLF;
  +    char crlf[] = CRLF;
  +    apr_ssize_t len;
  +
  +    (void) apr_brigade_length(bb, 1, &len);
   
  -    if (s->end >= 255 && s->end <= 257) {
  +    if (len >= 255 && len <= 257) {
           ap_xlate_proto_to_ascii(tmp, strlen(tmp));
  -        apr_brigade_write(bb, NULL, NULL, tmp, strlen(tmp));
  +        apr_brigade_puts(bb, NULL, NULL, tmp);
       }
       ap_xlate_proto_to_ascii(crlf, strlen(crlf));
  -    apr_brigade_write(bb, NULL, NULL, crlf, strlen(crlf));
  +    apr_brigade_puts(bb, NULL, NULL, crlf);
   }
   
   /*
  @@ -2157,7 +2150,7 @@
       apr_table_setn(r->headers_out, "Allow", make_allow(r));
       ap_set_keepalive(r);
   
  -    h.r = r;
  +    h.pool = r->pool;
       h.bb = bb;
   
       apr_table_do((int (*) (void *, const char *, const char *)) form_header_field,
  @@ -2442,7 +2435,7 @@
       const char *clheader;
       const char *protocol;
       apr_bucket *e;
  -    apr_bucket_brigade *b2 = apr_brigade_create(r->pool);
  +    apr_bucket_brigade *b2;
       apr_size_t len = 0;
       header_struct h;
       header_filter_ctx *ctx = f->ctx;
  @@ -2557,9 +2550,10 @@
           apr_table_unset(r->headers_out, "Content-Length");
       }
   
  +    b2 = apr_brigade_create(r->pool);
       basic_http_header(r, b2, protocol);
   
  -    h.r = r;
  +    h.pool = r->pool;
       h.bb = b2;
   
       if (r->status == HTTP_NOT_MODIFIED) {
  
  
  

Mime
View raw message