cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

Problem this snippet solves:

This iRule will interrogate and log all components of the URI. It is meant to illustrate how to use the various URI methods to extract the relevant components of the current HTTP::uri.

Code :

when HTTP_REQUEST {
  log local0. "----------------------"
  log local0. "URI Information"
  log local0. "----------------------"
  log local0. "HTTP:

  log local0. "----------------------"
  log local0. "Path Information"
  log local0. "----------------------"
  log local0. "HTTP:
  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:
  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]"
    log local0. "Value\[$pnum\]: [URI::query [HTTP::uri] [lindex $params 0]]"
  }
}
Version history
Last update:
‎18-Mar-2015 16:07
Updated by:
Contributors