util::resources::http_get_with_default (private)
util::resources::http_get_with_default -url url -key key \ [ -expires expires ] [ -default default ]
Defined in packages/acs-tcl/tcl/utilities-procs.tcl
Run an HTTP request, which might not be always possible (e.g., when the site has no Internet connection). Therefore, the call will return a default value. This function is to be called for non-essential calls, like e.g. obtaining the newest version of library, etc. The result is cached by default for 5 minutes.
- Switches:
- -url (required)
- URL for the GET request
- -key (required)
- cache key
- -expires (optional, defaults to
"5m"
)- time how long the entry is to be cached
- -default (optional)
- Returns:
- body of the request
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: try { ::acs::misc_cache eval -expires $expires acs-tcl.get_with_default-$key { # # Newer versions (NaviServer 5 or 4.99.31 or newer) # have auto_sni, so plain "ns_http" can be used. For # backwards compatibility, use ::util::http::get, # which contains a logic to add manually the SNI # hostname for HTTPS requests. # set d [::util::http::get -url $url] if {[dict get $d status] ne 200} { ns_log warning "request to $url led to unexpected status code: [dict get $d status]" set result $default break } else { set result [dict get $d page] } } } on ok {result} { } on error {errorMsg} { ns_log warning "request to $url led to: $errorMsg" set result $default } return $resultXQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-tcl/tcl/utilities-procs.xql