【发布时间】:2020-07-18 18:32:26
【问题描述】:
我在使用这个iRule时遇到了一个奇怪的TCL错误,错误是:
- 从“HTTP::uri”中调用的 ERR_ARG(第 2 行) [regsub "/3dnotification" [HTTP::uri] ""] "
这是一个 F5 规则代码。
这是我尝试过的:
when HTTP_REQUEST
{
if { not ( [string tolower [HTTP::uri]] starts_with "/socket.io" )} then {
HTTP::uri [regsub "/3dnotification" [HTTP::uri] ""]
# need to strip trailing slash on URI otherwise results in 404 for resources...
HTTP::uri [regsub "\/$" [HTTP::uri] ""]
} elseif { [string tolower [HTTP::header Upgrade]] contains "websocket" } {
ONECONNECT::reuse disable
set oc_reuse_disable 1
}
HTTP::header replace "X-Forwarded-ContextPath" "/"
}
when SERVER_CONNECTED {
if { [info exists oc_reuse_disable] } {
# Optional; unnecessary if the HTTP profile is disabled (goes into passthrough mode).
ONECONNECT::detach disable
unset oc_reuse_disable
}
}
【问题讨论】:
-
not和starts_with和contains是什么?它们不是标准的expr语法。 -
您可能想提及您正在使用的程序,因为这似乎是针对使用 tcl 作为脚本语言的程序。
-
在典型的失败案例中,
[HTTP::uri]的评估结果是什么?我们在这里处理 URI 的哪些部分?完整的 URI?只是路径部分? -
嗨,例如,如果 URL 是 example.com:8080/main/index.jsp?user=test&login=check,则 URI 将是 /main/index.jsp?user=test&login=check。我猜问题出在这里: HTTP::uri [regsub "\/$" [HTTP::uri] ""]
-
您是否收到所有 URI 的错误,还是只有某些 URI?