strange behaviour down here. I’m trying to extract value of parameters from the payload of a POST and send with HSL using the below irule with no success at all: the variables are empty.
Can anyone tell me what’s wrong with it?
when HTTP_REQUEST {
set hsl [HSL::open -proto UDP -pool HSL]
set uri [HTTP::uri]
set ip [IP::client_addr]
if {[HTTP::uri] contains “keepal”} {
set data [HTTP::payload]
set namevals [split [HTTP::payload] “&”]
set a 0
set b 0
set c 0
set d 0
for {set i 0} {$i < [llength $namevals]} {incr i} {
At a minimum you probably want to use the HTTP::collect command and HTTP_REQUEST_DATA event to capture the payload:
when HTTP_REQUEST {
if { ( [HTTP::method] equals "POST" ) and ( [string tolower [HTTP::uri]] contains "keepal" ) } {
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_REQUEST_DATA {
set payload [HTTP::payload]
All collected payload is available here...
}
You’re most likely not seeing the payload in the HTTP_REQUEST event because it exceeds a single TCP packet. Using HTTP::collect tells the iRule to collect and buffer the payload (up to the specified amount) and make it available in the HTTP_REQUEST_DATA event. Take a look at the wiki for both of these (command and event) for more thorough implementations.