Alex_Ma_58639
Dec 03, 2008Nimbostratus
add HTTP Header
How to write a iRule to check if the incoming HTTP header is "abc123" then add a header "efg123" in front of "abc123"?
GET / HTTP/1.1
Host: somehost.example.com
ABC: abcs_value
And you want to check if there is an ABC header and if so insert a new header named EFG like this:
GET / HTTP/1.1
Host: somehost.example.com
EFG: efg_value
ABC: abc_value
If so, this should work:
when HTTP_REQUEST {
Check if ABC header exists
if {[HTTP::header exists "ABC"]}{
Save the value of ABC
set abc_value [HTTP::header value "ABC"]
Remove the ABC header
HTTP::header remove "ABC"
Insert the EFG header
HTTP::header insert "EFG" value "efg_value"
Insert the ABC header again so it's after the EFG header
HTTP::header insert "ABC" value $abc_value
}
}
Note that I haven't tested it, but it looks about right. If you run into any issues, try adding some logging to the iRule.
Thanks,
Aaron