Forum Discussion
how to insert the header in http request and response on specific condition met
Hi Raj,
depending on how the specific parameter is passed, the code would look very differently.
If the parameter is a simple [HTTP::uri] query string, the code would look like that...
when HTTP_REQUEST {
if { [URI::query [HTTP::uri] "MY_URI_PARAMETER"] equals "VALUE_XYZ" } then {
HTTP::header insert "HEADER_XYZ" "VALUE_XYZ"
set header_insert 1
}
}
when HTTP_RESPONSE {
if { [info exist header_insert] } then {
HTTP::header insert "HEADER_XYZ" "VALUE_XYZ"
unset -nocomplain header_insert
}
}
But if the specific parameter is passed via POST data, then you have to [HTTP::collect] those data frist to enumerate the contained query string information.
Note: Since [HTTP::collect] do have a certain performance impact, it would be recommended to have some additional [if] conditions in place, to identify the request URIs that need to be collected. So if the data is based on POST data, then please provide additional information on how to identifiy those request (e.g. certain [HTTP::path], [HTTP::uri] information, etc.).
Cheers, Kai
Recent Discussions
Related Content
* 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