MCPcopy Index your code
hub / github.com/apache/httpd / create_entity

Function create_entity

modules/cache/mod_cache_disk.c:338–402  ·  view source on GitHub ↗

* Hook and mod_cache callback functions */

Source from the content-addressed store, hash-verified

336 * Hook and mod_cache callback functions
337 */
338static int create_entity(cache_handle_t *h, request_rec *r, const char *key, apr_off_t len,
339 apr_bucket_brigade *bb)
340{
341 disk_cache_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &cache_disk_module);
342 disk_cache_conf *conf = ap_get_module_config(r->server->module_config,
343 &cache_disk_module);
344 cache_object_t *obj;
345 disk_cache_object_t *dobj;
346 apr_pool_t *pool;
347
348 if (conf->cache_root == NULL) {
349 return DECLINED;
350 }
351
352 /* we don't support caching of range requests (yet) */
353 if (r->status == HTTP_PARTIAL_CONTENT) {
354 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00700)
355 "URL %s partial content response not cached",
356 key);
357 return DECLINED;
358 }
359
360 /* Note, len is -1 if unknown so don't trust it too hard */
361 if (len > dconf->maxfs) {
362 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00701)
363 "URL %s failed the size check "
364 "(%" APR_OFF_T_FMT " > %" APR_OFF_T_FMT ")",
365 key, len, dconf->maxfs);
366 return DECLINED;
367 }
368 if (len >= 0 && len < dconf->minfs) {
369 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00702)
370 "URL %s failed the size check "
371 "(%" APR_OFF_T_FMT " < %" APR_OFF_T_FMT ")",
372 key, len, dconf->minfs);
373 return DECLINED;
374 }
375
376 /* Allocate and initialize cache_object_t and disk_cache_object_t */
377 h->cache_obj = obj = apr_pcalloc(r->pool, sizeof(*obj));
378 obj->vobj = dobj = apr_pcalloc(r->pool, sizeof(*dobj));
379
380 obj->key = apr_pstrdup(r->pool, key);
381
382 dobj->name = obj->key;
383 dobj->prefix = NULL;
384 /* Save the cache root */
385 dobj->root = apr_pstrmemdup(r->pool, conf->cache_root, conf->cache_root_len);
386 dobj->root_len = conf->cache_root_len;
387
388 apr_pool_create(&pool, r->pool);
389 apr_pool_tag(pool, "mod_cache (create_entity)");
390
391 file_cache_create(conf, &dobj->hdrs, pool);
392 file_cache_create(conf, &dobj->vary, pool);
393 file_cache_create(conf, &dobj->data, pool);
394
395 dobj->data.file = data_file(r->pool, conf, dobj, key);

Callers

nothing calls this directly

Calls 4

ap_get_module_configFunction · 0.85
file_cache_createFunction · 0.85
data_fileFunction · 0.85
header_fileFunction · 0.85

Tested by

no test coverage detected