nsmcp::CodeUpstreamTool method http (protected)

 <instance of nsmcp::CodeUpstreamTool[i]> http url accept

Defined in /usr/local/ns/tcl/nsmcp/code-upstream.tcl

Parameters:
url (required)
accept (required)

Testcases:
No testcase defined.
Source code:
set headers [ns_set create Accept $accept User-Agent nsmcp-code-upstream Accept-Encoding identity X-GitHub-Api-Version 2022-11-28]
try {
    # No redirect following, cookies, bearer token or arbitrary URL.
    # Fail closed on runtimes without bounded response support.
    set reply [ns_http run -method GET -headers $headers -binary -timeout 3s -expire 5s -maxresponse 1MiB $url]
    try {
        if {[dict get $reply status]==200} {
            set bytes [dict get $reply body]
            set decoded [encoding convertfrom utf-8 $bytes]
            if {[encoding convertto utf-8 $decoded] ne $bytes} {error "invalid-upstream-utf8"}
            dict set reply body $decoded
        }
        return [dict remove $reply headers]
    } finally {
        if {[dict exists $reply headers]} {ns_set free [dict get $reply headers]}
    }
} finally {ns_set free $headers}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: