multiple match-based stream replacements?
EDIT: I posted this to the wrong category. I figured out the solution: Use more than one expression and use conditionals in your STREAM_MATCHED.
I need to do the following three operations to certain HTTP responses:
1. Modify all relative hrefs to full URL (example: a href="/images/a.jpg" would become a href="http://site.com/images/a.jpg">.
2. Modify all src tags that are not relative to use HTTPS rather than HTTP (example: img src="http://site.com/images/a.jpg" would become img src="https://site.com/images.a.jpg")
3. Modify all Flash AC_FL_RunContent "src", "http://site.com" references to https://
I have a single expression that handles 1:
HTTP_RESPONSE:
STREAM::expression {@href\s*=\s*\"/.*?\"@@}
STREAM_MATCHED:
STREAM::replace "[string map {href=\" href=\"http://site.com} [STREAM::match]]"
I have a single expression that handles 2 and 3:
HTTP_RESPONSE:
STREAM::expression {@src=\"http://.*?\"@@\"src\", \"http://.*?\"@@}
STREAM_MATCHED:
STREAM::replace "[string map {http:// https://} [STREAM::match]]"
Can these be combined somehow and/or is it possible to use more than one iRule? Apologies for my ignorance, I'm new to iRules and TCL.
Thank you,