Forum Discussion
Darren_Young_10
Nimbostratus
Mar 11, 2010Remove headers on GET vs. POST
How could I remove headers on a GET vs. a POST request?
hoolio
Cirrostratus
Mar 11, 2010If you want to check for multiple paths you can use a switch statement:
http://www.tcl.tk/man/tcl8.4/TclCmd/switch.htm
when HTTP_REQUEST {
set remove_headers 0
Check the requested path
switch -glob [HTTP::path] {
"/path1/*" -
"*/path2/" -
"*/path3/*" {
if {[HTTP::method] eq "POST"}{
set remove_headers 1
}
}
}
}
when HTTP_RESPONSE {
if {$remove_headers}{
HTTP::header remove Cache-Control
HTTP::header remove Pragma
}
}
The -glob flag in combination with the * wildcard means the first check is if the path starts with /path1/, the second is if the path ends with /path2/ and the third is if the path contains /path3/.
If you did want to do something to a set of strings, you could use a list and a foreach loop:
set paths [list path1 path2 path3]
foreach path $paths {
do something
}
There are arrays in TCL if you want to use one:
http://www.tcl.tk/man/tcl8.4/TclCmd/array.htm
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