Patti_G_72768
Oct 21, 2013Nimbostratus
iRule for missing or blank headers (user-agent and accept)
Hi all, I'm working on another iRule creation. I need to create a rule that will detect if the request headers for user-agent and/or accept is blank/missing. I also need to be able to exclude uri extensions with rss and smil. Below is the iRule I tried to create based on the requirements. Can I get some help with reviewing the rule and letting me know where I've gone wrong please?
when HTTP_REQUEST {
if {not ([HTTP::uri] ends_with "rss") and not ([HTTP::uri] ends_with "smil")}
{
log local0. "URI extension is not rss or smil."
}
elseif { [HTTP::header "User-Agent"] eq "false" }
{
log local0. "User-Agent header is missing."
}
elseif { [HTTP::header "Accept"] eq "false" }
{
log local0. "Accept header is missing."
}
elseif { [HTTP::header "User-Agent"] contains "^$" }
{
log local0. "User-Agent header is blank."
}
elseif { [HTTP::header "Accept"] contains "^$" }
{
log local0. "Accept header is blank."
}
}