MCPcopy Create free account
hub / github.com/apache/httpd / handle_autoindex

Function handle_autoindex

modules/generators/mod_autoindex.c:2282–2334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2280/* The formal handler... */
2281
2282static int handle_autoindex(request_rec *r)
2283{
2284 autoindex_config_rec *d;
2285 int allow_opts;
2286
2287 if (strcmp(r->handler,DIR_MAGIC_TYPE) && !AP_IS_DEFAULT_HANDLER_NAME(r->handler)) {
2288 return DECLINED;
2289 }
2290 if (r->finfo.filetype != APR_DIR) {
2291 return DECLINED;
2292 }
2293
2294 allow_opts = ap_allow_options(r);
2295
2296 d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config,
2297 &autoindex_module);
2298
2299 r->allowed |= (AP_METHOD_BIT << M_GET);
2300 if (r->method_number != M_GET) {
2301 return DECLINED;
2302 }
2303
2304 /* OK, nothing easy. Trot out the heavy artillery... */
2305
2306 if (allow_opts & OPT_INDEXES) {
2307 int errstatus;
2308
2309 if ((errstatus = ap_discard_request_body(r)) != OK) {
2310 return errstatus;
2311 }
2312
2313 /* KLUDGE --- make the sub_req lookups happen in the right directory.
2314 * Fixing this in the sub_req_lookup functions themselves is difficult,
2315 * and would probably break virtual includes...
2316 */
2317
2318 if (r->filename[strlen(r->filename) - 1] != '/') {
2319 r->filename = apr_pstrcat(r->pool, r->filename, "/", NULL);
2320 }
2321 return index_directory(r, d);
2322 }
2323 else {
2324 const char *index_names = apr_table_get(r->notes, "dir-index-names");
2325
2326 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01276)
2327 "Cannot serve directory %s: No matching DirectoryIndex (%s) found, and "
2328 "server-generated directory index forbidden by "
2329 "Options directive",
2330 r->filename,
2331 index_names ? index_names : "none");
2332 return HTTP_FORBIDDEN;
2333 }
2334}
2335
2336static void register_hooks(apr_pool_t *p)
2337{

Callers

nothing calls this directly

Calls 4

ap_allow_optionsFunction · 0.85
ap_get_module_configFunction · 0.85
ap_discard_request_bodyFunction · 0.85
index_directoryFunction · 0.85

Tested by

no test coverage detected