tcltrace::before-ns_return (private)

 tcltrace::before-ns_return cmd op

Defined in packages/acs-tcl/tcl/tcltrace-procs.tcl

Execute this proc before ns_return is called. This proc saves the request in a file, which can be later used for validating the returned HTML. This works as well for admin pages, which can not be validated via web based HTML validators without giving away admin privileges.

Parameters:
cmd (required)
the full command as executed by Tcl
op (required)
the trace operation

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-tcl/tcl/tcltrace-init.tcl packages/acs-tcl/ tcl/tcltrace-init.tcl tcltrace::before-ns_return tcltrace::before-ns_return packages/acs-tcl/tcl/tcltrace-init.tcl->tcltrace::before-ns_return ad_file ad_file (public) tcltrace::before-ns_return->ad_file ad_tmpdir ad_tmpdir (public) tcltrace::before-ns_return->ad_tmpdir parameter::get_from_package_key parameter::get_from_package_key (public) tcltrace::before-ns_return->parameter::get_from_package_key

Testcases:
No testcase defined.
Source code:
        lassign $cmd cmdname statuscode mimetype content

        if {[::parameter::get_from_package_key  -package_key acs-tcl  -parameter TclTraceSaveNsReturn  -default 0]} {
            if {$statuscode == 200
                && $mimetype eq "text/html"} {
                set name [ns_conn url]
                regsub {/$} $name /index name
                set fullname [ad_tmpdir]/ns_saved$name.html
                ns_log notice "before-ns_return: save content of ns_return to file:$fullname"
                set dirname [ad_file dirname $fullname]
                if {![ad_file isdirectory $dirname]} {
                    file mkdir $dirname
                }
                set f [open $fullname w]
                puts $f $content
                close $f
            } else {
                ns_log notice "before-ns_return: ignore statuscode $statuscode mime-type $mimetype"
            }
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: