Forum Discussion

JSpartan0901_95's avatar
Icon for Nimbostratus rankNimbostratus
Mar 08, 2012

Ability to correlate HTTP response to a HTTP request in iRules




We have a requirement to perform certain operations on HTTP response only for specific HTTP requests. Is there any way I can correlate a response to a request in iRules?







3 Replies

  • Hi J,

    You can set a variable in HTTP_REQUEST and check for it in HTTP_RESPONSE event:

    when HTTP_REQUEST {
    if {$some_check==1}{
    set check_response 1
    } else {
    set check_response 0
    when HTTP_RESPONSE {
    if {$check_response==1}{
     do something

  • Thanks, Aaron. I am novice in iRules.



    Is this thread safe? Does it work for concurrent requests from multiple clients?
  • Yes, local variables are tied to a connection. Global variables (those set using 'set ::my_var value' in any non-RULE_INIT event or those set as 'set my_var value' or 'set ::my_var value' in RULE_INIT) are available across all connections. SMP summarized this nicely in this post. It's relevant for v10 and v11.



    v10 - local vs. global vars