Forum Discussion

prilin_265672's avatar
prilin_265672
Icon for Nimbostratus rankNimbostratus
Jun 09, 2017

iRule Data Group non-case sensitive comparison

I am writing a program for filtering out headers from http requests. I have defined a new data group "ALLOWED_HEADERS" which contains the headers I want to allow in the request.

 

In my iRule file, I am iterating through my http headers and comparing every header with the group. How do I make this comparison non case sensitive.

 

Here is my code:

 

foreach hname [HTTP::header names] { if {not (class match -nocase ${hname} equals ALLOWED_HEADERS] }} { HTTP::header remove "${hname}" } }

 

I am unsure of the syntax. Can someone please help me validate the "if" statement?

 

1 Reply

  • Modified few event in iRule. Please have try and confirm.

            foreach hname [string tolower [HTTP::header names]] 
                { if { ![class matches -value $hname equals ALLOWED_HEADERS] } 
                      HTTP::header remove "$hname" } 
                 }