Forum Discussion
kcommerce_49734
Nimbostratus
Dec 28, 2008How to replace a HTTP XML POST content with irules?
Hi all gurus,
I just wonder whether anyone could help me to share some irule example that illustrate how to replace a HTTP XML POST content . I just would like to replace some string in the content.
Client - HTTP POST -> F5 (irules) --HTTP POST-> Server
BR/
kcommerce
3 Replies
- hoolio
Cirrostratus
Hi,
You can use a blank stream profile and the following iRule to replace a string with another string in the HTTP payload of a POST request. You'll need to create a custom HTTP profile with response chunking set to rechunk. You can check the STREAM::expression wiki page (Click here)
Aaronwhen HTTP_REQUEST { Check if the request is a POST, with a content type of text if {[HTTP::method] eq "POST" && [HTTP::header value Content-Type] contains "text/xml"}{ Match the literal string "find" and replace it with "replace" STREAM::expression {@find@replace@} Enable the stream filter for this request only STREAM::enable } else { Disable the stream filter by default STREAM::disable } } when STREAM_MATCHED { This event is only included for debugging. You should remove the event after testing is complete. log local0. "[IP::client_addr]:[TCP::local_port]: matched: [STREAM::match]" } - kcommerce_49734
Nimbostratus
Hi Aaron,
Thank you for your guidance. Your suggestion is very useful to me. In addition, I just wonder how I can save the seession data for the client.
In the example below, I would like to reduce the push id length (remove 12345), however, when I return the response to the client I have to keep the the "12345" and attach the "12345" back in the response. How do I use a regular expression to match and save "12345" as a session data, and how could I response back to the client.
Any idea please let me know.
Example:
Client --------(HTTP POST A)---> IRules/F5 -------------(HTTP POST B) ----> Server
Client <-------(HTTP RES A) -------IRules/F5 <---------- (HTTP RES B) -------- Server
HTTP POST A:
DATA
HTTP RESP A:
success
HTTP POST B:
DATA
HTTP RESP B:
success - hoolio
Cirrostratus
That should be possible using the STREAM_MATCHED event to modify the stream replacement.
Is 12345 always the first five characters of the push-id value? Does the format for the string to modify change ever (ie, is it always push-id="value" with the same capitalization and spacing)?
Thanks,
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
