I'm not sure exactly what your question is so I'll just analyze your iRule and hopefully that will give you the answers you need.
1. The First "set query" line looks fine. This should log "msisdn is 123".
2. The "set path" line has a couple of issues.
First of all, the URI::path command is to extract the path portion of the URI, not the query portion where ABC resides.
Here's the format of the uri:
http://[HTTP::host][HTTP::uri]
The HTTP::uri is formatted with a path and optional query string
[HTTP::uri] -> path?query
Also, the URI::path command doesn't take strings as arguments, but directory indexes in the path. So for /foo/bar/foobar, to get /bar you would use
set path [URI::path [HTTP::uri] 2 2]
The 2's represent the start and end directory. in this case, I just want directory 2 or /bar).
Here's an iRule that illustrates parsing a URI. Hopefully this will shed some light on the usage of these methods:
when HTTP_REQUEST {
log local0. "----------------------"
log local0. "URI Information"
log local0. "----------------------"
log local0. "HTTP::uri: [HTTP::uri]"
log local0. "----------------------"
log local0. "Path Information"
log local0. "----------------------"
log local0. "HTTP::path: [HTTP::path]"
set depth [URI::path [HTTP::uri] depth]
for {set i 1} {$i <= $depth} {incr i} {
set dir [URI::path [HTTP::uri] $i $i]
log local0. "dir\[$i\]: $dir"
}
log local0. "Basename: [URI::basename [HTTP::uri]]"
log local0. "----------------------"
log local0. "Query Information"
log local0. "----------------------"
log local0. "HTTP::query: [HTTP::query]"
set namevals [split [HTTP::query] "&"]
for {set i 0} {$i < [llength $namevals]} {incr i} {
set params [split [lindex $namevals $i] "="]
set pnum [expr $i+1]
log local0. "Param\[$pnum\]: [lindex $params 0]"
Commented out to show how to use URI::query in the next line. Both
lines produce the same output.
log local0. "Value\[$pnum\]: [lindex $params 1]"
log local0. "Value\[$pnum\]: [URI::query [HTTP::uri] [lindex $params 0]]"
}
}
When passed in with "
http://host/123/456=?456=sss&ABC=123&SSS" (I've added an extra directory to show out it will output), here are the log results:
----------------------
URI Information
----------------------
HTTP::uri: /123/456=?456=sss&ABC=123&SSS
----------------------
Path Information
----------------------
HTTP::path: /123/456=
dir[1]: /123/
Basename: 456=
----------------------
Query Information
----------------------
HTTP::query: 456=sss&ABC=123&SSS
Param[1]: 456
Value[1]: sss
Param[2]: ABC
Value[2]: 123
Param[3]: SSS
Value[3]:
-Joe