Forum Discussion
Kalyan_Reddy_Da
Nimbostratus
Jul 13, 2010Can we Insert HTTP Header using HTTP Profile for a dynamic tranaction id generation
Can we Insert HTTP Header using HTTP Profile for a dynamic tranaction id generation.
Example:
The following code i am using in my irule to generate a random number for my transaction ID.
set ::transactionID [expr { int(10000000 * rand()) }]
incr ::transactionID
HTTP::header insert TRANSACTID $::transactionID
Can we achieve the same using http profile Header Insert Option?
Your help is greatly appreciated
2 Replies
- hoolio
Cirrostratus
Hi Kalyan,
You can use iRule syntax in the HTTP profile header to insert field, but I think it needs to be on a single line:
TRANSACTID [incr [expr { int(10000000 * rand()) }]]
Aaron - hoolio
Cirrostratus
I didn't test that first. It results in a runtime error as incr expects a variable--not a number:
expr { int(10000000 * rand()) }
4888651
incr 1
can't read "1": no such variable
Can you try this instead:
[expr { int(10000000 * rand()) }]
This will generate a random number for each HTTP request. It will not increment a past value, so the ID numbers won't be sequential. If you wanted to store the past value in a global variable, you'd need to use an iRule.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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