util::split_location (public)
util::split_location location protoVar hostnameVar portVar
Defined in packages/acs-tcl/tcl/utilities-procs.tcl
Split the provided location into "proto", "hostname" and "port". The results are returned on success to the provided output variables. The function supports IP-literal notation according to RFC 3986 section 3.2.2.
- Parameters:
- location (required)
- protoVar (required)
- hostnameVar (required)
- portVar (required)
- Returns:
- boolean value indicating success
- Author:
- Gustaf Neumann
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- util__split_and_join_location
Source code: upvar $protoVar proto $hostnameVar hostname $portVar port try { set urlInfo [ns_parseurl $location] } on error {errorMsg} { # # Here we cannot use "ad_log warning", since it calls # "split_location" leading potentially in some error cases to # a recursive loop (call path "ad_log warning", # "util::request_info -with_headers...", # "util_current_location", "security::validated_host_header" # "util::split_location"). Therefore, we are using here the a # simplified version just printing the header fields. # set msg "cannot parse URL '$location': $errorMsg" if {[ns_conn isconnected]} { append msg \n [ns_conn request] \n [util::ns_set_pretty_print [ns_conn headers]] } ns_log warning $msg set success 0 } on ok {result} { if {[dict exists $urlInfo proto] && [dict exists $urlInfo host]} { set proto [dict get $urlInfo proto] set hostname [dict get $urlInfo host] if {[dict exists $urlInfo port]} { set port [dict get $urlInfo port] } else { set port [dict get {http 80 https 443} $proto] } set success 1 } else { ns_log warning "util::split_location <$location> fails" "no host and port information in <$urlInfo>" set success 0 } } return $successXQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-tcl/tcl/utilities-procs.xql