Forum Discussion
Richard_Marsha1
Nimbostratus
Sep 06, 2006http content rewrite
Hi,
I'm looking for some help writing my first iRule.
We are quering a remote domain for an xml feed, but often the returned content begins with garbage - please see example below:...
Richard_Marsha1
Nimbostratus
Sep 19, 2006Well,
I've finally managed to get the thing to compile, but I'm not currently able to test it (because it's production traffic) but i guess it should work.
Here's the irule: where BadServers = foo.bar.com
when HTTP_REQUEST {
if { [matchclass [HTTP::host] equals $::BadServers] }{
set replace 1
}
}
when HTTP_RESPONSE {
if {$replace > 0}{
if {[HTTP::header exists "Content-Length"]}{
set clen [HTTP::header "Content-Length"]
} else {
set clen 4294967295
}
if { $clen > 0 } {
HTTP::collect $clen
}
}
}
when HTTP_RESPONSE_DATA {
if {$replace}{
find beginning of data to keep
set xml_start [string first { if { $xml_start > 0 }{
set newPayload [string range [HTTP::payload] $xml_start end]
HTTP::payload replace 0 $clen $newPayload
}
HTTP::release
Log Results
log local0. "Found $xml_start replaced with $newPayload"
}
}
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
