Forum Discussion

Yugandhar's avatar
Yugandhar
Icon for Nimbostratus rankNimbostratus
Jul 27, 2018

Reg getfield command in Redirection.

Hi

 

Is there any difference between the below 2 methods ?.

 

HTTP::redirect "https://[getfield [HTTP::host] : 1][HTTP::uri]"

 

HTTP::redirect "https:// [HTTP::host] [HTTP::uri]"

 

I get the same result when i apply either of them on a Virtual Server listening on Port 80 i.e. http://test7883.com is redirected to https://test7883.com as expected.

 

Is there any specific advantage of using getfield command in the redirection statement.

 

Thanks,

 

Yugandhar.

 

3 Replies

  • getfield is tcl function and more flexible to grepping exact value in long URL/URI String.

    getfield: Split a string on a character and returns the string corresponding to the specific field. The field_number parameter is 1 indexed.

        getfield     
    
    • HTTP::redirect "https://[getfield [HTTP::host] : 1][HTTP::uri]" --> Here Split String/character is

      :

    • HTTP::redirect "https://[HTTP::host][HTTP::uri]" --> Its common redirection conditions.

    Rest didn't observe difference.

    • Yugandhar's avatar
      Yugandhar
      Icon for Nimbostratus rankNimbostratus

      Hi F5_Rock,

       

      1. Here getfield functionality is to split the host part i.e. http://test7883.com:8900 ?.

         

      2. what is the use of field_number in the above case it's mentioned as 1 ?.

         

      I am unable to understand why we need to split the host part when we have to do a https redirection for the http request i.e. we wil redirect the http request http://test7883.com:8900 to https://test7883.com:8900

       

      Thanks,

       

      Yugandhar

       

  • as f5_rock explained, getfield command returns a substring of the input string

     

    in your example : the input string is test7883.com:8900

     

    • [getfield [HTTP::host] : 1] will return test7883.com

       

      this is the first part of the input string with separator :
    • [getfield [HTTP::host] : 2] will return 8900

       

      this is the second part of the input string with separator :