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

Function fixup_redir

modules/mappers/mod_alias.c:665–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

663}
664
665static int fixup_redir(request_rec *r)
666{
667 void *dconf = r->per_dir_config;
668 alias_dir_conf *dirconf =
669 (alias_dir_conf *) ap_get_module_config(dconf, &alias_module);
670 char *ret;
671 int status;
672
673 /* It may have changed since last time, so try again */
674
675 if ((ret = try_redirect(r, &status)) != NULL
676 || (ret = try_alias_list(r, dirconf->redirects, 1, &status))
677 != NULL) {
678 if (ret == PREGSUB_ERROR)
679 return HTTP_INTERNAL_SERVER_ERROR;
680 if (ap_is_HTTP_REDIRECT(status)) {
681 if (dirconf->allow_relative != ALIAS_FLAG_ON || ret[0] != '/') {
682 if (ret[0] == '/') {
683 char *orig_target = ret;
684
685 ret = ap_construct_url(r->pool, ret, r);
686 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00675)
687 "incomplete redirection target of '%s' for "
688 "URI '%s' modified to '%s'",
689 orig_target, r->uri, ret);
690 }
691 if (!ap_is_url(ret)) {
692 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00676)
693 "cannot redirect '%s' to '%s'; "
694 "target is not a valid absoluteURI or abs_path",
695 r->uri, ret);
696 return HTTP_INTERNAL_SERVER_ERROR;
697 }
698 }
699 /* append requested query only, if the config didn't
700 * supply its own.
701 */
702 if (r->args && !ap_strchr(ret, '?')) {
703 ret = apr_pstrcat(r->pool, ret, "?", r->args, NULL);
704 }
705 apr_table_setn(r->headers_out, "Location", ret);
706 }
707 return status;
708 }
709
710 return DECLINED;
711}
712
713static const command_rec alias_cmds[] =
714{

Callers

nothing calls this directly

Calls 6

ap_get_module_configFunction · 0.85
try_redirectFunction · 0.85
try_alias_listFunction · 0.85
ap_construct_urlFunction · 0.85
ap_is_urlFunction · 0.85
ap_strchrFunction · 0.85

Tested by

no test coverage detected