Forum Discussion

Rory_Hewitt_139's avatar
Rory_Hewitt_139
Icon for Nimbostratus rankNimbostratus
Dec 27, 2013

Can I include variables in an HTTP::respond string?

Is it possible to include variables in an HTTP::respond string?

For example:

set title "title of the page"
set body "Hi there!"
HTTP::respond 200 content "$title$body" "Set-Cookie" $cookie

or do I need to build the entire string in advance and then just pass it as a single content variable?

2 Replies

  • would it retain the spacing between the variables in the string?

    yes

    e.g.

    [root@ve11a:Active:In Sync] config  tmsh list ltm virtual bar
    ltm virtual bar {
        destination 172.28.20.15:80
        ip-protocol tcp
        mask 255.255.255.255
        profiles {
            http { }
            tcp { }
        }
        rules {
            myrule
        }
        source 0.0.0.0/0
        vs-index 34
    }
    [root@ve11a:Active:In Sync] config  tmsh list ltm rule myrule
    ltm rule myrule {
        when HTTP_REQUEST {
      set var1 "12345"
      set var2 "abcdef"
      set var3 "xyz"
      HTTP::respond 200 content "$var1 $var2            $var3\r\n"
    }
    }
    [root@ve11a:Active:In Sync] config  curl -i http://172.28.20.15
    HTTP/1.0 200 OK
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 29
    
    12345 abcdef            xyz