Forum Discussion
Russell_E_Glaue
Nimbostratus
Feb 18, 2009How to disable iRule processing on keep-alive per request when using HTTP::respond
How to disable iRule processing on keep-alive per request when using HTTP::respond
Okay, I have encountered a problem I cannot figure out how to get around.
Here is what I want to do:
1) First of all I want to keep the keep-alive connection open - I do not want to close it.
2) The web user connects to the IP for a web site and sends a request
3) the iRule catches something in the request, and send back a response via "HTTP::respond"
4) the iRule execute "event HTTP_REQUEST disable" to stop further iRule processing (important) of HTTP_REQUEST.
5) the keep-alive connection remains open
6) some how the iRule processing is enabled again for the HTTP_REQUEST event.
7) on the next web user's http request, the same iRule(s) is processed.
How do I do this?
*) I do not see how 6 can be possible, while keeping the keep-alive connection open, from everything I have read about how iRules work.
When we use HTTP::respond, the HTTP_RESPONSE event is never processed in the iRules (which is where it has been recommended to execute the "event enable" command), plus I do not see any other events being processed.
My question may be, how can I reenable the HTTP_REQUEST event for the next request on the same keep-alive connection?
But perhaps it should be, how do I turn off iRule processing on a per-request basis when using HTTP::respond?
My goal is to:
1) use the HTTP::respond - immediately returning the response to the web user
2) keep the keep-alive connection open
3) do not process any further iRules
4) allow the web user to send another request on the same keep-alive connection.
5) have the iRules process the new request coming across the same keep-alive connection from the web user.
6) be able to go back to 1 and continue this loop indefinitely.
What does NOT work:
1) the "return" command - it returns, but further iRules are still processed.
2) the "event disable" command - it disables iRules for any future events on the same keep-alive connection, and if you use HTTP::respond, then you have no opportunity to execute "event enable" at the end of the request so iRules will process the next request.
3) the "reject", "TCP::close", or other commands that close the keep-alive connection - I do not want to close the connection.
4) using global variables as flags for determining it further iRules should be processed - according to this article ( http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=236 ) "a global variable ... [is] shared by all connections"
Would anyone know what I can do to resolve this?
-RG
- hoolio
Cirrostratus
Hi RG, - Russell_E_Glaue
Nimbostratus
Using local variables - Can you provide an example, because I tried a local variable and it did not work.irule firstirule { when HTTP_REQUEST priority 10 { set localVar "somevalue" } } irule secondirule { when HTTP_REQUEST priority 100 { if { not [info exists $localVar] } { log local0.err "Variable localVar not available. Initialized in iRule firstirule." } } }
- hoolio
Cirrostratus
info exists expects the variable name without the $: - Russell_E_Glaue
Nimbostratus
Okay,rule any_irule { when ?event? { if { not $stop_processing_irules_flag } { normal iRule code } } }
- hoolio
Cirrostratus
Not that I can think of. Anyone else have any ideas?when HTTP_REQUEST { log local0. "500 disabling" event HTTP_REQUEST disable log local0. "500 disabled" } when HTTP_REQUEST priority 501 { log local0. "501?" }
- Russell_E_Glaue
Nimbostratus
I was actually thinking of a few new feature possibilities.event [] [enable|disable] | [enable all|disable all]
event [] [enable|disable] | [enable all|disable all] [forthisconnection|forthisrequest]
event [] [enable|skip|disable] | [enable all|disable all]
- Russell_E_Glaue
Nimbostratus
Actually the second suggestion is probably better as:event [] [enable|disable|end] | [enable all|disable all]
- spark_86682Historic F5 AccountThe only better thing I can think of is to do a return if that flag is set.
rule first_rule { when HTTP_REQUEST { set stop_processing 0 if { $condition } { HTTP::respond "foo" set stop_processing 1 } } } rule second_rule { when HTTP_REQUEST { if { $stop_processing } { return } do other stuff here } }
- Russell_E_Glaue
Nimbostratus
- hoolio
Cirrostratus
Hi RG,
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