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 -N -r1.22 -r1.23 --- openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl 20 Jul 2018 10:53:18 -0000 1.22 +++ openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl 1 Aug 2018 10:39:13 -0000 1.23 @@ -440,8 +440,10 @@ @param timeout Timeout in seconds. The value can be an integer, a floating point number or an ns_time value. - @return Returns the data as dict with elements headers, page, - file, status, and modified. + @return Returns the data as dict with elements + headers, page, file, + status, time (elapsed request time in + ns_time format), and modified. } { return [util::http::request \ @@ -575,8 +577,10 @@ @param timeout Timeout in seconds. The value can be an integer, a floating point number or an ns_time value. - @return Returns the data as dict with elements headers, page, - file, status, and modified. + @return Returns the data as dict with elements + headers, page, file, + status, time (elapsed request time in + ns_time format), and modified. } { set this_proc [lindex [info level 0] 0] @@ -989,9 +993,11 @@ @param timeout Timeout in seconds. The value can be an integer, a floating point number or an ns_time value. - @return Returns the data as dict with elements headers, page, - file, status, and modified from the last - followed redirect, or an empty string if request was not a redirection. + @return Returns the data as dict with elements + headers, page, file, + status, time (elapsed request time in + ns_time format), and modified from the last followed + redirect, or an empty string if request was not a redirection. } { ## Redirection management ## @@ -1169,8 +1175,10 @@ @param timeout Timeout in seconds. The value can be an integer, a floating point number or an ns_time value. - @return Returns the data as dict with elements headers, page, - file, status, and modified. + @return Returns the data as dict with elements + headers, page, file, + status, time (elapsed request time in + ns_time format), and modified. } { set this_proc [lindex [info level 0] 0] @@ -1300,8 +1308,10 @@ @param timeout Timeout in seconds. The value can be an integer, a floating point number or an ns_time value. - @return Returns the data as dict with elements headers, page, - file, status, and modified. + @return Returns the data as dict with elements + headers, page, file, + status, time (elapsed request time in + ns_time format), and modified. } { set this_proc [lindex [info level 0] 0] @@ -1400,9 +1410,21 @@ } } + # Queue call to the url and wait for response - {*}$wait_cmd [{*}$queue_cmd] + set start_time [ns_time get] + set r [{*}$wait_cmd [{*}$queue_cmd]] + set end_time [ns_time get] + # Naviserver > 4.99.16 will return, among others, elapsed time in + # the response dict. If we run an older version, this must be + # calculated. + if {[dict exists $r time]} { + set time [dict get $r time] + } else { + set time [ns_time diff $end_time $start_time] + } + if {[info exists spool_file]} { set page "${this_proc}: response spooled to '$spool_file'" } else { @@ -1473,6 +1495,7 @@ page $page \ file $spool_file \ status $status \ + time $time \ modified $last_modified] } @@ -1617,8 +1640,10 @@ before 7.32.0 just accept integer, the granularity is set to seconds. - @return Returns the data as dict with elements headers, page, - file, status, and modified. + @return Returns the data as dict with elements + headers, page, file, + status, time (elapsed request time in + ns_time format), and modified. } { set this_proc [lindex [info level 0] 0] @@ -1760,8 +1785,13 @@ lappend cmd -D $resp_headers_tmpfile lappend cmd $url + set start_time [ns_time get] set response [{*}$cmd] + set end_time [ns_time get] + # elapsed time + set time [ns_time diff $end_time $start_time] + # Parse headers from dump file set resp_headers [ns_set create resp_headers] set rfd [open $resp_headers_tmpfile r] @@ -1831,6 +1861,7 @@ page $page \ file $spool_file \ status $status \ + time $time \ modified $last_modified] }