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:...
Deb_Allen_18
Sep 09, 2006Historic F5 Account
Maybe something like this:
Create a class of type string containing the hostnames for which you want the rule to run:
class BadServers {
"www.domain1.com"
"www.domain2.com"
}to be used by this iRule:
rule rewrite_content {
when HTTP_REQUEST {
if {[matchclass [HTTP::host] $::BadServers]}{
set replace 1
}
when HTTP_RESPONSE {
if {$replace}{
if {[HTTP::header exists Content-Length]}{
set clen [HTTP::header Content-Length]
} else {
set clen 4294967295
}
if { $clength > 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
}
}
}HTH
/deb
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
