Forum Discussion
Kevan_50436
Nimbostratus
Apr 21, 2009Changing the body of a response
We have an application that builds and returns pages containing URLs as part of the response body based on how it was called. For example:
Called as: http://a.b.c.d/something/so...
hoolio
Cirrostratus
Apr 22, 2009Here 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects