Forum Discussion

danra_139044's avatar
danra_139044
Icon for Altostratus rankAltostratus
Mar 25, 2014

iRule: 'Switch -glob' does not work with HTTP::payload, it works using 'if-elseif' logic.

Anyway how to use 'switch -glob' to search HTTP::payload?
It works with 'if-elseif' logic.

Also, is the HTTP::release advisable to add?


when HTTP_REQUEST {
  if { [HTTP::method] equals "POST" }{
    HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_REQUEST_DATA {
  switch -glob [HTTP::payload] {      
apple {
                    pool apple_pool
                }
orange {   
                    pool orange_pool
               }
}
}   

1 Reply

  • It will work, but I'm guessing you need to allow for some padding:

    when HTTP_REQUEST {
        if { [HTTP::method] equals "POST" }{
            HTTP::collect [HTTP::header Content-Length]
        }
    }
    when HTTP_REQUEST_DATA {
        switch -glob [HTTP::payload] {      
            "*apple*" {
                pool apple_pool
            }
            "*orange*" {   
                pool orange_pool
            }
        }
    }
    

    You shouldn't need to issue the HTTP::release command because you're explicitly defining the amount of payload to collect using the Content-Length header.