Anush
Aug 11, 2016Nimbostratus
TCL errors
we have following irule configured and it's throwing large amount of TCL errors evenif logging is disable for the irule. It's working ok and in production but not sure why it cause TCL errors
...
Ah, so you are performing that match on purpose. Got it. You can either use the catch method already articulated, or:
set cn "VURL_[string tolower [HTTP::host]]"
if { [class exists "$cn"] } {
set redirect_url [class lookup [HTTP::path] $cn]
... etc ...
}
The problem with using catch is, it will catch any runtime error, not just this one, so you could end up masking a different issue, which you would actually want to log.
Incidentally, the quoting I use above (in the set ... command and the class exists ... command) is intentional. If a space creeps in anywhere, it'll cause a runtime exception. Since class names cannot have spaces, and you validated the existence in the class exists ..., quoting isn't needed in the class lookup ....
Also, ordinarily we recommend against variable assignment for command retrieved values (e.g., it's not usually necessary to assign [HTTP::path] to a variable, even if it's referenced more than once because it is generally cheaper to get the value from the command each time than to expand a Tcl variable). In this case, however, we want to avoid duplicate execution of string tolower ...; hence the assignment.
question on HTTP::path - is it case sensitive too?
what if someone type abc.com/F5Devcentral
and configured class has only lowercase item means /f5devcentral
is it going to be hit or miss in class?
Thanks