Forum Discussion

BaltoStar_12467's avatar
Oct 12, 2015

BIG-IP : iRule case-insensitive query-param matching

F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi

In my iRule I wish to identify the value of a query-param that may or may not be present.

I'm using this logic :

 

set myparam 0
set myparam [URI::query [HTTP::uri] myparam]

 

However, I'm finding that URI::query performs case-sensitive matching.

For example, if my request is :

http://www.mysite.com/hello?myParam=1

then the myparam variable will not be set.

Howe can I perform case-insensitive matches of query-params ?

3 Replies

  • Using your sample, you can conver it to lower-case, before using the variable for any string comparisons: set myparam [string tolower [URI::query [HTTP::uri] myparam]]

    Alternatively:

    set myparam [string tolower [HTTP::query]]

    In case of a request www.asd.fgh/asd?fFF=1, the code above would return "fff=1" (without the query question mark).

    if you want to include the query question mark, use the code below which will return "?fff=1"

    set myparam "?[string tolower [HTTP::query]]"

    • thanks Hannes but your understanding of the URI::query function does not match my own. My understanding is that 'URI::query uri-string query-param-name' returns 1 if "query-param-name=x" ( irrelevant of value of x ) is present in uri-string, and 0 if it's not.
    • Hannes_Rapp's avatar
      Hannes_Rapp
      Icon for Nimbostratus rankNimbostratus
      No, this understanding is not correct. This function will return the value of query parameter, the exact value present in place of x in your sample, not a binary result (0 or 1). If you want a binary result, why not try 'if {[string tolower [HTTP::query]] contains "myparameter"}{ set RESULT 1 }'