Forum Discussion

Chad_Roberts_21's avatar
Chad_Roberts_21
Icon for Nimbostratus rankNimbostratus
Jan 23, 2007

Quotation 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?
  • 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: 846

    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

    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
  • 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.