Forum Discussion
Store variable from STREAM::expression and use in HTTP_RESPONSE context
I've been looking for a way to store the stream matched hostname in a HREF from a HTML stream.
As I rewrite the content from internal domain to external domain using the stream filter I also need to store a portion of the rewritten value, as a cookie, and pass it on to the client so that when they return to the HREF'd location I can persist to the origin node (which is only identified through the HREF not through a direct or even proxied connection).
All and any advice appreciated!
Cheers,
Comms
- hoolioCirrostratusHi Comms,
- commsmonkey_172NimbostratusHi Aaron,
when STREAM_MATCHED { set myVar [string tolower [getfield [STREAM::match] "." 1]] log local0.emerg " myVar variable is $ myVar" } when HTTP_REQUEST { Disable the stream filter for all requests via VS STREAM::disable } when HTTP_RESPONSE { Disable the stream filter by default STREAM::disable Enable the stream filter for text responses only if {[HTTP::header value Content-Type] contains "text"}{ STREAM::expression {@string@replacementstring@} Enable the stream filter for this response only log local0.emerg "Passed stream expression" STREAM::enable log local0.emerg "variable $myVar is set now" } if {$myVar contains "string"}{ Set Cookie value value to 'string' found by the Stream filter log local0.emerg "Setting new persist Cookie" HTTP::cookie insert name "myCookie" value $myVar path "/" log local0.emerg "Cookie Set and Inserted" } }
- commsmonkey_172NimbostratusThe context error:
- nitassEmployeei got this error.
- commsmonkey_172NimbostratusHi Nitass,
- hoolioCirrostratusAs Nitass said, HTTP_RESPONSE is triggered when the HTTP response headers from the pool member are parsed. The stream filter is applied after this event. The response headers have already been unbuffered and sent to the client by STREAM_MATCHED.
- commsmonkey_172NimbostratusHi Hoolio,
When STREAM_MATCHED { Insert $myVar to the URI component of the HREF following the junction /Junction/ for subsequent ingress processing set myVar [string tolower [getfield [STREAM::match] "." 1]] STREAM::replace "external.domain.name/Junction/$myVar/" }when HTTP_REQUEST { Disable the stream filter for all requests via VS STREAM::disable Check URI for part of myVar (nodename01 to nodename19) if {[HTTP::uri] contains "nodename"}{ set myVarCookie [getfield [HTTP::uri] "/" 3] Set & Insert Cookie for processing HTTP::cookie insert name "EV" value $myVar path "/" Redirect client for processing by the Internal VS ideally the preceding / needs to be removed after myVar as well HTTP::redirect [string map {$myVar ""} [HTTP::uri]] } } when HTTP_RESPONSE { Disable the stream filter by default STREAM::disable Enable the stream filter for text responses only if {[HTTP::header value Content-Type] contains "text"}{ Find the value I want to change, but manage change in STREAM_MATCHED STREAM::expression {@string@@} Enable the stream filter for this response only STREAM::enable } }
- hoolioCirrostratusWhat are you trying to do? When you say it's not working, what is or isn't happening?
- commsmonkey_172NimbostratusThanks Hoolio, that makes sense.
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