Persistence on value present in one of 3 places
Hello!
Looking to force persistence on a single value found in either the URI of a request, in a header (present in a header but is not the header itself) or the payload.
When a request is redirected to this VIP depending on the type of request it has a unique reference in the URI such as the below:
ref=7c974593-b5e1-4885-a1e1-0a33403bb094
If the reference above is not present in the URI of the request its present in a header but the header is not called "ref" it can be a value in the referred header (after the URL) or present in the payload of the request as something slightly different like xref=7c974593-b5e1-4885-a1e1-0a33403bb094
Payload data is seperated by & (key) and value is seprated by the =
Example - somedata=1234&xref=7c974593-b5e1-4885-a1e1-0a33403bb094&moredata=5678
Below is what I currently have yet its logging the initial request on the URI but nothing on the body (because the below is looking for a specific header) and the BODY part seems to log nothing either just empty.
proc key2value {l k} {
foreach elm [split $l &] {
set kv [split $elm =]
if { $k eq [string trim [lindex $kv 0]] } {
return [string trim [lindex $kv 1]]
}
}
}
when HTTP_REQUEST {
if {[string tolower [URI::query [HTTP::uri] "ref"]] != ""}{
set req_trvalue [string tolower [URI::query [HTTP::uri] "ref"]]
log local0. "REF URI: $req_trvalue"
persist uie $req_trvalue 43200
#########This part works as i can see the ref logged on the F5##########
} elseif { [HTTP::header exists ref] } {
set req_trvalue [string tolower [HTTP::header ref]]
log local0. "REF HEADER: $req_trvalue"
persist uie $req_trvalue 43200
#########The above doesn't work as I can't seem to search for a "ref=" in the headers can only find the option to search for a specific header based on its name####
} else {
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_REQUEST_DATA {
set payload [HTTP::payload]
set req_trvalue [call key2value [lindex $payload 0] \"xref\"]
log local0. "XREF BODY: [call key2value [lindex $payload 0] \"xref\"]"
persist uie $req_trvalue 43200
HTTP::release
}
This last part if I just log after the "HTTTP::collect" command I can cleary see the entire payload listed with the xref=value but the actual log file doesn't seem to log it so either im doing something wrong here or the proc at the top is not right.
The goal is just to scan through all 3, if the ref is present in the first it logs it and persists on it, if not does a value exist in the headers , if not the payload.