Hi 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