Forum Discussion
Chad_Roberts_21
Nimbostratus
Jan 23, 2007Quotation Marks in content of HTTP::respond
I have numerous scripts that contain the "HTTP::respond" action, and I've always been able to get around not being able to use a quotation mark in the content until now. I've got a rather long block of javascript I've been asked to attempt to insert, and it contains exactly 1.2 frillion quotation marks. Give or take.
It's not very practical for me to rewrite the whole thing, so is there a way to be able to use quotes in the content? Or perhaps use the ASCII code for the character or something?
3 Replies
- Chad_Roberts_21
Nimbostratus
It looks like using an ASCII code for a quotation mark works, but the problem is that once you've created the iRule and go back to edit it again, your own browser interprets that text in the content of the iRule as a quotation mark as well, making it difficult to edit on the fly when necessary. I guess this will work, but if anybody else has a better idea, please let me know. - Why do you need to get rid of the quotation marks? If the issue is because you are setting a variable to your content and you are enclosing your variables value with quotes and the internal quotes in the data are mucking things up, then there is an easy workaround.
In TCL, you can enclose values with curly braces instead of quotes if you wish. Here's an example of storing response content in a variable and then responding with that content.when HTTP_REQUEST { set content {Object not found!"Object" not found!The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.Error 404 } HTTP::respond 404 content $content "Connection" "close" }
Here's the HTTP response from the BIG-IP.HTTP/1.0 404 Not Found
Connection: close
Server: BIG-IP
Connection: close
Content-Length: 846Object not found!"Object" not found!The requested URL was not found on this server. If you entered the URL manually please check your
spelling and try again.Error 404
You'll note that in addition to embedded quotes, I also tested including more curly braces in the content and as long as they are evened out then the TCL interpreter should handle it.
If this is completely off target of what you were asking, let me know...
-Joe - Chad_Roberts_21
Nimbostratus
Crap. That's exactly what I needed. That's the problem with being self-taught... you miss out on some details.
I wasn't using a variable (actually, never thought to do it that way), just placing the text directly into the content of the HTTP::respond action, but I have never noticed sample code that used curly brackets instead of quotes. Ya learn something new every day, especially with BIG-IPs. heh
Thanks a million.
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
