Scope and integrity of local variables
I’m presently getting slightly confused about the scope of local variables and how much I can trust their integrity during evaluation even for the same event.
My understanding is that they are stored on a per connection basis:
So where there an iRule that has both an HTTP_REQUEST event as well as an HTTP_RESPONSE event :
- How much can I rely on a variable that let’s say is always set at the start of the HTTP_REQUEST event, to be available always in the HTTP_RESPONSE ?
- And as per above, always match the value it is set to from the matching request (as opposed to some other request that may have occurred under the same connection basically at the same time)?
- I’m asking this question because I was initializing a variable at the very start of HTTP_REQUEST and then in the HTTP_RESPONSE I refer to this variable at the beginning (and assume it has a value). However in a small number of cases there was an error in the log that said this variable was never set… which unsettled me a little since it’s always set in the request event…
One more question sorry!
- Is it possible for the same connection for there to be more than one request occurring at the same time (HTTP/2?)?
- And if there is, then even within the same HTTP_REQUEST event for a particular request, can I rely on the integrity of the local variables to hold during the evaluation of this event, even while there are other requests operating at the same time for a given connection?
Thanks! This will help my understanding and trust a lot in the iRule I am currently writing (which has quite a few variables)
Toni1 As long as it is considered part of the same client connection you should be fine for both of these. Again, I have never had an instance where a variable for one user was unintentionally used by a different user. When the iRule initiates for that users connection any variables should be set so I don't think you have to worry about responses not having the variable.