Forum Discussion
Livius
Feb 03, 2016Cirrus
Need help decoding iRule
Hi guys,
I inherited the system from ex sys-admin and I found an itneresting iRule which I would like to know the effect for :
The irule is as follows :
when HTTP_REQUEST {
set seco...
Theo_12742
Feb 03, 2016Cirrus
It appears to be a rule designed to create a persistence record based on values from the URI.
I've added syntax formatting and comments to the code below, roughly explaining the logic.
when HTTP_REQUEST {
Search the URI for a slash (skipping the first character) and record it's index value into the value second. If it doesn't find another slash, the value of second will be -1
set second [string first "/" [HTTP::uri] 1]
Add 1 to second
incr second
This if is true unless the search above did not find another slash, at which point the iRule exists without setting a persistence record
if { $second > 0 } {
Repeat above looking for a third slash.
set third [string first "/" [HTTP::uri] $second]
Again skips the creation of a persistence record unless a third slash was found
if { $third >= 0 } {
Create a universal persistence record based on the URI, but only the portion before the third slash
set uniqueuri [string range [HTTP::uri] 0 $third]
persist uie $uniqueuri 28800
}
}
}
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