For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Insert Content Into Server Response

Problem this snippet solves:

This iRule inserts content into a server response using HTTP::payload replace.

There are lots of examples of using HTTP::payload replace to substitute content in a server response. It can also be used to add content to the payload.

One requirement is that you add response rechunk to the http profile.

Code :

profile http profile-http-test {
  defaults from http
  response rechunk
}

# This example adds text, in the form of an HTML comment, to the payload sent to the client. The text could could easily be a variable set during the execution of the iRule.

when HTTP_RESPONSE {
  # Insert HTML comment to the top of the payload.
  HTTP::payload replace 0 0 ""
}

# Question: Don't you have to collect the HTTP data first using HTTP::collect before calling HTTP::payload replace in the HTTP_RESPONSE_DATA event? -Aaron
Published Mar 18, 2015
Version 1.0
No CommentsBe the first to comment