rp_handler (private)
rp_handler
Defined in packages/acs-tcl/tcl/request-processor-procs.tcl
The request handler, which responds to absolutely every HTTP request made to the server.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if { ![info exists ::ad_conn] } { # # DRB: handle obscure case where we are served a request like # GET http://www.google.com. In this case AOLserver 4.0.10 # (at least) doesn't run the preauth filter "rp_filter", but # rather tries to serve /global/file-not-found directly. # rp_handler dies a horrible death if it's called without # ::ad_conn being set up. My fix is to simply redirect to the # url AOLserver substitutes if ::ad_conn does not exist # (rp_filter begins with ad_conn -reset) ... # ad_log warning "rp_handler: Obscure case, where ::ad_conn is not set, redirect to [ns_conn url]" # # Before we give up, make one attempt to setup everything. # rp_filter preauth if { ![info exists ::ad_conn] } { ad_returnredirect [ns_conn url] return } } # # Determine internal redirects by comparing URL suffix. We check # if the connection URL ends by the ad_conn extra_url. Don't use a # match operation, since this might lead to surprising results, # when the URL contains match characters ('*' or '?', ...). # if {[info exists ::ad_conn(extra_url)] && $::ad_conn(extra_url) ne "" && [string range [ns_conn url] end-[expr {[string length $::ad_conn(extra_url)] - 1}] end] ne $::ad_conn(extra_url) } { # # On internal redirects, the current ::ad_conn(extra_url) # might be from a previous request, which might have led to a # not-found error pointing to a new URL. This can lead to a # hard to find loop which ends with a "recursion depth # exceeded". There is a similar problem with # ::ad_conn(package_key) and ::ad_conn(package_url) Therefore, # we refetch the url info in case, in case, and reset these # values. These variables seem to be sufficient to handle # request processor loops, but maybe other variables have to # be reset either. # # However, also internal redirects to error pages happens the # same way, but we need to deliver the current URL (coming # from ns_url) and not the original url before the redirect # (the extra_url). Similarly we have to reset the package_key # and package_url to point to the subsite package to deliver # the error pages. This is especially important on # host-node-mapped subsites, when e.g. the error pages are # mapped to /shared/404 etc. # set status [ns_conn status] rp_debug "internal redirect status $status" if {$status < 200 || $status >= 300} { ad_conn -set extra_url [ns_conn url] ad_conn -set package_key "acs-subsite" ad_conn -set package_url / } else { set node [site_node::get -url [ad_conn url]] ad_conn -set extra_url [string range [ad_conn url] [string length [dict get $node url]] end] rp_debug "reset extra_url to '[ad_conn extra_url]'" if {![apm_package_enabled_p [dict get $node package_key]]} { set node [site_node::get -url /] } ad_conn -set package_key [dict get $node package_key] ad_conn -set package_url [dict get $node url] } } # JCD: keep track of rp_handler call count to prevent dev support from recording # information twice when for example we get a 404 internal redirect. We should probably set recursion_count [ad_conn recursion_count] ad_conn -set recursion_count [incr recursion_count] rp_debug "rp_handler: handling request: [ns_conn method] [ns_conn url]?[ns_conn query]" ad_try { rp_handle_request } on error {errorMsg} { set error_msg "errorMsg $errorMsg while serving [ns_conn request]" append error_msg "\nad_url <[ad_conn url]> maps to file <[ad_conn file]>" rp_debug "error in rp_handler: $error_msg" ns_log error "rp_handler no-script-abort: $error_msg\n$::errorCode\n$::errorInfo" rp_report_error }XQL Not present: Generic, PostgreSQL, Oracle