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.


REWRITE::payload <length>
REWRITE::payload length
REWRITE::payload replace <begin> <length> <string>

REWRITE::payload <length>

  • 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 <begin> <length> <string>

  • 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.


    # 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 {<apm_do_not_touch>} $data]
    set end [string last {</apm_do_not_touch>} $data]
    # Determines the amount of characters to remove
    set length_open [string length {<apm_do_not_touch>}]
    set length_close [string length {</apm_do_not_touch>}]

    # 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 {}