iRule to inspect case-insensitive string
I am trying to compose an irule which examines a 'POST' in http header, doesn't care about case as it may be capitals or not, and processes as normal if that value is present. If that value is NOT present - reject the inbound connection.
Here is where I'm at:
when HTTP_REQEUST {
set keyvalue 0
if { [HTTP::method] equals "POST"} {
set http_headers [HTTP::header names]
foreach header $http_headers {
if {tolower $header equals "somevalue"} {
set keyvalue if we find the header
keyvalue == 1
}
}
if {$keyvalue ne 1} {
TCP::close
}
}
}
^^This is not taking into the LTM v9.4.5, so I assume I have some formatting error or other issue.^^
-------------------------------------------------
Another potential one is:
when HTTP_REQUEST {
if {[HTTP::method] equals "POST"} {
set http_headers [HTTP::header names]
[$http_headers "somevalue"] if {$index == -1} { TCP::close } } }
^^this doesn't evaluate case insensitivity though^^
I'm hoping there is an easy way to accomplish what I'm after.
Thank you.