Forum Discussion
irule - HTTP_RESPONSE - Default vs Not Default
I'm trying to wrap my head around the difference in this syntax.
In a quick summary it does not appear that the code I have nested inside "default {}" brackets processes properly. I have it setup in another environment exact same way without "default {}" and it works just fine.
when HTTP_RESPONSE {
STREAM::disable
switch statement to look at what Service Pool for ReWriting SSL
switch -glob [LB::server pool] {
"PoolLoadBalance1" {
pool pool_443
}
"PoolLoadBalance2" {
pool pool_4445
}
"/PoolLoadBalance3" {
HTTP::cookie remove "TestCookie1"
HTTP::header insert Set-Cookie "TestCookie1=deleted;secure;expires=Thu, 01 Jan 1970 00:00:00 GMT"
}
default {
if { ([HTTP::header value Content-Type] contains "text") } {
STREAM::expression {@http://abc.com@https://www.abc.com@@src="http://@src="https://@@123.net@www.abc.com@}
STREAM::enable
}
}
}
Working Environment
when HTTP_RESPONSE {
STREAM::disable
switch statement to look at what Service Pool for ReWriting SSL
switch -glob [LB::server pool] {
"PoolLoadBalance1" {
pool pool_443
}
"PoolLoadBalance2" {
pool pool_4445
}
"/PoolLoadBalance3" {
HTTP::cookie remove "TestCookie1"
HTTP::header insert Set-Cookie "TestCookie1=deleted;secure;expires=Thu, 01 Jan 1970 00:00:00 GMT"
}
if { ([HTTP::header value Content-Type] contains "text") } {
STREAM::expression {@http://abc.com@https://www.abc.com@@src="http://@src="https://@@123.net@www.abc.com@}
STREAM::enable
}
}
}
Code
What is the priority with syntax behind default and why would traffic not appear to be hitting the rewrites under the STREAM Expressions.
1 Reply
Strange that your second example works, while the first example makes more sense to me. About the switch command and the default section:
The switch command matches its string argument against each of the pattern arguments in order. As soon as it finds a pattern that matches string it evaluates the following body argument by passing it recursively to the Tcl interpreter and returns the result of that evaluation. If the last pattern argument is default then it matches anything. If no pattern argument matches string and no default is given, then the switch command returns an empty string.
So if there is no match on [LB::server pool] the code in default will be executed. You could start with adding some logging. This will give an idea how far you are getting. Check /var/log/ltm for the logs.
when HTTP_REQUEST { tell server not to compress response HTTP::header remove Accept-Encoding disable STREAM for request flow STREAM::disable } when HTTP_RESPONSE { switch statement to look at what Service Pool for ReWriting SSL switch -glob [LB::server pool] { "PoolLoadBalance1" { log local0. "DEBUG: match PoolLoadBalance1" pool pool_443 } "PoolLoadBalance2" { log local0. "DEBUG: match PoolLoadBalance2" pool pool_4445 } "/PoolLoadBalance3" { log local0. "DEBUG: match PoolLoadBalance3" HTTP::cookie remove "TestCookie1" HTTP::header insert Set-Cookie "TestCookie1=deleted;secure;expires=Thu, 01 Jan 1970 00:00:00 GMT" } default { log local0. "DEBUG: match default" if { ([HTTP::header value Content-Type] contains "text") } { log local0. "DEBUG: Content-Type: text" STREAM::expression {@http://abc.com@https://www.abc.com@@src="http://@src="https://@@123.net@www.abc.com@} STREAM::enable } } } }
Recent Discussions
Related Content
* 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