util::resources::download_helper (public)

 util::resources::download_helper [ -url url ]

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

Helper for ::util::resources::download, since some download sites tend to redirect.

Switches:
-url (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 richtext::ckeditor4::download richtext::ckeditor4::download (private) util::resources::download_helper util::resources::download_helper richtext::ckeditor4::download->util::resources::download_helper util::resources::download util::resources::download (public) util::resources::download->util::resources::download_helper

Testcases:
No testcase defined.
Source code:
        set host [dict get [ns_parseurl $url] host]
        set result [ns_http run -hostname $host -spoolsize 1 $url]
        set fn ""
        switch [dict get $result status] {
            200 {
                set fn [dict get $result file]
            }
            301 -
            302 {
                set location [ns_set iget [dict get $result headers] location]
                ns_log notice "download redirected to $location"
                #set result [util::http::get -url $location -spool]
                set host [dict get [ns_parseurl $url] host]
                set result [ns_http run -hostname $host -spoolsize 1 $location]
                if {[dict get $result status] == 200} {
                    set fn [dict get $result file]
                }
            }
            default {
                ns_log warning "::util::resources::download $url"  "lead to HTTP status code [dict get $result status]"
            }
        }
        if {$fn eq ""} {
            error "download from $url failed: $result"
        }
        return $result
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-tcl/tcl/utilities-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: