Patti_G_72768
Oct 01, 2013Nimbostratus
Regex rule conversion to iRule
Hi all, I'm a newbie and have been working on converting a regex rule to an iRule. I wanted to reach out to the community to see if I can get some help with what I have written so far. The regex rule I have is looking to match the following http methods: get, head, prop find, options. If it finds that match then it looks to find a second match looking for content type application-x-www-form-urlencoded, multipart/form-data, text/xml and if both conditions are met then it returns a response error.
Here is the iRule I've written so far:
when HTTP_REQUEST {
if {[HTTP::method] contains
"get" -
"head" -
"propfind" -
"options"
and [HTTP::header "Content-Type"] contains
":application/x-www-form-urlencoded; charset = " -
":multipart/form-data;" -
":text/xml"
}
{
log local0. "Request content type is not allowed by policy."
drop
HTTP::respond 501 content "501 Request ErrorRequest content type is not allowed by policy."
}
}
I don't know if what I have so far is a step in the right direction or if I am completely off.
thanks!