Forum Discussion
sukru_isik_8872
Nimbostratus
Nov 22, 2012gzip filter
I want to filter gzip requests.if http requests have gzip ,I want to login server.Otherwise don't login .
I write an irule like down but it isn't working.what changes I have to do?
...
hoolio
Cirrostratus
Nov 26, 2012Hi Steve,
Nice example. You had the closing square brace for the string tolower command after the string you were checking. Here is an updated example and one showing how to use switch as well:
when HTTP_REQUEST {
if { [string tolower [HTTP::header Accept-Encoding]] contains "gzip" or [string tolower [HTTP::header Accept-Encoding]] contains "deflate" } {
pool Test_pool
log local0. "Compression enabled, request has been routed [HTTP::header "Accept-Encoding"]"
} else {
HTTP::respond 500 Content "PLEASE SEND A GZIP ENABLED REQUEST" noserver Content-Type "text/html" Connection "Close"
log local0. "Compression disabled, request has NOT been routed [HTTP::header "Accept-Encoding"]: "
}
}
or using switch:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::header Accept-Encoding]] {
"*gzip*" -
"*deflate*" {
pool Test_pool
log local0. "Compression enabled, request has been routed [HTTP::header "Accept-Encoding"]"
}
default {
HTTP::respond 500 Content "PLEASE SEND A GZIP ENABLED REQUEST" noserver Content-Type "text/html" Connection "Close"
log local0. "Compression disabled, request has NOT been routed [HTTP::header "Accept-Encoding"]: "
}
}
}
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
