Forum Discussion

Mikoto_Misaka_1's avatar
Mikoto_Misaka_1
Icon for Nimbostratus rankNimbostratus
Mar 01, 2006

the 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_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Your 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's avatar
    zafer
    Icon for Nimbostratus rankNimbostratus
    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
  • Hi,

     

     

    you can do a [string tolower [HTTP::uri]] to ensure your uri will only have lower case character

     

     

    HTH
  • zafer's avatar
    zafer
    Icon for Nimbostratus rankNimbostratus
    Hello

     

     

    i tried to request to this url http://vip/TEST/word.doc but it didnt worked

     

     

     

    regards

     

     

    zafer

     

  • Could you maybe show us your whole iRule and the logging troubleshooting you did ?

     

     

    it would help us understand what's happening ^^
  • zafer's avatar
    zafer
    Icon for Nimbostratus rankNimbostratus
    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]"

     

    }

     

    }
  • 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_Rober's avatar
    G__Wesley_Rober
    Historic F5 Account
    The 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_Rober's avatar
    G__Wesley_Rober
    Historic F5 Account
    By 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
            }  
    }
    }