Forum Discussion

Jim_Araujo_1061's avatar
Jim_Araujo_1061
Icon for Nimbostratus rankNimbostratus
Jun 10, 2015

when HTTP_REQUEST_DATA not working

Hello folks, I have a POC I'm testing out. The idea is a web user does a HTTP POST with token that matches a value in a data group. If it matches it will connect them to the pool. I am running into trouble with HTTP_REQUEST_DATA not firing. I've done some debugging by placing log statements within my many IF clauses.

Running LTM 11.5.1 HF4

when CLIENT_ACCEPTED { 
    set usertoken "1"

} 
end of CLIENT_ACCEPTED

when HTTP_REQUEST_DATA {
     log local0. "HITTING http-request-data clause"
     foreach x [split [string tolower [HTTP::payload]] "&"] {
        if { $x starts_with "token=" } {
            set usertoken [lindex [split $x "="] 1]
        }
    }
    log local0. "User $usertoken attempted login from [IP::client_addr]:[TCP::client_port]"
} 
end of HTTP_REQUEST_DATA

when HTTP_REQUEST {
set MasterToken [class match -value "num" equals data_POC ]
    if { ([IP::addr [IP::client_addr] equals "10.255.255.4/32"]) }{
        Admin Page displayed based on source IP
        HTTP::respond 200 content "Token is $MasterToken"
         log local0. "HITTING 10.30.0.0 clause"
    } else {
         Check if request is a POST
        if { ([string tolower [HTTP::method]] eq "post" ) } {
             log local0. "HItting post clause"

            check content length is less than a 1Mb, or capture 1Mb only
            if { ([HTTP::header "Content-Length"] ne "") && ([HTTP::header "Content-Length"] <= 1048576)}{
                 log local0. "hitting content-length clause"
                set content_length [HTTP::header "Content-Length"]
            } else {
                set content_length 1048576
            }
             Check if $content_length is not set to 0
            if { $content_length > 0} {
                 log local0. "HITTING http-collect clause"
                HTTP::collect 
                this fires the HTTP_REQUEST_DATA event
            }

             Check if $gloabal_usertoken and $MAsterToken match
             if { ($usertoken eq $MasterToken) }{
                MATCH page
                HTTP::respond 200 content " MATCH $usertoken and $MasterToken "
              }
              else { 
                 NO match page
                 HTTP::respond 200 content " NO MATCH $usertoken and $MasterToken "
              }
         NO POST  data
        } else {
                HTTP::respond 200 content [ifile get "iFile_TokenPage"] 
         }
    }
}
end of HTTP_REQUEST
  • usertoken = dynamic variable that gets set in HTTP_REQUEST_DATA based on the POST field=token and it's value, and read in HTTP_REQUEST where it is compared to the Data Group value.

Interesting enough the client logic is making it to HTTP::collect

Jun 10 17:09:01 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : HItting post clause
Jun 10 17:09:01 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : hitting content-length clause
Jun 10 17:09:01 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : HITTING http-collect clause
Jun 10 17:09:02 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : HItting post clause
Jun 10 17:09:02 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : hitting content-length clause
Jun 10 17:09:02 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : HITTING http-collect clause
Jun 10 17:09:03 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : HItting post clause
Jun 10 17:09:03 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : hitting content-length clause
Jun 10 17:09:03 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : HITTING http-collect clause
Jun 10 17:09:03 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : HItting post clause
Jun 10 17:09:03 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : hitting content-length clause
Jun 10 17:09:03 deltm02 info tmm3[10524]: Rule /Common/irule_tokenPage : HITTING http-collect clause

Lastly here is the iFile_TokenPage just incase




Any help would be greatly appreciated.

  • sfuerst_116779's avatar
    sfuerst_116779
    Historic F5 Account

    HTTP::respond will immediately respond to the request. The internal state of the HTTP filter will then be the one that sinks the rest of the request data. Thus it will not collect data and trigger the HTTP_REQUEST_DATA event, since it is no longer in the collect state.

     

    You probably want to put the HTTP::respond calls into the HTTP_REQUEST_DATA event. That way they will be called after collection is complete.