Forum Discussion
DB
Nimbostratus
May 11, 2007Can iRule be used to modify HTML code itself being passed?
Can iRules be used to modify the contents of an HTML page being returned to a client HTTP request? For example, if HTML page includes any link that begins with "http://images.dot.com/*" change it to "https://images.dot.com/*". I have an application that's too dumb to send the links back as HTTPS for images on a page, so my users get the "This page contains secure and unsecure items, are you sure you want to see the unsecure..." warning message.
BTW, I'm already doing a HTTP to HTTPS redirect so that if the user does try to his the HTTP://images... link they'll get it, but it's the warning about mixed content I'm trying to alter.
- Of course you can modify the content in the response. You can use the HTTP::payload command to return the current payload into a variable, modify the content in that variable, and then issue the HTTP::payload command again passing in the new payload. To perform substitutions, you can use the TCL regsub or "string map" commands.
http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=5&postid=13504
- DB
Nimbostratus
Thanks for pointing me to the Stream profile. I created a simple example and see it working. - I do believe that you'll need 9.2 to support multiple replacements in a single stream profile. Also the stream profile does not support regular expressions (as far as I know). For that route you'll have to do it manually with the HTTP::payload command in conjuction with the TCL regsub command.
- hoolio
Cirrostratus
I was able to get regexes to work by wrapping the stream expression in {}'s:when HTTP_RESPONSE { STREAM::enable STREAM::expression {@\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}@0.0.0.0@} }
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