Here are a few suggestions:
when HTTP_REQUEST {
Only rewrite responses if request is a GET
if {[HTTP::method] eq "GET"}{
set rewrite_response 1
Prevent server from compressing response content if we're potentially going to rewrite it
by removing the compression offerings from the client
HTTP::header remove "Accept-Encoding"
} else {
set rewrite_response 0
}
}
when HTTP_RESPONSE {
Check if the request was a GET and the response is a text content type
if {$rewrite_response && [HTTP::header "Content-Type"] starts_with "text/"}{
Configure the find/replace for the stream filter and enable it
STREAM::expression @http://@https://@
STREAM::enable
} else {
Disable the stream filter for this response
STREAM::disable
}
}
This assumes that the server doesn't include http:// references in the redirects. If it does, you could rewrite them following the logic in this post (
Click here).
Aaron