Index: openacs-4/packages/acs-tcl/tcl/00-icanuse-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/00-icanuse-procs.tcl,v diff -u -r1.1.2.22 -r1.1.2.23 --- openacs-4/packages/acs-tcl/tcl/00-icanuse-procs.tcl 14 Jan 2021 14:40:33 -0000 1.1.2.22 +++ openacs-4/packages/acs-tcl/tcl/00-icanuse-procs.tcl 14 Jan 2021 21:35:43 -0000 1.1.2.23 @@ -54,17 +54,21 @@ ad_proc -private cmd_has_subcommand {cmd subcommand} { Helper proc abusing error messages to determine, whether as - submethod is available. + submethod is available, since there is in Tcl no generic way + to determine subcommands for a command. - } { - set has_p true - if {[catch [list $cmd $subcommand] errorMsg]} { - if {[regexp "^.*\"$subcommand\": must be .*\$" $errorMsg]} { - set has_p false - } - } + Note: Use this with caution, this is NOT GUARANTEED to work + with every command, since many commands require e.g. a + connection or return different error messages. When using this + in more cases, test first! - return $has_p + Therefore, this is a PRIVATE function, not intenended for + public use. + } { + catch [list $cmd ""] errorMsg + regsub ", or " $errorMsg ", " errorMsg + regsub "^.*must be " $errorMsg " " errorMsg + return [expr {" $subcommand" in [split $errorMsg ","]}] } ad_proc -private cmd_error_contains {cmd subcommand} { @@ -106,10 +110,11 @@ ::acs::register_icanuse "ns_writer" {[info commands ::ns_writer] ne ""} ::acs::register_icanuse "nsv_dict" [acs::cmd_error_contains {nsv_dict get ""} -varname] -# Note: NaviServer has ns_http since version 4.99.5, but supports the -# run subcommand only since 4.99.15. -::acs::register_icanuse "ns_http" [acs::cmd_has_subcommand ns_http run] +# The feature NaviServer to return a dict as result of "ns_http run" +# came at the same time, when "ns_http stats" was introduced. +::acs::register_icanuse "ns_http results dict" [acs::cmd_has_subcommand ns_http stats] + # # Add some compatibility procs for AOLserver or older NaviServer versions # @@ -176,7 +181,7 @@ if {$delimiter ne ""} { set re "^\\s*\[$delimiter\](.*)$" } else { - set re "^\\s*(\S*.*)$" + set re "^\\s*(\S*.*)$" } join [lmap line [split $text \n] { regexp $re $line . line Index: openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl,v diff -u -r1.30.2.17 -r1.30.2.18 --- openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl 14 Jan 2021 14:40:33 -0000 1.30.2.17 +++ openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl 14 Jan 2021 21:35:43 -0000 1.30.2.18 @@ -209,7 +209,7 @@ set preferred [lindex $preference 0] - if {$preferred eq "native" && [acs::icanuse ns_http]} { + if {$preferred eq "native" && [acs::icanuse "ns_http results dict"]} { return "native" } elseif {[util::which curl] ne ""} { return "curl" Index: openacs-4/packages/acs-tcl/tcl/test/00-icanuse-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/00-icanuse-procs.tcl,v diff -u -r1.1.2.3 -r1.1.2.4 --- openacs-4/packages/acs-tcl/tcl/test/00-icanuse-procs.tcl 14 Jan 2021 14:30:13 -0000 1.1.2.3 +++ openacs-4/packages/acs-tcl/tcl/test/00-icanuse-procs.tcl 14 Jan 2021 21:35:43 -0000 1.1.2.4 @@ -48,7 +48,7 @@ set flag [ad_generate_random_string] aa_false "string has no subcommand called '$flag'" [acs::cmd_has_subcommand string $flag] - aa_section "Test a NaviServer command" + aa_section "Test NaviServer subcommands" set flags { get set