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
Hi Darren, - Darren_Young_10
Nimbostratus
We have this one app behind the F5's the we need to remove Cache-Control and Pragma from on a certain set of GET requests. The vendor has also identified what we can search for on the uri for the removal. - hoolio
Cirrostratus
You can check the request method and URI in HTTP_REQUEST and then set a variable to track that you want to remove the Cache-Control and Pragma headers from the response. I'm not sure whether you only want to check GETs or POSTs, but here's an example which checks POSTs:when HTTP_REQUEST { set remove_headers 0 if {[HTTP::path] contains "some/string"}{ if {[HTTP::method] eq "POST"}{ set remove_headers 1 } } } when HTTP_RESPONSE { if {$remove_headers}{ HTTP::header remove Cache-Control HTTP::header remove Pragma } }
- Darren_Young_10
Nimbostratus
Thanks a bunch, that's (mostly) what I had going. I'm discovering how rusty my tcl is now... - hoolio
Cirrostratus
If you want to check for multiple paths you can use a switch statement: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 } }
set paths [list path1 path2 path3] foreach path $paths { do something }
- Darren_Young_10
Nimbostratus
Working perfectly now, thanks. - hoolio
Cirrostratus
You can check the port in HTTP_RESPONSE using TCP::server_port: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 && [TCP::server_port] != 443}{ HTTP::header remove Cache-Control HTTP::header remove Pragma } }
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