_acs-tcl__util_http_post_vars (private)

 _acs-tcl__util_http_post_vars

Defined in packages/acs-tcl/tcl/test/http-client-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_section aa_section (public) aa_true aa_true (public) _acs-tcl__util_http_post_vars _acs-tcl__util_http_post_vars _acs-tcl__util_http_post_vars->aa_equals _acs-tcl__util_http_post_vars->aa_log _acs-tcl__util_http_post_vars->aa_log_result _acs-tcl__util_http_post_vars->aa_section _acs-tcl__util_http_post_vars->aa_true

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    set endpoint_name /acs-tcl-util-http-post-vars

    set url [acs::test::url]${endpoint_name}

    set script {
        set files [list]
        foreach f [ns_querygetall files.tmpfile] {
            lappend files [ns_md file $f]
        }
        set vars [ns_querygetall vars]
        set vars_urlencoded [ns_querygetall vars_urlencoded]
        set vars_list [ns_querygetall vars_list]
        ns_return 200 text/plain [list $files $vars $vars_urlencoded $vars_list]
    }

    try {
        ns_register_proc POST $endpoint_name $script

        aa_section "Try to send the same parameter as URL and POST"
        aa_true "One cannot specify URLvars and POST vars at the same time" [catch {
            util::http::post  -url $url?thevars=1  -formvars [export_vars {{thevars 2}}]  -formvars_list {thevars 3 thevars 4}
        } errmsg]

        aa_section "Try to send the same parameter as file and non-file"
        aa_true "One cannot specify file vars and POST vars at the same time" [catch {
            util::http::post  -url $url  -files {{file /tmp/myfile.txt fieldname thevars}}  -formvars [export_vars {{thevars 2}}]  -formvars_list {thevars 3 thevars 4}
        } errmsg]

        aa_section "Combine URLencoded and list parameters in a urlencoded POST request"
        set r [util::http::post  -url $url  -formvars [export_vars {{vars 2} {vars_urlencoded:multiple {c d e f}}}]  -formvars_list {vars 3 vars 4 vars_list a vars_list b}]
        lassign [dict get $r page] files vars vars_urlencoded vars_list
        aa_equals "'files' has been sent correctly"  [lsort $files] [list]
        aa_equals "'vars' have been sent correctly"  [lsort $vars] {2 3 4}
        aa_equals "'vars_urlencoded' has been sent correctly"  [lsort $vars_urlencoded] {c d e f}
        aa_equals "'vars_list' has been sent correctly"  [lsort $vars_list] {a b}

        aa_section "Combine URLencoded, list parameters and files in a multipart POST request"
        set files {}
        set files_checksums {}
        set to_delete {}
        foreach c {abc 123 ÄÜÖ} {
            set F [ad_opentmpfile tmpfile]
            puts -nonewline $F $c
            close $F
            lappend files [list file $tmpfile fieldname files]
            lappend files_checksums [ns_md file $tmpfile]
            lappend to_delete $tmpfile
        }
        set r [util::http::post  -url $url  -files $files  -formvars [export_vars {{vars 2} {vars_urlencoded:multiple {c d e f}}}]  -formvars_list {vars 3 vars 4 vars_list a vars_list b}]
        lassign [dict get $r page] files vars vars_urlencoded vars_list
        aa_equals "'files' has been sent correctly"  [lsort $files] [lsort $files_checksums]
        aa_equals "'vars' have been sent correctly"  [lsort $vars] {2 3 4}
        aa_equals "'vars_urlencoded' has been sent correctly"  [lsort $vars_urlencoded] {c d e f}
        aa_equals "'vars_list' has been sent correctly"  [lsort $vars_list] {a b}

        aa_section "Combine URLencoded and list parameters in a multipart POST request"
        set r [util::http::post  -url $url  -multipart  -formvars [export_vars {{vars 2} {vars_urlencoded:multiple {c d e f}}}]  -formvars_list {vars 3 vars 4 vars_list a vars_list b}]
        lassign [dict get $r page] files vars vars_urlencoded vars_list
        aa_equals "'files' has been sent correctly"  [lsort $files] [list]
        aa_equals "'vars' have been sent correctly"  [lsort $vars] {2 3 4}
        aa_equals "'vars_urlencoded' has been sent correctly"  [lsort $vars_urlencoded] {c d e f}
        aa_equals "'vars_list' has been sent correctly"  [lsort $vars_list] {a b}
        ad_file delete {*}$to_delete

    } finally {
        ns_unregister_op POST $endpoint_name
    }
}} {
          aa_log "Running testcase body $body_count"
          set ::__aa_test_indent [info level]
          set catch_val [catch $testcase_body msg]
          if {$catch_val != 0 && $catch_val != 2} {
              aa_log_result "fail" "util_http_post_vars (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: