Forum Discussion
keefyweefy
Mar 24, 2011Nimbostratus
simple stream replace not working
Hi Guys,
I'm trying to replace text within webpages but things arn't going to plan! As a result i've stripped this to be as simple as possible but still no joy. I've tried doing this two ways:
I've created a stream profile with source: Hello, target: 12345. Applied this to the VS. Then connected to a page which consists of: Hello - The text doesn't get replaced.
I've also tried creating and applying blank stream profile, ammending the assigned http profile to 'rechunk', and creating and applying the following iRule:
when HTTP_RESPONSE {
STREAM::expression "@Hello@45678@"
STREAM::enable
}
But the text still isn't getting replaced, any ideas?
Thanks
- hooleylistCirrostratusHi Keith,
- Michael_YatesNimbostratusIf you are going to use a Stream Profile in an iRule you need several things.
profile stream blank.stream.profile { defaults from stream }
when HTTP_RESPONSE { STREAM::disable STREAM::expression "@Hello@45678@ @Goodbye@12345@" STREAM::enable } }
when HTTP_REQUEST { set uri [HTTP::uri] } when HTTP_RESPONSE { STREAM::disable STREAM::expression "@Hello@45678@ @Goodbye@12345@" if { !($uri contains "somefile.xml") || !($uri contains "/some/folder/") } { STREAM::enable } }
- Michael_YatesNimbostratusPrevious Post of code was messed up:
Stream Profile: ----------------------------------------------------------------- profile stream blank.stream.profile { defaults from stream } iRule 1: ----------------------------------------------------------------- when HTTP_RESPONSE { STREAM::disable STREAM::expression "@Hello@45678@ @Goodbye@12345@" STREAM::enable } } iRule 2: ----------------------------------------------------------------- when HTTP_REQUEST { set uri [HTTP::uri] } when HTTP_RESPONSE { STREAM::disable STREAM::expression "@Hello@45678@ @Goodbye@12345@" if { !($uri contains "somefile.xml") || !($uri contains "/some/folder/") } { STREAM::enable } }
- keefyweefyNimbostratusThank you both for your responses. It appears the text wasn't being replaced due to compression. I changed the irule to include:
when HTTP_REQUEST { Disable the stream filter for all requests STREAM::disable remove the compression offerings from the client HTTP::header remove "Accept-Encoding" } when HTTP_RESPONSE { Check if response type is text if {[HTTP::header value Content-Type] contains "text"}{ Replace STREAM::expression {@Hello@12345@} Enable the stream filter for this response only STREAM::enable } }
- Michael_YatesNimbostratusGlad to hear that you got it worked out.
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