首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >包要求HTTP不工作

包要求HTTP不工作
EN

Stack Overflow用户
提问于 2017-07-01 01:20:27
回答 1查看 235关注 0票数 0

我在使用"package require http“时遇到了一些问题。如果我只有一个包含该行的tcl文件,我会得到以下错误:

代码语言:javascript
复制
can't set "formMap": variable is array
while executing
"variable formMap [array get map]"
(procedure "init" line 15)
invoked from within
"init"
(in namespace eval "::http" script line 42)
invoked from within
"namespace eval http {
# Allow resourcing to not clobber existing data

variable http
if {![info exists http]} {
array set http {
    -ac..."
(file "/usr/local/naviserver4910/lib/tcl8/8.4/http-2.7.13.tm" line 16)
invoked from within
"source -encoding utf-8 /usr/local/naviserver4910/lib/tcl8/8.4/http-2.7.13.tm"
("package ifneeded http 2.7.13" script)
invoked from within
"package require http"
("uplevel" body line 2)
invoked from within
"uplevel {
package require http

有人能帮我解决这个问题吗?谢谢。

编辑-->包含后:

代码语言:javascript
复制
catch {namespace delete ::http}

我在package require http后面添加了:

代码语言:javascript
复制
http::geturl "https://google.com"   

但是,我现在得到以下错误:

代码语言:javascript
复制
invalid command name "http::geturl"
while executing
"http::geturl "https://google.com""
    ("uplevel" body line 4)
    invoked from within
"uplevel {
    catch {namespace delete ::http}
package require http
http::geturl "https://google.com"
set user_id       [ad_conn user_id]

set events_o..."
    (procedure "code::tcl::/web/dev/nnab-codebook/packages/ctrl-ars/www/inde..." line 2)
    invoked from within
"uplevel {

        if { [file exists $__adp_stub.tcl] } {

            # ensure that data source preparation procedure exists and is up-to-date
  ..."
(procedure "adp_prepare" line 2)
invoked from within
"adp_prepare"
    invoked from within
"template::adp_parse [file rootname [ad_conn file]] {}"
    (procedure "adp_parse_ad_conn_file" line 6)
    invoked from within
"$handler"
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
                $handler
            } ad_script_abort val {
                # do nothing
            }"
    invoked from within
"rp_serve_concrete_file [ad_conn file]"
    (procedure "::nsf::procs::rp_serve_abstract_file" line 60)
    invoked from within
"rp_serve_abstract_file "$root/$extra_url""
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
                rp_serve_abstract_file "$root/$extra_url"
                set tcl_url2file([ad_conn url]) [ad_conn file]
                set ..."
EN

回答 1

Stack Overflow用户

发布于 2017-07-01 07:45:19

看起来您/NaviServer正在以某种方式在解释器中重新加载http包,该解释器已经加载了不同版本的http包。这很奇怪。

更奇怪的是,以这种方式工作的http库的最新版本可以追溯到2004年;它在http 2.5.0中进行了更改,该版本是在2005年初升级到该版本的。(显然是我做的,但我真的不记得了。)这一变化适用于TCL8.4和8.5版本(以及8.6和更高版本),所以我非常确定您正在使用的旧版本真的不值得使用。这是版本的上限,这些版本足够老,可以触发你现在看到的行为;它们可能比这个更老。

总而言之,这绝对是奇怪的。你不应该把一个包的不同版本加载到一个Tcl解释器中。这不是一个特别受支持的使用模式(主要是因为大多数包不能很好地卸载它们的状态,因为很难做到很好)。

一种解决方法是在package require之前执行此操作

代码语言:javascript
复制
catch {namespace delete ::http}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44851900

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档