Forum Discussion

candc's avatar
candc
Icon for Cirrus rankCirrus
Jun 07, 2017

Getting current value of STREAM::expression

Am I missing something fundamental, or is it really not possible to obtain the current value of

STREAM::expression
, e.g. to append to it?

I have two iRules -- one is a 'library' rule that works for me in 99% of cases to fixup automatically-generated links derived from the real server IP/port, the other is an edge case I need for one specific site to also replace the path.

I'd like to do something like:

set pathexpr "@/oldpath@/newpath@"
if {[string length [STREAM::expression]]} { 
    STREAM::expression "[STREAM::expression] $pathexpr" 
} else {
    STREAM::expression $pathexpr 
}

I don't really want to duplicate the work of the library irule in my edge irule. I can't access the variable used by the library irule from the edge irule (it is not static).

I'd rather not change the whole library irule because it is in use in other places, but I suppose I could, if I knew where to store my expression that would be 'request-scoped' (I believe static::vars are shared by all requests, so setting in one might affect another) and accessible from across multiple irule files, e.g.:

 edge irule file
when HTTP_REQUEST {
    set pathexpr "@/oldpath@/newpath@"
    if {[info exists PLACE_WHERE_I_CAN_STORE_EXPRESSION]} { 
        set PLACE_WHERE_I_CAN_STORE_EXPRESSION "$PLACE_WHERE_I_CAN_STORE_EXPRESSION $pathexpr" 
    } else {
        set PLACE_WHERE_I_CAN_STORE_EXPRESSION $pathexpr 
    }
}

 library irule file
when HTTP_RESPONSE priority 1000 {
    if {[info exists PLACE_WHERE_I_CAN_STORE_EXPRESSION]} {
        STREAM::expression $PLACE_WHERE_I_CAN_STORE_EXPRESSION
        STREAM::enable
    }
}

So, either how do I get the current stream expression (including if it set in the GUI or updated by

STREAM::expression
); or, optionally, what is a valid
PLACE_WHERE_I_CAN_STORE_EXPRESSION
which is safe from contamination by simultaneous requests, while being accessible from multiple irule files.

No RepliesBe the first to reply