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

Function fixup_dir

modules/mappers/mod_dir.c:224–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224static int fixup_dir(request_rec *r)
225{
226 dir_config_rec *d;
227 char *dummy_ptr[1];
228 char **names_ptr;
229 int num_names;
230 int error_notfound = 0;
231
232 /* In case mod_mime wasn't present, and no handler was assigned. */
233 if (!r->handler) {
234 r->handler = DIR_MAGIC_TYPE;
235 }
236
237 /* Never tolerate path_info on dir requests */
238 if (r->path_info && *r->path_info) {
239 return DECLINED;
240 }
241
242 d = (dir_config_rec *)ap_get_module_config(r->per_dir_config,
243 &dir_module);
244
245 /* Redirect requests that are not '/' terminated */
246 if (r->uri[0] == '\0' || r->uri[strlen(r->uri) - 1] != '/')
247 {
248 char *ifile;
249
250 if (!d->do_slash) {
251 return DECLINED;
252 }
253
254 /* Only redirect non-get requests if we have no note to warn
255 * that this browser cannot handle redirs on non-GET requests
256 * (such as Microsoft's WebFolders).
257 */
258 if ((r->method_number != M_GET)
259 && apr_table_get(r->subprocess_env, "redirect-carefully")) {
260 return DECLINED;
261 }
262
263 if (r->args != NULL) {
264 ifile = apr_pstrcat(r->pool, ap_escape_uri(r->pool, r->uri),
265 "/?", r->args, NULL);
266 }
267 else {
268 ifile = apr_pstrcat(r->pool, ap_escape_uri(r->pool, r->uri),
269 "/", NULL);
270 }
271
272 apr_table_setn(r->headers_out, "Location",
273 ap_construct_url(r->pool, ifile, r));
274 return HTTP_MOVED_PERMANENTLY;
275 }
276
277 /* we're running between mod_rewrites fixup and its internal redirect handler, step aside */
278 if (!strcmp(r->handler, REWRITE_REDIRECT_HANDLER_NAME)) {
279 /* Prevent DIR_MAGIC_TYPE from leaking out when someone has taken over */
280 if (!strcmp(r->content_type, DIR_MAGIC_TYPE)) {
281 r->content_type = NULL;

Callers 1

dir_fixupsFunction · 0.85

Calls 5

ap_get_module_configFunction · 0.85
ap_construct_urlFunction · 0.85
ap_sub_req_lookup_uriFunction · 0.85
ap_destroy_sub_reqFunction · 0.85

Tested by

no test coverage detected