Forum Discussion
Using variables to create HTTP::respond string?
Hi bc,
the [HTTP::respond] command requires you to pass each additional header as two parameters. So you may either pass your additional headers as two variables...
set statusCode 405
set httpcontent "Only POSTs allowed"
set extraheader_name "Connection"
set extraheader_value "Close"
HTTP::respond $statusCode content $httpContent $extraheader_name $extraheader_value
... or you could utilize TCLs [eval] command to create and finally execute a custom TCL script during runtime.
set http_respond_param "405 content \"Only POSTs allowed\" Connection Close"
eval "HTTP::respond $http_respond_param"
Note: The use of [eval] to create a (non-global) TCL script should be strongly avoided. The reason is, that [eval] needs to parse and byte-code compile the provided script. This will add additional overhead to the system. In addition you have to make sure that the usage of [eval] does not introduce TCL Code-Injection attack vectors, by wrapping every user provided infomation into curly {} braces so that those information are getting hidden either from the first or second command substitution. For further information read those wiki pages.
Information on [eval]
Information on TCL Code Injection Attacks
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
