Forum Discussion

BunnyJunJun's avatar
BunnyJunJun
Icon for Altostratus rankAltostratus
Sep 27, 2022

iRule Checking for No Value

Hi All,

Just want to check with the fellow community members if you all have any idea on how to use iRules to check for no value?

Basically, I am crafting an iRule that search for all headers and sieving out that it starts with sec-ch. If it starts with sec-ch and there isn't any value (tried playing around and this is not an empty string), how do i use iRules to check it as an if condition?

if {$header_name eq ????}, where ???? represents no value. Do assist if possible and share your experiences 😄 

  • Something like this maybe:

    when HTTP_REQUEST {
        foreach x [string tolower [HTTP::header names]] {
            if { ( $x starts_with "sec-ch" ) and ( [HTTP::header $x] eq "" ) } {
                log local0. "found empty sec-ch header"
            }
        }
    }
    • BunnyJunJun's avatar
      BunnyJunJun
      Icon for Altostratus rankAltostratus

      Hi Kevin,

      Thanks! I did roughly the same, however, in your context, x has no value. It is not even a string. Hence, quite hard for me to further "manipulate" x.

      I was thinking to concatenate it like those we do for typical coding. (i.e. var temp = "" + x, and temp will be a string with x valueless). Is this possible in terms of iRules?