Forum Discussion
Optimizing redirects to avoid TCL error "Multiple redirect/respond invocations"
Greetings all: I have been cleaning up my redirects to make sure I do not redirect if the connection had already been redirected. I do see the advice to combine iRules but I refuse to make a monolithic mess versus modular iRules (the programmer in me :) ).
That being said, I have resorted to the following arrangement (and much of this comes from other tips I have read on this fantastic reference, DevCentral...)
Any iRule that has a redirect, I do the following as the first line in the HTTP_REQUEST event:
if {$gRespondOrRedirect}{ return };
Then, any iRule that does a respond or redirect, I do the following (the 500 is just one example):
set gRespondOrRedirect 1 HTTP::respond 500 noserver return
This makes sure that future iRules can test $gRespondOrRedirect and return if necessary. The return after the respond is necessary or the same iRule will keep running.
There may be other ways to do this, but that is what I came up with here. Note it occurs to be a New Feature Suggestion might be in order. With a couple small additions to the engine, the following might be possible:
In any iRule that does a redirect:
if {[HTTP::redirected]} { return };
Then, in the actual respond or redirect, the following might help:
HTTP::respond 500 noserver with_return
with_return could be an option to the respond and redirect command to return from the current script at the time of the return.
Of course, engineering gets to decide the validity of something like that to make sure it has general customer usefulness and does not break anything, but I thought I would see what the community thinks before I ask. Is there a better to accomplish this?
Thanks,
Tom Schaefer
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
