Forum Discussion
Thieß_Rathjen_1
Nimbostratus
Apr 13, 2006matchclass and string tolower
I am trying to match parts of the URI against a list of strings.
My problem is, that i have to convert both into lower case before, because i do not know if the customers types in lower or upper case.
Following rule does not work:
class gt_brand {
"Brand1"
"brand2"
"BRAND3"
}
when HTTP_REQUEST {
set tmp_uri [string tolower [HTTP::uri]]
set my_uri [getfield $tmp_uri "/" 2]
if { [matchclass [string tolower $::gt_brand] starts_with $my_uri] } {
log local0. "tmp_uri is $tmp_uri , my_uri is $my_uri"
}
}
if i remove the "string tolower"-statement in the matchclass line it works theoreticly, but i have the problem mentioned above.
Any proposals?
2 Replies
- Your problem likely lies in the fact that you are passing a TCL list (gt_brand) into a function that expects a string (string tolower). Odds are the "string tolower" call in your matchclass command is casting the list to the first string in that list.
class gt_brand { "brand1" "brand2" "brand3" } when HTTP_REQUEST { set tmp_uri [string tolower [HTTP::uri]] set my_uri [getfield $tmp_uri "/" 2] if { [matchclass $::gt_brand starts_with $my_uri] } { log local0. "tmp_uri is $tmp_uri , my_uri is $my_uri" } }
class gt_brand { "/brand1/" "/brand2/" "/brand3/" } when HTTP_REQUEST { if { [matchclass [string tolower [HTTP::uri]] starts_with $::gt_brand] } { log local0. "found match with uri [string tolower [HTTP::uri]]" } }
- Thieß_Rathjen_1
Nimbostratus
Question: why are you adding mixed case to your class and then converting it to lower case in the iRule. Why not just have it lower case to start with and then just convert the uri to lower case.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects