Forum Discussion
Insert text to HTTP header via iRule event during APM execution
- Apr 14, 2021
HTTP_REQUEST_SEND is also one of the event can be used to send the APM variable.
https://support.f5.com/csp/article/K74392192
so worth trying below. modify as needed.
when ACCESS_POLICY_AGENT_EVENT { if { [ACCESS::policy agent_id] eq "event_1" } { ACCESS::session data set session.custom.header "value" set header [ACCESS::session data get "session.custom.header"] } } when HTTP_REQUEST_SEND { clientside { if {[info exists header]}{ HTTP::header insert "headername" $header } else { return } } }
Hi Nikoolayy1,
Thank you for your suggestion.
Our expectation is to insert the header when the flow goes through just a certain APM check (branch path) and a certain condition is met, that is because we tried to use ACCESS_POLICY_AGENT_EVENT. Header should not be added by any other APM branch.
If we use "ACCESS_POLICY_COMPLETED" or "HTTP_REQUEST" or "ACCESS_ACL_ALLOWED" or even "HTTP_REQUEST", header will be added for all the checks, not just by a specific APM.
Can you enable some logging and see what's happeing. also edit the iRule to add "insert header"
when ACCESS_POLICY_AGENT_EVENT {
if { [ACCESS::policy agent_id] eq "event_1" } {
ACCESS::session data set session.custom.header "value"
set header [ACCESS::session data get "session.custom.header"]
log local0. "header: $header"
}
}
when ACCESS_POLICY_COMPLETED {
if {[info exists header]}{
log local0. "header found"
HTTP::header insert "headername" $header
log local0. "header inserted with value $header"
} else {
log local0. "no header added as event doesn't match"
return
}
}"
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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