Forum Discussion
Javon_Simons_47
Nimbostratus
Jan 06, 2009irule User Agent rewrite
IE problem. It seems that the more .NET updates that you install, the longer your user agent becomes in your registry. I was wondering if this irule would rewrite, IE shorten the user agent:
when HTTP_REQUEST {
change host header
if { [HTTP::header "User-Agent"] contains " .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; InfoPath.2; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729 " }
{
HTTP::header replace "; .NET CLR 1.1.4322" " "
HTTP::header replace "; .NET CLR 3.0.04506.648" " "
HTTP::header replace "; .NET CLR 3.0.04506.30" " "
}
}
- hoolio
Cirrostratus
Out of curiosity, why are you trying to trim down the length of the User-Agent header? Does your app not handle the long header value? Could you just truncate it or replace it with a default value if the User-Agent header is over a certain length and contains ".net clr"?when HTTP_REQUEST { Rewrite the User-Agent header value if it's over 100 characters and contains .NET CLR if { [string length [HTTP::header "User-Agent"]] > 100 && [string tolower [HTTP::header "User-Agent"]] contains " .net clr"}{ Replace the User-Agent header with a default value HTTP::header replace "User-Agent" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1; )" A more precise option (but also more resource intensive) Replace the .NET CLR strings in the User-Agent header with nothing, using a regex HTTP::header replace "User-Agent" [regsub -all -nocase {\.net clr (?:\d{1,5}\.?){1,4};? ?} [HTTP::header "User-Agent"] ""] } }
- Javon_Simons_47
Nimbostratus
Thank you for replying. Yes, the app is having trouble with the long string. It causes DOS of the website in IE. Your first option looks like the way I should go. Thank you.
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