Forum Discussion

Lyonsy_271608's avatar
Lyonsy_271608
Icon for Altocumulus rankAltocumulus
Mar 24, 2017

Irule problem "contains then insert"

Hi Guys,

 

Looking to add an irule to fix a code issue until it can be fixed by the software team

 

when a request is made that contains native-billing i would like it to insert header named x-version with the value of 9.0

 

we have tried

 

when HTTP_REQUEST { if {{ [HTTP::uri] contains "native-billing" }} { HTTP::header insert "X-Version" "'9.0'" }

 

}

 

didnt work Any ideas

 

thanks is advance

 

  • figured it out didnt like the "'9.0'"

     

    Changed to this and works

     

    when HTTP_REQUEST { if { [HTTP::uri] contains "native-billing" } { HTTP::header insert "X-Version" "9" } }

     

  • Do you get any error when adding the iRule to the system? Do you get any error when the iRule is executed?

    I don't see any major error in the iRule, except the double {. However, that shouldn't cause problems.

    Try add some log messages, like this:

    when HTTP_REQUEST {
      log local0. "[HTTP::uri]"
      if { [HTTP::uri] contains "native-billing" } { 
        HTTP::header insert "X-Version" "'9.0'"
        log local0. "Header inserted"
      }
      log local0. "Headers: [HTTP::header names]"
    }
    
  • figured it out didnt like the "'9.0'"

     

    Changed to this and works

     

    when HTTP_REQUEST { if { [HTTP::uri] contains "native-billing" } { HTTP::header insert "X-Version" "9" } }