Convert HTTP iRule to TCP
We have a client/server application that uses a private written client that connects to a server through the LTM. The client app is installed on the users local workstation and then is used to connect to a virtual server on our LTM. The client sends the initial connection request as a malformed header which contains a session id that is then used for persistence. The current iRule we are using contains HTTP commands, so a HTTP profile is required on the virtual server. But, since this not a true HTTP application, we have some issues when using the HTTP profile. So, I am trying to convert the existing iRule from using the HTTP commands and try and use the TCP payload to get the session id. I am an amateur iRule creator, so I was hoping to get some help and to even see if this is possible. The current iRule is listed below. I want to achieve the same result but with using the TCP payload. That way the HTTP profile will not be needed.
Current iRule
when RULE_INIT {
#Sets logging level (0 = no logging 1 = logging)
set ::debug 0
#Sets persistence timeout in seconds
set ::timeout 900
}
when HTTP_REQUEST {
#Checks if Content-Session header exists
if { [HTTP::header exists "Content-Session"] }{
#Grab Content-Session header value
set sessionid [HTTP::header "Content-Session"]
if {$::debug}{ log local0. "Content-Session value for [IP::client_addr] is: $sessionid"}
#Persist connection based on Content-Session value
catch { persist uie $sessionid $::timeout }
}
}
when HTTP_RESPONSE {
#Checks for Content-Session header
if { [HTTP::header exists "Content-Session"] }{
#Grap Content-Session header value
set sessionid [HTTP::header "Content-Session"]
if {$::debug}{ log local0. "Content-Session value for [IP::remote_addr] is: $sessionid"}
#Setup Persistence record
catch { persist add uie $sessionid $::timeout }
}
}