Hi RZ,
There isn't a way to update the content-length header in an HTTP request, so unless the original and replacement strings are the same length, I don't think you can use a stream profile and iRule to replace content in the request payload. You'd be better off collecting the payload using HTTP::collect and modifying it with HTTP::payload.
You can check the HTTP::collect wiki page for examples (
Click here). Make sure you add a check to the collection logic so that if the content-length is over 4Mb, you only collect 4Mb. If you're applying regexes to the payload, you might want to lower the collection amount to 1Mb. Failing to do so will result in a TMM crash and a complete loss of service through LTM. See the note on the wiki page for details:
Note that although any size payload can theoretically be collected, the maximum size of a Tcl variable is 4MB with a smaller functional maximum after charset expansion of approximately 1MB. Any payload manipulation outside of calls to HTTP::payload should obey that limit. The 2nd example below includes the best practice logic to enforce that limit, including the suppression of response chunking to allow more accurate determination of collect length.
Also, if it's only a small percentage of POST requests that you need to rewrite, you should try to restrict the payload collection to specific requests (either by URI, client IP, Host header, etc).
Aaron