Forum Discussion

Brian_Herr_1028's avatar
Brian_Herr_1028
Icon for Nimbostratus rankNimbostratus
Nov 20, 2009

Manipulate a HTTP:path then continue to parse iRule

We are trying modify an existing iRule where we currently rewrite the HTTP:path to a new one. We would like to do the rewrite and then continue to evaluate the rest of the iRule with the new path. My understanding is that once the path is rewritten it would stop executing the iRule as it has matched a condition. My current idea is to have another iRule that would execute in the same event but with a higher priority to change the path first. The eval the current iRule as is with the new path set. If anyone can shed some light on a way to do it within one iRule it would be appreciated.

2 Replies

  • For the most part, multiple iRules on the same VIP are all executed regardless of what happens in previous ones. The obvious exceptions to this I can think of are HTTP_RESPONSE not running if the request is responded to in HTTP_REQUEST or if you explicitly disable events using 'event disable'.

     

     

    One issue you might have is that most HTTP commands (like HTTP::path, HTTP::uri, etc) are cached in the same event and event priority. So if you log the HTTP::path value, modify it and then log it again, the change is not shown. You could just save the modified value of HTTP::path and reference that instead though. Or you could add subsequent code to another HTTP_REQUEST event with a higher priority that would run after the first rule. But I think using a variable in one HTTP_REQUEST event is probably easier.

     

     

     
      This demonstrates the caching of the HTTP::path value 
     when HTTP_REQUEST { 
      
        log local0. "(priority 500) Current \[HTTP::path\] value [HTTP::path]" 
        HTTP::path "/new_path" 
        log local0. "(priority 500) Current \[HTTP::path\] value [HTTP::path]" 
     } 
     when HTTP_REQUEST priority 501 { 
      
        log local0. "(priority 501) Current \[HTTP::path\] value [HTTP::path]" 
     } 
     

     

     

    Here is a workaround for using one HTTP_REQUEST event:

     

     

     
     when HTTP_REQUEST { 
      
        set path [HTTP::path] 
        log local0. "Current \$path value $path" 
      
        set path "/new_path" 
        HTTP::path $path 
      
        log local0. "Current \$path value $path" 
     } 
     

     

     

    Aaron
  • Hi Brian,

     

     

    Here is a article on Priority as well

     

    http://devcentral.f5.com/Wiki/default.aspx/iRules/priority.html

     

     

    Bhattman