Forum Discussion

Thinkfast_12947's avatar
Thinkfast_12947
Icon for Nimbostratus rankNimbostratus
Aug 15, 2013

Does http::payload replace work on the http request?

Hi,

 

All the payload replace examples I have seen have to do with outbound traffic. (Eg: mask credit card numbers).

 

Does the payload replace functionality also work for inbound traffic?

 

Does anyone know of any examples?

 

Thanks TF

 

5 Replies

  • i dont believe so, there is not actual http payload in a http request, just the request and the headers i believe. so there is no need to change something here right?

     

    do you have a specific situation you want to tackle?

     

  • HTTP POSTs contain HTTP payloads, although in most use cases it's the HTTP headers that most customers want replaced.

     

  • You can replace ANY HTTP request payload in the same manner as response payload.

    HTTP::payload replace 0 [HTTP::header Content-Length] "blah-blah-blah"
    
  • As Kevin said, this certainly is possible: Here's an example from the HTTP::collect wiki page. You can also check the HTTP::payload wiki page for more info on doing the payload replacement: https://devcentral.f5.com/wiki/iRules.http__collect.ashx https://devcentral.f5.com/wiki/iRules.http__payload.ashx

    From https://devcentral.f5.com/wiki/iRules.http__collect.ashx
     Collect a request payload
    when HTTP_REQUEST {
    
      if {[HTTP::method] eq "POST"}{
         Trigger collection for up to 1MB of data
        if {[HTTP::header "Content-Length"] ne "" && [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_REQUEST_DATA {
       do stuff with the payload
      set payload [HTTP::payload]
    }