iRules Live!
Problem this snippet solves:
Sometimes it would be nice to be able to test the output of an iRule command without having to write a whole rule and implement it.
How to use this snippet:
Usage: http://vs_address/request|response/command
Replace spaces in commands with underscore "_"
Examples: http://10.10.67.100/request/AES::key_128
RESULT AES 128 0430890e8eb3dbbc87584439f5830c87
http://10.10.67.100/request/LB::server_pool
RESULT /Common/http_pool
http://10.10.67.100/response/HTTP::header_Server
RESULT Apache/2.2.22 (Debian)
http://10.10.67.100/request/HTTP::header_names
RESULT Host Connection Upgrade-Insecure-Requests User-Agent Accept Accept-Encoding Accept-Language
RESULT
Date: Thu, 13 Apr 2017 04:23:58 GMT
Server: Apache/2.2.22 (Debian)
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 289
Connection: close
Content-Type: text/html; charset=iso-8859-1
Todo: Come up with simpler ways to encode certain characters.
Code :
when HTTP_REQUEST { foreach { ignore event command } [ split [HTTP::uri] "/" ] break log local0. "COMMAND [string map {_ " "} [URI::decode $command]]" set response "" if {$event eq "request"} { catch [string map {_ " "} [URI::decode $command]] output HTTP::respond 200 content "RESULT $output\n$response" Content-Type "text/plain" } } when HTTP_RESPONSE { if {$event eq "response"} { catch [string map {_ " "} [URI::decode $command]] output HTTP::respond 200 content "RESULT $output\n$response" Content-Type "text/plain" } }
Tested this on version:
11.6