Forum Discussion
Anthony_Vaz_547
Nimbostratus
Jul 07, 2009Stream::expression irule problem
Hi guys
I'm sure this is just me being an airhead but I can't get this irule to work. Any input greatly appreciated
We have a need to rewrite the content of a HTTP response. I ...
hoolio
Cirrostratus
Jul 07, 2009That looks about right. The regex doesn't match top.jpg:
% regexp
wrong args: should be "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"
% regexp -inline -all {top\.(?!jpg)} top.test
top.
% regexp -inline -all {top\.(?!jpg)} top.jpg
%
Is it possible that jpg is in mixed case? If so, you could use character classes to avoid matching:
regexp -inline -all {top\.(?![jJ][pP][gG])}
Else, you could do more extensive checks of the match by setting the replacement string in STREAM_MATCHED using STREAM::replace. There is an example of this in the last sample of the STREAM::expression wiki page:
http://devcentral.f5.com/wiki/default.aspx/iRules/stream__expression
when HTTP_RESPONSE {
Disable the stream filter by default
STREAM::disable
Check if response type is text
if {[HTTP::header value Content-Type] contains "text"}{
Match any http:// instance and replace it with nothing
STREAM::expression {&http://.*?example\.com&&}
Enable the stream filter for this response only
STREAM::enable
}
}
when STREAM_MATCHED {
log local0. "[IP::client_addr]:[TCP::local_port]: matched: [STREAM::match],\
replaced with: [string map {http:// https://} [STREAM::match]]"
STREAM::replace "[string map {http:// https://} [STREAM::match]]"
}
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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