httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: httpd-2.0 CHANGES
Date Mon, 07 Oct 2002 05:10:55 GMT
brianp      2002/10/06 22:10:54

  Modified:    modules/http http_protocol.c
               .        CHANGES
  Log:
  Simpler, faster code for generating HTTP response headers:
  Instead of passing a callback function to apr_table_do() to
  generate one field at a time, just build an iovec containing
  all the fields and make a single call to apr_brigade_writev().
  
  Revision  Changes    Path
  1.460     +43 -2     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.459
  retrieving revision 1.460
  diff -u -r1.459 -r1.460
  --- http_protocol.c	22 Sep 2002 00:05:08 -0000	1.459
  +++ http_protocol.c	7 Oct 2002 05:10:53 -0000	1.460
  @@ -1151,6 +1151,48 @@
       return 1;
   }
   
  +/* Send a request's HTTP response headers to the client.
  + */
  +static apr_status_t send_all_header_fields(header_struct *h,
  +                                           const request_rec *r)
  +{
  +    const apr_array_header_t *elts;
  +    const apr_table_entry_t *t_elt;
  +    const apr_table_entry_t *t_end;
  +    struct iovec *vec;
  +    struct iovec *vec_next;
  +
  +    elts = apr_table_elts(r->headers_out);
  +    if (elts->nelts == 0) {
  +        return APR_SUCCESS;
  +    }
  +    t_elt = (const apr_table_entry_t *)(elts->elts);
  +    t_end = t_elt + elts->nelts;
  +    vec = (struct iovec *)apr_palloc(h->pool, 4 * elts->nelts);
  +    vec_next = vec;
  +
  +    /* For each field, generate
  +     *    name ": " value CRLF
  +     */
  +    do {
  +        vec_next->iov_base = (void*)(t_elt->key);
  +        vec_next->iov_len = strlen(t_elt->key);
  +        vec_next++;
  +        vec_next->iov_base = ": ";
  +        vec_next->iov_len = sizeof(": ") - 1;
  +        vec_next++;
  +        vec_next->iov_base = (void*)(t_elt->val);
  +        vec_next->iov_len = strlen(t_elt->val);
  +        vec_next++;
  +        vec_next->iov_base = CRLF;
  +        vec_next->iov_len = sizeof(CRLF) - 1;
  +        vec_next++;
  +        t_elt++;
  +    } while (t_elt < t_end);
  +
  +    return apr_brigade_writev(h->bb, NULL, NULL, vec, vec_next - vec);
  +}
  +
   /*
    * Determine the protocol to use for the response. Potentially downgrade
    * to HTTP/1.0 in some situations and/or turn off keepalives.
  @@ -1637,8 +1679,7 @@
                        NULL);
       }
       else {
  -        apr_table_do((int (*) (void *, const char *, const char *)) form_header_field,
  -                     (void *) &h, r->headers_out, NULL);
  +        send_all_header_fields(&h, r);
       }
   
       terminate_header(b2);
  
  
  
  1.953     +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.952
  retrieving revision 1.953
  diff -u -r1.952 -r1.953
  --- CHANGES	7 Oct 2002 01:41:01 -0000	1.952
  +++ CHANGES	7 Oct 2002 05:10:54 -0000	1.953
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.44
   
  +  *) Performance improvements for the code that generates HTTP
  +     response headers  [Brian Pane]
  +
     *) Add -S as a synonym for -t -DDUMP_VHOSTS.
        [Thom May <thom@planetarytramp.net>]
   
  
  
  

Mime
View raw message