Forum Discussion
Mikoto_Misaka_1
Nimbostratus
Feb 28, 2006the capital letter and the small letter
Hello,
I think that the operator "contains" distingushes the capital letter and the small letter.
Could you please tell me how to simply write iRule without distingushing the capital letter and the small letter ?
For example, I feel the following rule is not simple.
when HTTP_REQUEST {
if { [HTTP::uri] contains "/up/" or [HTTP::uri] contains "/Up/" or [HTTP::uri] contains "/uP/" } {
use pool pool_up
}
else {
use pool pool_others
}
}
We would like to use a conditional expression as follows.
Could you advice me ?
if { [HTTP::uri] contains "[uU][pP]" }
Mark
10 Replies
- Deb_Allen_18Historic F5 AccountYour second example should actually work, although you'll probably want to add the /'s back in to avoid unintentional matches:
if { [HTTP::uri] contains "/[Uu][Pp]/" }
For longer strings, it's easier to convert the uri to one consistent case for comparison instead:
if { [string tolower [HTTP::uri]] contains "/up/" }
HTH
/deb - I believe that the "contains" operator works on standard strings, not regular expressions. You'll have to use "matches_regex" if you want match on regular expressions.
Regular expressions are very expensive resource wise so you should only use them when absolutely necessary and there is no other alternative. I'd recommend using the "string tolower" to convert it to lowercase as deb suggested.
-Joe - zafer
Nimbostratus
Hello
i use this type matchlass, how can i check capital or small letter in request?
if {[matchclass [HTTP::uri] ends_with $::ok_extension] or [matchclass [HTTP::uri] contains $::compress_dir ] and not [matchclass [IP::remote_addr] equals $::no_compress_ip ] } {
set nocompress 0
regards
zafer - Nicolas_Menant
Employee
Hi,
you can do a [string tolower [HTTP::uri]] to ensure your uri will only have lower case character
HTH - zafer
Nimbostratus
Hello
i tried to request to this url http://vip/TEST/word.doc but it didnt worked
regards
zafer - Nicolas_Menant
Employee
Could you maybe show us your whole iRule and the logging troubleshooting you did ?
it would help us understand what's happening ^^ - zafer
Nimbostratus
here is my irule, can i see different resul when clients come from firefox or ie?
disable or enable compress while checking extension and uri and ip addresses with dataclass option
when HTTP_REQUEST {
set nocompress 0
log local0. "comp enabled default "
if {[matchclass [string tolower [HTTP::uri]] ends_with $::ok_extension] or [matchclass [string tolower [HTTP::uri]] contains $::compress_dir ] and not [matchclass [IP::remote_addr] equals $::no_compress_ip ] } {
set nocompress 0
log local0. "setted 0 for ok_extension or compress_dir or ip [IP::remote_addr]"
}
elseif {[matchclass [string tolower [HTTP::uri]] ends_with $::no_extension] or [matchclass [string tolower [HTTP::uri]] contains $::no_compress_dir ] or [matchclass [IP::remote_addr] equals $::no_compress_ip ] } {
set nocompress 1
log local0. "setted 1 for no_extension or no_compress_dir or your ip [IP::remote_addr]"
}
} - The_Bhattman
Nimbostratus
I believe so, but you have to know which request is for IE and which one is for Firefox. If you want this for your internal needs that I believe you can log the HTTP::header and determine if you are running firefox or IE at the time of the request. It's not accurate since the information can be removed, but it's a start. - G__Wesley_RoberHistoric F5 AccountThe http profile has all the appropriate settings to appropriately match URIs and content types. The real problem as I see it is that when you want to do "intelligent compression" beyond what is available in the http profile, you must use the "selective" setting in the profile. Unfortunately this setting does not do ANY compression by default. You must use the COMPRESS::enable command, which rightly ignores the content compression settings of the http profile, and will attempt to compress regardless of content type. My suggestion would be:
1) Allow the Compress: disable command when compression is enabled in the http profile.
or
2) Have the default behavior for selective compression actually compress according to the http profile settings.
It would make things a whole lot simpler. ;-) - G__Wesley_RoberHistoric F5 AccountBy simpler, I mean a rule like this, that disables compression for clients on a local subnet:
rule Intelligent_comression { when HTTP_REQUEST { log local0. "in HTTP_REQUEST" Compression setting in http profile should be set to selective if {[matchclass [IP::remote_addr] eq $::TrustedNets]} { log "Client on a local subnet, disabling compression. client IP: [IP::remote_addr]" COMPRESS::disable } else { log "No Match in local NET List, compressing response to client IP: [IP::remote_addr]" COMPRESS::enable } } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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