Forum Discussion

GBurch's avatar
GBurch
Icon for Altostratus rankAltostratus
Jun 28, 2019

Syntax for iRule string manipulation

I have an iRule with the following code:

 

set schema [getfield [HTTP::uri] "&" 2]
set host [getfield [HTTP::uri] "&" 3]
set uri [getfield [HTTP::uri] "&" 4]

 

which works in the vast majority of cases. However, in cases where the URI itself contains an ampersand character, the string is truncated.

 

Is there an alternative I could replace the 3rd line with which would return everything after the 3rd ampersand character in a string? I could do it quite easily on other languages, but can't quite get my head around the syntax for TCL!

 

Many thanks

1 Reply

  • HTTP query ordered parameters is not the best solution...

    I guess the uri format is :

    /page.php?var1=value1&schema=value2&host=value3&uri=value4

    you can use following command to get query string parameters

    set schema [URI::query  [HTTP::uri] schema]
    set host [URI::query  [HTTP::uri] host]
    set uri  [URI::query  [HTTP::uri] uri]