iRule only runs once
I have a BigIP 3400 running BIG-IP 9.4.8 Build 355.0 Final. I am trying to do some payload replacement. I contacted tech support and they told me to ask here. I would have thought they would know the answer. I first tried using a Stream Profile to do a simple replace of www.xyz.com with www3.xyz.com. The home page would load, but any links off the home page would only load a finite amount of data. Very frustrating. So, I decided to write an iRule. After some research I came up with the following:
when HTTP_REQUEST {
Don't allow data to be chunked
if { [HTTP::version] eq "1.1" } {
if { [HTTP::header is_keepalive] } {
HTTP::header replace "Connection" "Keep-Alive"
}
HTTP::version "1.0"
}
}
when HTTP_RESPONSE {
First, check to see if there's a Content-Length header
if {[info exists [HTTP::header Content-Length]] } {
If there is, we'll collect that much data
set clen [HTTP::header "Content-Length"]
} else {
Otherwise we collect the max
set clen 4294967295
}
if { $clen > 0 } {
HTTP::collect $clen
}
}
when HTTP_RESPONSE_DATA {
set find "www.xyz.com"
set replace "www3.xyz.com"
set payload [HTTP::payload]
log local0. "Test"
if {[regsub -all $find $payload $replace new_response] > 0} {
log local0. "Replacing www with www3."
HTTP::payload replace 0 [HTTP::payload length] $new_response
}
HTTP::release
}
This rule ONLY fires 1 time. Any subsequent refreshes or links I follow result in the rule not matching again. When I say the rule only fires 1 time the log entry of "Test" only shows up 1 time. I have to uninstall the iRule and then put it back to get it to work again. Like I said, I've asked Tech Support, but they were no help at all. Could someone please point me in the right direction? Thank you.