rp_force_host_redirect (private)

 rp_force_host_redirect host_header location path query \
    [ effective_location ]

Defined in packages/acs-tcl/tcl/request-processor-procs.tcl

Build a ForceHostP redirect to the driver's configured location, or return an empty string when the request already uses that hostname. The path is decoded connection data; the query is the original encoded query string, not form data (in particular, not a POST request body). When supplied, effective_location preserves the current scheme and port (including proxy, container and SuppressHttpPort handling), but its request-derived hostname is replaced with the configured hostname.

Parameters:
host_header (required)
location (required)
path (required)
query (required)
effective_location (optional)
Returns:
encoded absolute redirect URL, or an empty string

Partial Call Graph (max 5 caller/called nodes):
test_rp_force_host_redirect rp_force_host_redirect (test acs-tcl) rp_force_host_redirect rp_force_host_redirect test_rp_force_host_redirect->rp_force_host_redirect ad_urlencode_folder_path ad_urlencode_folder_path (public) rp_force_host_redirect->ad_urlencode_folder_path util::split_host util::split_host (public) rp_force_host_redirect->util::split_host util::split_location util::split_location (public) rp_force_host_redirect->util::split_location rp_filter rp_filter (private) rp_filter->rp_force_host_redirect

Testcases:
rp_force_host_redirect
Source code:
    if {$host_header eq ""} {
        return ""
    }
    util::split_host $host_header host port
    if {![util::split_location $location proto desired_host desired_port]} {
        error "ForceHostP: invalid configured location"
    }
    if {[string equal -nocase $host $desired_host]} {
        return ""
    }

    if {$effective_location ne ""} {
        set effective [ns_parseurl $effective_location]
        set authority [expr {[string first : $desired_host]>=0
                             ? "\[$desired_host\]" : $desired_host}]
        set location [dict get $effective proto]://$authority
        if {[dict exists $effective port]} {
            append location :[dict get $effective port]
        }
    }
    set url [string trimright $location /][ad_urlencode_folder_path $path]
    if {$query ne ""} {
        append url ?$query
    }
    return $url
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: