Forum Discussion

Perween_Zaman_7's avatar
Perween_Zaman_7
Icon for Nimbostratus rankNimbostratus
Nov 06, 2005

Question on getfield

Hi

 

 

If my URL is http://myDomain.com/myImage.img

 

 

what will be the value of the variable second_field in this iRule?

 

 

set second_field [getfield [HTTP::uri] "/" 2]

 

 

Will it be myImage.img or will it be an empty string because the second slash is missing?

 

 

Thanks,

 

 

pzaman

 

 

 

  • The value will be myImage.img. Here's the reason why. getfield works like this:

     

     

    {field1}{sep}{field2}{sep}{field3}{sep}...

     

     

    For your URI of

     

     

    /myImage.img

     

     

    If you use a slash ("/") as a separator, then the first token will be before the separator and the second will be after. So the field number "1" would be what's before the slash (an empty string) and the field number "2" would be after the first slash (myImage.img).

     

     

    -Joe
  • In condition 1 [HTTP::uri] "/" 1] return (null)

     

    In condition 2 [HTTP::uri] "/" 2] return myImage.img