Forum Discussion
Dayton_Gray_103
Nimbostratus
Mar 11, 2011Checking for and inserting strings into a POST
I've seen several examples of how to match and replace a string within a POST such as here. I am wondering if it is possible to search for a string in the POST data and insert it if it doesn't exist. An example string would be something like "yourID=". Is this possible?
Thanks!
3 Replies
- Michael_Yates
Nimbostratus
The short answer is Yes, you can do that.
The more complicated part of the answer depends on you search criteria. You can use a stream profile post that you referenced, but with a stream profile it will replace a string with a string.
Example: "yourID=" can be replaced with "newID="
Otherwise you will need to write an iRule that will analyze the [HTTP::uri], [HTTP::path], and/or [HTTP::query] to find what you are looking for (or what is missing) and take a specific action.
We will need a more detailed description of exactly what you are looking for to know which one you will need to use. - Dayton_Gray_103
Nimbostratus
Yeah I am not looking to replace any data I am looking to insert a field into the post that may be missing:
This iRule will need to scan POST data from /thispage.php and POST data from /overhere/thispage.php. If "&thisParam=" is not present in the POST data the iRule will need to insert "&thisParam=" to the post data.
I can see how to replace data fairly easily, but I am unsure as to how to look for data and then insert. Keep in mind that the post fields may be different every time, some may already have &thisParam= and others will not.
Thanks! - Michael_Yates
Nimbostratus
I think that you should look at this post and Wiki entry. I think that they will get you started on the detection and insertion portion of what you are needing.
http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/18/How-to-parse-a-URI.aspx
http://devcentral.f5.com/wiki/default.aspx/iRules/URI__path.html
I'm not sure if I understand what you meant by This iRule will need to scan POST data from /thispage.php and POST data from /overhere/thispage.php. I know that you can detect the incoming source page and URI, the "POST data from" part is the part I don't think that you can do. You can manipulate what you have (add, remove, modify), but I don't think you can collect data from a different page in a POST in an iRule, so I am assuming that you want to detect from "/thispage.php" and just modify the URI to post to "/overthere/thispage.php".
http://devcentral.f5.com/Forums/tabid/1082223/asg/50/showtab/groupforums/afv/topic/aff/5/aft/9545/Default.aspx
Hope this helps get you started.
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
