Forum Discussion
Yaniv_99962
May 23, 2017Nimbostratus
remove HTTP header based on its value
Lets say I have a client sending multiple headers with same name but different values. How can i remove just one of these headers if it's value is equal to something i'm looking for?
For example:
GET / HTTP/1.1
Test: a
Test: b
Test: c
Test: d
how can I remove just "Test: c" ?
Thanks in advanced
- AneshCirrostratus
Try the below
when HTTP_RESPONSE { foreach header_name [HTTP::header names] { if {[HTTP::header value Test] equals "c"}{ HTTP::header remove $header_name } } }
- Jad_Tabbara__J1Cirrostratus
Hello Yaniv,
try this
set nTEST [HTTP::header count "TEST"] if { $nTEST eq "0" } { log local0. "Nothing to do => No TEST header found" } else { set TESTValueList [HTTP::header values "TEST"] set firstloop 0 foreach TESTValue $TESTValueList { if { $firstloop eq "0"} { HTTP::header remove "TEST" } if { $TESTValue eq "c"} { nothing to do log local0. "Removed -> TEST: $TESTValue" } else { HTTP::header insert TEST $TESTValue log local0. "Inserted -> TEST: $TESTValue" } set firstloop 1 } }
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