httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: httpd-2.0/modules/experimental cache_storage.c mod_cache.c mod_cache.h mod_mem_cache.c
Date Fri, 07 Sep 2001 02:56:11 GMT
stoddard    01/09/06 19:56:11

  Modified:    modules/experimental cache_storage.c mod_cache.c mod_cache.h
                        mod_mem_cache.c
  Log:
  Pass headers on read/write header calls.  Update mod_mem_cache to cache headers.
  So much to do so little time ...
  
  Revision  Changes    Path
  1.6       +4 -24     httpd-2.0/modules/experimental/cache_storage.c
  
  Index: cache_storage.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_storage.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- cache_storage.c	2001/09/05 13:33:42	1.5
  +++ cache_storage.c	2001/09/07 02:56:11	1.6
  @@ -189,13 +189,9 @@
   }
   
   apr_status_t cache_write_entity_headers(cache_handle *h, request_rec *r, cache_info *info,
  -                                        apr_table_t *headers_in, apr_table_t *headers_out)

  +                                        apr_table_t *headers)
   {
  -    const char *ct;
  -
  -    ct = ap_table_get(r->headers_out, "Content-Type");
  -    info->content_type = ct;
  -    h->write_headers(h, r, info);
  +    h->write_headers(h, r, info, headers);
       return APR_SUCCESS;
   }
   apr_status_t cache_write_entity_body(cache_handle *h, apr_bucket_brigade *b) 
  @@ -211,27 +207,11 @@
   {
       cache_info *info;
   
  -    /* Be careful to not modify info. */
  -    h->read_headers(h, r, &info);
  -
       /* Build the header table from info in the info struct */
       *headers = apr_table_make(r->pool, 15);
  -    /* Content-Length */
  -    if (info->len)
  -        apr_table_set(*headers, "Content-Length", 
  -                      apr_psprintf(r->pool, "%" APR_SIZE_T_FMT, info->len));
   
  -    /* Last-Modified */
  -    if (info->lastmod) {
  -    }
  -    /* Expires */
  -    if (info->expire) {
  -    }
  -    if (info->content_type) {
  -        r->content_type = apr_pstrdup(r->pool, info->content_type);
  -    }
  -    /* Date */
  -    
  +    h->read_headers(h, r, &info, *headers);
  +
       return APR_SUCCESS;
   }
   apr_status_t cache_read_entity_body(cache_handle *h, apr_bucket_brigade *b) 
  
  
  
  1.13      +1 -1      httpd-2.0/modules/experimental/mod_cache.c
  
  Index: mod_cache.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- mod_cache.c	2001/08/30 02:55:08	1.12
  +++ mod_cache.c	2001/09/07 02:56:11	1.13
  @@ -631,7 +631,7 @@
       /*
        * Write away header information to cache.
        */
  -    cache_write_entity_headers(cache->handle, r, info, r->headers_in, r->headers_out);
  +    cache_write_entity_headers(cache->handle, r, info, r->headers_out);
       cache_write_entity_body(cache->handle, in);    
       return ap_pass_brigade(f->next, in);
   }
  
  
  
  1.9       +5 -5      httpd-2.0/modules/experimental/mod_cache.h
  
  Index: mod_cache.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- mod_cache.h	2001/08/30 02:51:26	1.8
  +++ mod_cache.h	2001/09/07 02:56:11	1.9
  @@ -175,9 +175,9 @@
   
       /* Cache call back functions */
       int (*remove_entity) (cache_handle *h);
  -    int (*write_headers)(cache_handle *h, request_rec *r, cache_info *i);
  +    int (*write_headers)(cache_handle *h, request_rec *r, cache_info *i, apr_table_t *headers);
       int (*write_body)(cache_handle *h, apr_bucket_brigade *b);
  -    int (*read_headers) (cache_handle *h, request_rec *r, cache_info **i);
  +    int (*read_headers) (cache_handle *h, request_rec *r, cache_info **i, apr_table_t *headers);
       int (*read_body) (cache_handle *h, apr_bucket_brigade *bb); 
   
   };
  @@ -208,7 +208,7 @@
   int cache_select_url(request_rec *r, const char *types, char *url);
   
   apr_status_t cache_write_entity_headers(cache_handle *h, request_rec *r, cache_info *info,

  -                                        apr_table_t *headers_in, apr_table_t *headers_out);
  +                                        apr_table_t *headers);
   apr_status_t cache_write_entity_body(cache_handle *h, apr_bucket_brigade *bb);
   
   apr_status_t cache_read_entity_headers(cache_handle *h, request_rec *r, apr_table_t **headers);
  @@ -252,13 +252,13 @@
                             (cache_handle *h))
   APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, read_entity_headers, 
                             (cache_handle *h, cache_info **info,
  -                           apr_table_t **headers_in, apr_table_t **headers_out))
  +                           apr_table_t **headers))
   APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, read_entity_body, 
                             (cache_handle *h,
                              apr_bucket_brigade *out))
   APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, write_entity_headers, 
                             (cache_handle *h, cache_info *info,
  -                           apr_table_t *headers_in, apr_table_t *headers_out))
  +                           apr_table_t *headers))
   APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, write_entity_body, 
                             (cache_handle *h,
                              apr_bucket_brigade *in))
  
  
  
  1.6       +62 -6     httpd-2.0/modules/experimental/mod_mem_cache.c
  
  Index: mod_mem_cache.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_mem_cache.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- mod_mem_cache.c	2001/08/30 02:49:40	1.5
  +++ mod_mem_cache.c	2001/09/07 02:56:11	1.6
  @@ -81,10 +81,17 @@
   } cache_type_e;
   
   typedef struct {
  +    char* hdr;
  +    char* val;
  +} cache_header_tbl_t;
  +
  +typedef struct {
       cache_type_e type;
       char *key;
  -    void *m;
  +    apr_ssize_t num_headers;
  +    cache_header_tbl_t *tbl;
       apr_size_t m_len;
  +    void *m;
       cache_info info;
       int complete;
   } cache_object_t;
  @@ -103,9 +110,11 @@
   
   /* Forward declarations */
   static int remove_entity(cache_handle *h);
  -static int write_headers(cache_handle *h, request_rec *r, cache_info *i);
  +static int write_headers(cache_handle *h, request_rec *r, cache_info *i,
  +                         apr_table_t *headers);
   static int write_body(cache_handle *h, apr_bucket_brigade *b);
  -static int read_headers(cache_handle *h, request_rec *r, cache_info **info);
  +static int read_headers(cache_handle *h, request_rec *r, cache_info **info, 
  +                        apr_table_t *headers);
   static int read_body(cache_handle *h, apr_bucket_brigade *bb);
   
   static void cleanup_cache_object(cache_object_t *obj)
  @@ -147,6 +156,10 @@
       if (obj->m)
           free(obj->m);
   
  +    /* XXX Cleanup the headers */
  +    if (obj->num_headers) {
  +        
  +    }
       free(obj);
   }
   
  @@ -377,10 +390,15 @@
       return OK;
   }
   
  -static int read_headers(cache_handle *h, request_rec *r, cache_info **info) 
  +static int read_headers(cache_handle *h, request_rec *r, cache_info **info, 
  +                        apr_table_t *headers) 
   {
       cache_object_t *obj = (cache_object_t*) h->cache_obj;
  +    int i;
   
  +    for (i = 0; i < obj->num_headers; ++i) {
  +        apr_table_setn(headers, obj->tbl[i].hdr, obj->tbl[i].val);
  +    } 
       *info = &(obj->info);
   
       return OK;
  @@ -399,9 +417,47 @@
       return OK;
   }
   
  -static int write_headers(cache_handle *h, request_rec *r, cache_info *info)
  +static int write_headers(cache_handle *h, request_rec *r, cache_info *info, apr_table_t
*headers)
   {
       cache_object_t *obj = (cache_object_t*) h->cache_obj;
  +    apr_table_entry_t *elts = (apr_table_entry_t *) headers->a.elts;
  +    apr_ssize_t i;
  +    apr_size_t len = 0;
  +    apr_size_t idx = 0;
  +    char *buf;
  +
  +    /* Precompute how much storage we need to hold the headers */
  +    obj->tbl = malloc(sizeof(cache_header_tbl_t) * headers->a.nelts);
  +    if (NULL == obj->tbl) {
  +        return DECLINED;
  +    }
  +    for (i = 0; i < headers->a.nelts; ++i) {
  +        len += strlen(elts[i].key);
  +        len += strlen(elts[i].val);
  +        len += 2;        /* Extra space for NULL string terminator for key and val */
  +    }
  +
  +    /* Transfer the headers into a contiguous memory block */
  +    buf = malloc(len);
  +    if (!buf) {
  +        free(obj->tbl);
  +        obj->tbl = NULL;
  +        return DECLINED;
  +    }
  +    obj->num_headers = headers->a.nelts;
  +    for (i = 0; i < obj->num_headers; ++i) {
  +        obj->tbl[i].hdr = &buf[idx];
  +        len = strlen(elts[i].key) + 1;              /* Include NULL terminator */
  +        strncpy(&buf[idx], elts[i].key, len);
  +        idx+=len;
  +
  +        obj->tbl[i].val = &buf[idx];
  +        len = strlen(elts[i].val) + 1;
  +        strncpy(&buf[idx], elts[i].val, len);
  +        idx+=len;
  +    }
  +
  +#if 0
       if (info->date) {
           obj->info.date = info->date;
       }
  @@ -416,7 +472,7 @@
           if (obj->info.content_type)
               strcpy((char*) obj->info.content_type, info->content_type);
       }
  -
  +#endif
       return OK;
   }
   
  
  
  

Mime
View raw message