ltm rule command REWRITE payloadΒΆ

iRule(1)		      BIG-IP TMSH Manual		      iRule(1)



REWRITE::payload
       Queries for or manipulates REWRITE payload.

SYNOPSIS
       REWRITE::payload (LENGTH | (OFFSET LENGTH))?

       REWRITE::payload length

       REWRITE::payload replace OFFSET LENGTH PAYLOAD

DESCRIPTION
       Queries for or manipulates REWRITE payload (content) information. With
       this command, you can retrieve content, query for content size, or
       replace a certain amount of content.

       Syntax

       REWRITE::payload 

	    * Returns the entire payload or up to the length in bytes. If you do
	      not specify a size, the system returns the entire collected
	      content.

       REWRITE::payload length

	    * Returns the size of the content.

       REWRITE::payload replace   

	    * Replaces the amount of content that you specified with the
	      argument, starting at with , adjusting the Content-Length header
	      appropriately. To clarify, the length argument should be the length
	      of original content to replace.

RETURN VALUE
VALID DURING
       REWRITE_REQUEST_DONE, REWRITE_RESPONSE_DONE

EXAMPLES
	when REWRITE_RESPONSE_DONE {
	    # The rewrite_response_done event isn't absolutely necessary because browser will just ignore any html tags that it doesn't recongnize.
	    # However, it will be cleaner if we remove it nevertheless

	    set data [REWRITE::payload]
	    # Find the tags we inserted
	    set start [string first {} $data]
	    set end [string last {} $data]
	    # Determines the amount of characters to remove
	    set length_open [string length {}]
	    set length_close [string length {}]

	    # log local0. "Starting Index:: $start"
	    # log local0. "Ending Index:: $end"

	    # Replace the number of characters taken up by the tags with nothing (e.g. null)
	    REWRITE::payload replace $end $length_close {}
	    REWRITE::payload replace $start $length_open {}
	}

HINTS
SEE ALSO
CHANGE LOG
       @BIGIP-10.2.1 --First introduced the command.



BIG-IP				  2017-01-31			      iRule(1)