Forum Discussion
TMaCEvans_92750
Nimbostratus
Jan 17, 2011nesting switch within aif statement
I'm trying to nest a switch statement in a if statement but am getting a parse error
[parse error: PARSE syntax 302 syntax\ error\ in\ expression\ \"\ switch\ -glob\ \[string\ tolower\ \[HTTP::u...
TMaCEvans_92750
Nimbostratus
Jan 17, 2011sorry to clear up the nested if statement to start with
not all the traffic that goes to this application that uses websockets requires HTTP::disable thus the nested if
have added a few comments below
[codewhen HTTP_REQUEST {
check is for websocket server (if it is then check if it is websocket if so disable HTTP then pass to pool3 else leave alone and pass to pool3)
if { [URI::path [HTTP::path]] starts_with "/xyz/" || [HTTP::query] contains "xy=9" } {
check is web socket
if { [HTTP::method] equals "GET" && [HTTP::header exists "Upgrade"] && [HTTP::header Upgrade] contains "WebSocket" } {
disbale http for websocket traffic
HTTP::disable
}
send to pool3
pool pool3
check which country it is for and send to coresponding server
} elseif { switch -glob [string tolower [HTTP::uri]] {
"/fr/app*" { pool pool2 }
default { pool Pool1 }
}
} else {
if it doesnt meet any of that criteria send to pool1
pool pool1
}
}
- Dec 20, 2006I haven't used the PHP interface and don't know the language so well, but what I do see is that you are passing in a 1-D array for the first parameter and a 1-D array for the second parameter.
struct MemberSessionState { IPPortDefinition member; EnabledState session_state; }; void LocalLB::PoolMember::set_session_enabled_state( in String[] pool_names, in MemberSessionState[][] session_states );
- Omachonu_Ogali1Dec 21, 2006Historic F5 AccountI initially tried passing a 2-level array as the second argument, but I get an exception from iControl saying that the member object could not be found. If I do a 1-level array, it goes through without a problem, without any exceptions thrown.
- Dec 21, 2006Well, I can guarantee that it is in fact a 2-D array that is required. Odds are the reason why you aren't getting an error for a 1-D array is that the server code is looking at that 1-D array and treating it as an empty 2nd dimension, thus no members for the associated pools.
- Omachonu_Ogali1Dec 22, 2006Historic F5 AccountI did some more testing, and even renamed my 1-D array keys to incorrect names (i.e. NOT member and monitor_state), and it still accepted the parameters without throwing an exception. It refuses a 2-D array, so I ended up creating a class and referencing that as an object. Now, it works flawlessly...
- Omachonu_Ogali1Dec 22, 2006Historic F5 AccountNever mind that last post, totally unnecessary. I was interpreting it as a 2-dimension array, when it's actually a 3-dimension array (first index is the pool, second index is the pool member, third is the actual value). No need for the classes and object references.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects