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);
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
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)
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;
idx+=len;
}
-#if 0
+ /* Init the info struct */
if (info->date) {
obj->info.date = info->date;
}
obj->info.expire = info->expire;
}
if (info->content_type) {
- obj->info.content_type = (char*) malloc(strlen(info->content_type));
- if (obj->info.content_type)
- strcpy((char*) obj->info.content_type, 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;
}