Forum Discussion
hooleylist
Jan 11, 2012Cirrostratus
Here's an example which uses a stream profile to rewrite the response headers and/or payload to https://:
when HTTP_REQUEST {
Save the requested host value
set host [string tolower [HTTP::host]]
Disable the stream filter by default
STREAM::disable
}
when HTTP_RESPONSE {
Check if response type is text and host isn't null
if {[HTTP::header value Content-Type] contains "text" and $host ne ""}{
Replace http://$host with https://$host
STREAM::expression "@http://$host@https://$host@"
Enable the stream filter for this response only
STREAM::enable
}
Rewrite the Location header in redirects to https://
if { [HTTP::is_redirect] && [string tolower [HTTP::header Location]] starts_with "http://$host"} {
HTTP::header replace Location [string map -nocase "http://$host https://$host" [HTTP::header Location]]
}
}
Aaron