Issue with HTTP_RESPONSE_RELEASE and redirect
Hi everyone, I'm pretty new to F5 and I've a question, regarding the processing of iRules within the Virtual servers. Basically I have an irule that I use to log the requests and send a line into a pool:
timing on
when CLIENT_ACCEPTED {
set logging_hsl [HSL::open -proto UDP -pool logging]
}
when HTTP_REQUEST {
set requestURI "[HTTP::uri]"
set virtual_server_name [getfield [virtual name] / 3]
set domain "[HTTP::host]"
set startTime [clock clicks -milliseconds]
if {[HTTP::header "X-XXX"] ne ""} {set inXXX "[HTTP::header "X-XXX"]"} else {set inXXX "unkn"}
set ts [clock format $timeInSeconds -format "%Y-%m-%dT%T.$frac" -gmt 1]Z
when HTTP_REQUEST_DATA {
set endRequestData [clock clicks -milliseconds]
}
when HTTP_RESPONSE {
set now [clock clicks -milliseconds]
set etimeResponse [expr {($now - $startTime)}]
}
when LB_SELECTED {
set lt_lbPool [getfield [LB::server pool] / 3]
set lt_lbServer [LB::server addr]
}
when HTTP_RESPONSE_RELEASE {
if { [catch {
...
set logging "$ts $src_addr > $virtual_server_name"
HSL::send $logging_hsl $logging
}]
} {
log local0. "Match error"
}
}
The problem I'm having occurs in the HTTP_RESPONSE_RELEASE event in the case that a REDIRECT occurs, in which case it exits through the catch, logs the error but I lose logging that line in the pool. To solve part of the problem, I add a
if { [HTTP::has_responded] } { return }
block before the
if { [catch
, but I would also be missing the logging line. In addition, when you do the redirect, you no longer have access to the headers, so you don't have them cached and it fails.
Does anyone have an idea of how I could do to be able to log that request even if it comes from a redirect? I'm struggling with this and I can't find how to avoid missing logging those requests that come out by redirect.
Thanks in advance!
Cheers.