Forum Discussion
TMcGov_92811
Nimbostratus
Dec 04, 2009iRule for LTM to send HTTP Error code
Hello, I have a simple iRule that directs HTTP requests to certain pools based on the URI. If there is a URI that is not specified in the iRule, I would like the LTM to respond with an HTTP Error code...
hoolio
Cirrostratus
Aug 18, 2010The curly braces prevent variable / command interpretation. You could use subst (http://www.tcl.tk/man/tcl8.4/TclCmd/subst.htm) or escape any double quotes and not use braces to include a command in a value. I haven't tested this but something like it should work. Note that I've set the HTML in a variable once in RULE_INIT rather than generating the HTML on every request.
when RULE_INIT {
HTML content to send.
Need to escape double quotes, literal square braces and other characters?
Example includes an escaped line break to shorten the long line.
set static::custom_html "My Title with escaped \"double quotes\"\
\[escaped literal square braces\]
500 spaces here: [string repeat 500 " "]}]
}
when HTTP_REQUEST {
Send the HTML
HTTP::respond 200 content $static::custom_html
}
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
