Forum Discussion
agidwani_102403
Feb 26, 2008Nimbostratus
One of the F5 expert was able to help write the script, We are running version 9.3.
Production iRule
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { ($uri contains "/global/") }
{ pool acecomm }
elseif { ($uri contains "/name1/") or
($uri contains "/name2/") or
($uri contains "/blah/")
}
{
if { $uri contains "/hscs.asmx" } {
pool acecomm
Change the URI of the request, preserving the query arguments, if any.
set args [findstr $uri "?"]
HTTP::uri "/global/hscs.asmx$args"
if {[HTTP::method] equals "POST"} {
Determine what the original path was
set origpath [findstr $uri "/" 1 "/"]
Determine the search regex (case-insensitive)
set search ""
set index 0
while {$index < [string length $origpath]} {
set char [string index $origpath $index]
set search "$search\[$char[string toupper $char]\]"
incr index
}
Look for /*/hscs.asmx and replace * with "global"
(if you change "global" here you need to change the hard-coded length of 6 below)
Note that this does not fix the Content-Length so we need to do that below
STREAM::expression "@/$search/\[Cc\]\[Oo\]\[Mm\]\[Pp\].\[Aa\]\[Ss\]\[Mm\]\[Xx\]@/global/hscs.asmx@"
STREAM::enable
Store original content-length for POST data
set origlen [HTTP::header "Content-Length"]
Assume replacement string ("global") is 6 characters long, determine difference in
length between "global" and the replacement path
set length_change [expr {6 - [string length $origpath] } ]
Set new content length, assuming the stream profile performed exactly one replacement
HTTP::header remove "Content-Length"
HTTP::header insert "Content-Length" [expr {$origlen + $length_change}]
log local0. "search path $search"
log local0. "origpath=$origpath, change=$length_change, origlen=$origlen"
log local0. "origpath=$origpath, Content len after: [HTTP::header Content-length]"
}
}
}
}