Forum Discussion

Les_Marstaeller's avatar
Les_Marstaeller
Icon for Nimbostratus rankNimbostratus
Feb 08, 2006

Case insensitivity in HTTP::uri

Hi,

 

 

I had the following irule that was deciding the pool to direct HTTP requests to the appropriate pool:

 

 

when HTTP_REQUEST {

 

 

if { [HTTP::uri] starts_with "/abc"} {

 

pool abc

 

} elseif { [HTTP::uri] starts_with "/def"} {

 

pool def

 

} elseif { [HTTP::uri] starts_with "/ghi"} {

 

pool ghi }

 

 

}

 

 

My clients are reporting issues with putting http://www.domain.com/ABC (uri in capitals) that, of course the irule does not trigger on. I changed the rule to the following:

 

 

when HTTP_REQUEST {

 

 

if {{tolower[HTTP::uri] starts_with "/abc"}} {

 

pool abc

 

} elseif {{tolower[HTTP::uri] starts_with "/def"}} {

 

pool def

 

} elseif {{tolower[HTTP::uri] starts_with "/ghi"}} {

 

pool ghi }

 

 

}

 

 

Unfortuately these changes disable the site altogether. Is this because the "tolower" function is doing strange things to the preceding slash?

 

 

I have put additional statements in the irule for the moment that will trigger on lower case and additional statement that will trigger on upper case but this will not cover clients that type "/Abc" which I really would like to cater for. As always, any help will be very appreciated.

 

 

Thanks,

 

 

Les

 

Canberra, Australia.
  • Try this instead:

    
    when HTTP_REQUEST {
      if { [ string tolower [HTTP::uri] ] starts_with "/abc" } {
        use pool abc
      } elseif { [ string tolower [HTTP::uri] ] starts_with "/def" } {
          use pool def 
      } elseif { [ string tolower [HTTP::uri] ] starts_with "/ghi" } {
          use pool ghi
      }
    }
  • Hey citizen_elah, you're a genius!!

     

     

    Thanks very much for your help.

     

     

    Have a good day (or night where ever you are in the world :-)

     

     

    Les

     

    Australia
  • Yep, citizen is one sharp guy.

     

     

    In the future, if you want to do things like string or list manipulation, you should browse the TCL reference manual over at sourceforge

     

     

    http://tmml.sourceforge.net/doc/tcl/

     

    Click here

     

     

    We support a large majority of the basic TCL commands. We have a list of unsupported commands over in our wiki if you are interested.

     

     

    -Joe