Forum Discussion
Mike_62629
Nimbostratus
Apr 07, 2008Has anyone successfully used dicts in iRules?
Has anyone successfully used dicts in iRules?
I'm currently iterating through a loop doing string comparisons and think it may be a bit more efficient to do a single dictionary lookup instead. I w...
hoolio
Cirrostratus
Mar 11, 2011Hi Dave,
You could try saving the value of [HTTP::request] split on a \r in HTTP_REQUEST and then use TCL list commands to parse this in the response. I think this should be more efficient than looping through all of the request headers and saving them to a list. You'll also get the full request line from HTTP::request, which can't be retrieved whole in one command otherwise.
Can you try something like this:
when HTTP_REQUEST {
Save the request headers split on a carriage return
set request_headers [split [HTTP::request] \\\r]
}
when HTTP_RESPONSE {
log local0. "request header count: [llength $request_headers]"
Loop through the request headers
for {set i 0} {$i < [llength $request_headers]} {incr i} {
Trim off the leading \r\n from each list element and log it
log local0. "$i: [string trimleft [lindex $request_headers $i]]"
}
}
Aaron
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