Commit 4f63710a authored by Bill Stoddard's avatar Bill Stoddard
Browse files

Maintain info structure in mod_mem_cache. This fixes bug where the content

type was lost when content was put in the cache.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91005 13f79535-47bb-0310-9956-ffa450edef68
parent 84ca33a7
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ int cache_select_url(request_rec *r, const char *types, char *url)
    const char *next = types;
    const char *type;
    apr_status_t rv;
    cache_info *info;
    cache_request_rec *cache = (cache_request_rec *) ap_get_module_config(r->request_config, 
                                                                          &cache_module);

@@ -166,13 +167,14 @@ int cache_select_url(request_rec *r, const char *types, char *url)
        type = ap_cache_tokstr(r->pool, next, &next);
        switch ((rv = cache_run_open_entity(cache->handle, type, url))) {
        case OK: {
            info = &(cache->handle->cache_obj->info);
            /* XXX:
             * Handle being returned a collection of entities.
             */

            /* Has the cache entry expired? */
#if 0
            if (r->request_time > cache->handle... need to get info out of the cache... info.expire)
            if (r->request_time > info->expire)
                cache->fresh = 0;
            else
#endif
@@ -213,11 +215,15 @@ apr_status_t cache_write_entity_body(cache_handle_t *h, apr_bucket_brigade *b)
apr_status_t cache_read_entity_headers(cache_handle_t *h, request_rec *r, 
                                       apr_table_t **headers)
{
    cache_info *info = &(h->cache_obj->info);

    /* Build the header table from info in the info struct */
    *headers = apr_table_make(r->pool, 15);

    h->read_headers(h, r, *headers);

    r->content_type = apr_pstrdup(r->pool, info->content_type);

    return APR_SUCCESS;
}
apr_status_t cache_read_entity_body(cache_handle_t *h, apr_bucket_brigade *b) 
+2 −0
Original line number Diff line number Diff line
@@ -634,6 +634,8 @@ int ap_cache_in_filter(ap_filter_t *f, apr_bucket_brigade *in)
    }
    info->expire = exp;

    info->content_type = apr_pstrdup(r->pool, r->content_type);

    /*
     * Write away header information to cache.
     */
+9 −5
Original line number Diff line number Diff line
@@ -405,6 +405,7 @@ static int read_body(cache_handle_t *h, apr_bucket_brigade *bb)

static int write_headers(cache_handle_t *h, request_rec *r, cache_info *info, apr_table_t *headers)
{
    cache_object_t *obj = h->cache_obj;
    mem_cache_object_t *mobj = (mem_cache_object_t*) h->cache_obj->vobj;
    apr_table_entry_t *elts = (apr_table_entry_t *) headers->a.elts;
    apr_ssize_t i;
@@ -445,7 +446,7 @@ static int write_headers(cache_handle_t *h, request_rec *r, cache_info *info, ap
        idx+=len;
    }

#if 0
    /* Init the info struct */
    if (info->date) {
        obj->info.date = info->date;
    }
@@ -456,11 +457,14 @@ static int write_headers(cache_handle_t *h, request_rec *r, cache_info *info, ap
        obj->info.expire = info->expire;
    }
    if (info->content_type) {
        obj->info.content_type = (char*) malloc(strlen(info->content_type));
        if (obj->info.content_type)
        obj->info.content_type = (char*) malloc(strlen(info->content_type) + 1);
        if (!obj->info.content_type) {
            /* cleanup the object? */
            return DECLINED;
        }
        strcpy((char*) obj->info.content_type, info->content_type);
    }
#endif

    return OK;
}