Forum Discussion

matm_58717's avatar
matm_58717
Icon for Nimbostratus rankNimbostratus
Jul 11, 2013

modify Request POST

Hello,

 

I have a web application where introduce user credential. When a client introduces your credentials, need intercept and inspect the POST, looking for the value to field "username".

 

I searched, but I don´t know if is possible to do this with iRules. ¿Have Someone an idea?

 

Thanks so much

 

 

 

3 Replies

  • have you checked HTTP::collect? you can collect http payload and take whatever action you want.

     

     

    HTTP::collect

     

    https://devcentral.f5.com/wiki/irules.HTTP__collect.ashx
  • The username, I'm guessing, is in the POST payload. Example:

    username=foo&password=bar

    So something like this might work to extract the username from that data:

    
    when HTTP_REQUEST {
         if { [HTTP::method] equals "POST" } {
              HTTP::collect [HTTP::header Content-Length]
         }
    }
    when HTTP_REQUEST_DATA {
         if { [HTTP::payload] contains "username=" } {
              foreach x [split [HTTP::payload] "&"] {
                   if { $x starts_with "username=" } {
                        set username [lindex [split $x "="] 1]
                   }
              }
         }
    }