Forum Discussion

N_67263's avatar
N_67263
Icon for Nimbostratus rankNimbostratus
Aug 27, 2017

Understanding the Host in the HTTP request.

Team, While receiving an HTTP request we are trying to get the HOST field from that request.

 

e.g. in case we receive http://xyz.externaldomain.com what parameter can I use in the getfield to extract out the "xyz" part only?

 

Thanks!! N.

 

5 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    N,

    If externaldomain.com is static then you can use string range. Something like this:

    set host [string range [HTTP::host] 0 end-19]
    

    Not on my lab to fully check though.

    Hope this helps,

    N

  • N.

    You can try other option, which will work based on your requirement. Even though domain length changes.

            set host [string tolower [getfield [HTTP::host] "." 1]]
    

    Let us know if any question. Refer link

    • N_67263's avatar
      N_67263
      Icon for Nimbostratus rankNimbostratus

      Thanks, so in here what does the {"." 1} logic mean?

       

      regards!! N.

       

    • Stanislas_Piro2's avatar
      Stanislas_Piro2
      Icon for Cumulonimbus rankCumulonimbus

      did you follow the link provided by f5_rock?

       

      the command getfield split the first parameter string with the second parameter as separator. the third parameter tell which field the command returns.

       

      in the code provided, this means return the string before the first character "."