Forum Discussion

Anthony_Cheng_1's avatar
Anthony_Cheng_1
Icon for Nimbostratus rankNimbostratus
Aug 30, 2015

irule to append for HTTP::header value Location

I am trying to append some parameters to a HTTP redirect; to my surprise when I tried to display the new value I see that the resulting value has a different string values attached to it. So it is appending at the end but displayed something different; I tried a few encoding but none seems to match the result.

when HTTP_RESPONSE {
  if { [HTTP::is_redirect] &&  [string tolower [HTTP::header Location]]contains "example.com"}{
        set [HTTP::header value Location] "[HTTP::header value Location]&stuff=1"
        log local0. "New Location header value: [HTTP::header value Location] "
    }
}

2 Replies

  • The method for changing a header value is:

    HTTP::replace  
    

    as in:

    when HTTP_RESPONSE {
      if { [HTTP::is_redirect] &&  [string tolower [HTTP::header Location]] contains "example.com" } {
            HTTP::header replace Location "[HTTP::header value Location]&stuff=1"
            log local0. "New Location header value: [HTTP::header value Location] "
        }
    }
    

    Notice that the

    HTTP::header replace
    operation is not placed in the substitution operators ([...]) because you require not return value from that operation.