Forum Discussion

Nicolas_Bellen1's avatar
Nicolas_Bellen1
Icon for Nimbostratus rankNimbostratus
May 31, 2011

HTTP Payload matching

I'm trying to match on a value in the HTTP payload and then insert this value into a cookie so i can use it for other purposes in future requests. However, i'm not getting any matches for HTTP_RESPONSE or HTTP_RESPONSE_DATA (i.e. it's not logging anything contained within this conditional statement). Is there something simple i'm missing here?

 

 

when HTTP_RESPONSE_DATA {

 

Log debug to /var/log/ltm? 1=yes, 0=no.

 

set debug 1

 

 

Check for the FQDN in the payload

 

 

set found [regexp "GMVM(\d)+.oasis\.local" [HTTP::payload]]

 

 

if {$found != -1 } {

 

Insert a new cookie with the old host IP name and old cookie's value

 

HTTP::cookie insert name "DRCShared_IP" value [class search CLASS equals $found]

 

 

if {$debug != 0} {

 

log local0. "$found is being replaced"

 

log local0. "[IP::client_addr]:[TCP::client_port]: Debug enabled" }

 

}

 

 

I'm seeing the the contents that i'm trying to match on referenced in the payload coming back from VIP. Any help would be appreciated.

 

 

Nick

 

  • Hi Nick,

     

     

    Are you calling HTTP::collect to tell TMM to buffer the response content? If so, can you post your HTTP_RESPONSE code? If not, can you try something like this:

     

     

    when HTTP_RESPONSE {
    
       Trigger collection for up to 1MB of data
      if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576}{
        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} {
        HTTP::collect $content_length
      }
    }
    when HTTP_RESPONSE_DATA {
       do stuff with the payload
      set payload [HTTP::payload]
    }
    

     

     

    If the app uses chunking or compression, you can use this section as well:

     

     

    when HTTP_REQUEST {
        Prevent the server from sending a compressed response
        remove the compression offerings from the client
       HTTP::header remove "Accept-Encoding"
    
        Don't allow data to be chunked
       if { [HTTP::version] eq "1.1" } {
    
           Force downgrade to HTTP 1.0, but still allow keep-alive connections.
           Since 1.1 is keep-alive by default, and 1.0 isn't,
           we need make sure the headers reflect the keep-alive status.
    
           Check if this is a keep alive connection
          if { [HTTP::header is_keepalive] } {
    
              Replace the connection header value with "Keep-Alive"
             HTTP::header replace "Connection" "Keep-Alive"
          }
    
           Set server side request version to 1.0
           This forces the server to respond without chunking
          HTTP::version "1.0"
       }
    }
    when HTTP_RESPONSE {
    
       Trigger collection for up to 1MB of data
      if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576}{
        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} {
        HTTP::collect $content_length
      }
    }
    when HTTP_RESPONSE_DATA {
       do stuff with the payload
      set payload [HTTP::payload]
    }
    

     

     

    Aaron