Forum Discussion
Alex_Ma_58639
Nimbostratus
Dec 03, 2008add 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"?
hoolio
Cirrostratus
Dec 04, 2008I assume you have a scenario like this:
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
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects