Forum Discussion
hooleylist
Dec 12, 2008Cirrostratus
Hi there,
A string comparison would be more efficient than a regex. If you really want to check if the postcode and email parameters are in the URI in a particular order you could use [string match *postcode=*email=* [HTTP::query]] to perform the test. Else if you want to check if the query string contains the two parameters in any order you could do two checks ([string match *postcode=*email=* [HTTP::query]] or [string match *email=*postcode=* [HTTP::query]]) or parse the parameters using URI::query (Click here)
Here is the first option:
when HTTP_REQUEST {
Check if the query string contains anything postcode anything email anything or anything email anything postcode
if {([string match *postcode=*email=* [HTTP::query]] or [string match *email=*postcode=* [HTTP::query]])}{
Query string matched, so use PoolB
pool PoolB
} else {
Query string did not match, so use PoolA
pool PoolA
}
}
Here is the second option which parses the query string for the actual parameter values and checks if they have a length. If you don't care whether the parameters have a value, you can remove the string length check on the values:
when HTTP_REQUEST {
Check if the query string contains the postcode and email email parameters with lengths
if {([string length [URI::query [HTTP::query] postcode]] and [string length [URI::query [HTTP::query] email]])}{
Query string matched, so use PoolB
pool PoolB
} else {
Query string did not match, so use PoolA
pool PoolA
}
}
Aaron