Forum Discussion
hooleylist
Feb 03, 2010Cirrostratus
When you call STREAM::enable it enables the stream filter until STREAM::disable is called or the connection is closed. So you want to disable the stream filter on each response by default. Then enable it for the specific responses you want to rewrite.
Can you try this?
when HTTP_REQUEST {
Save the URI so we can check it in the response
set uri [string tolower [HTTP::uri]]
set host [string tolower [HTTP::host]]
set repl "qa1"
}
when HTTP_RESPONSE {
Disable the stream filter by default
STREAM::disable
if { [HTTP::status] == 200 } {
Use a stream expression to replace content within the stream
IF... we are dealing with text content THEN
if {[HTTP::header value Content-Type] contains "text"} {
set stream_expression "@www.blah.com@$repl.blah.com@"
set stream_find ""
set stream_find_lower [string tolower $stream_find]
set stream_repl ""
set stream_repl_google_include "http://www.google-analytics.com/ga.js"
set InjectScript 1
log local0.debug "checking $uri"
switch -glob $uri {
"*.ashx*" -
"*.asmx*" -
"*.axd*" -
"*.js*" -
"*/player/html" {
set InjectScript 0
}
}
if { [TCP::server_port] == 443 }{
set InjectScript 0
set stream_repl_google_include "https://ssl.google-analytics.com/ga.js"
}
if { [HTTP::payload] contains "META HTTP-EQUIV=\"Refresh\""} {
set InjectScript 0
}
if {$InjectScript == 1} {
set include_js "infobarhandler.ashx"
append stream_repl ""
}
Google analytics for all text pages
append stream_repl ""
append stream_expression " @$stream_find@$stream_repl$stream_find@"
append stream_expression " @$stream_find_lower@$stream_repl$stream_find_lower@"
STREAM::expression $stream_expression
STREAM::enable
}
}
}
Aaron