Forum Discussion
Andrew_Bretten_
Nimbostratus
Oct 29, 2006payload replace fails against content from .jsp ?
I have the following iRule appled to a virtual server
when HTTP_RESPONSE_DATA {
set find "http://"
set replace "https://"
set payload [HTTP::payload]
if {[regsub ...
Andrew_Bretten_
Nimbostratus
Nov 02, 2006Ok....here's what I ended up with. From another thread, I found I can multiple match/replaces in a stream profile.
Simply, create a stream profile, leave source empty....put this in destination.
searchreplacesearch replacesearchreplace
The seperator () can be anything, whatever the first character is, is assumed to be the seperator.
This is much faster and simlier than trying to force an iRule to parse the entire HTTP response.
I did however also found a good link on how to load the complete HTTP response, which was the first problem I had with my iRule.
However, even after fixing that....the iRule still does not rewrite every single http:// link in the document, and I'm sick of debugging it.....The stream profile works great.
Here's the iRule I ended up with (but by no means 100% working).
when HTTP_REQUEST {
Don't allow data to be chunked.
if {[HTTP::version] == "1.1"} {
if {[HTTP::header is_keepalive]} {
Adjust the Connection header.
HTTP::header replace "Connection" "Keep-Alive"
}
HTTP::version "1.0"
}
}
when HTTP_RESPONSE {
if {[HTTP::header exists "Content-Length"]} {
set content_len [HTTP::header "Content-Length"]
} else {
set content_len 4294967295
}
if { $content_len > 0 } {
HTTP::collect $content_len
}
}
when HTTP_RESPONSE_DATA {
set payload [HTTP::payload]
set length [HTTP::payload length]
set new_payload [string map {http://tp https://tp} $payload]
if { $new_payload ne $payload } {
Replace the content if there was any matches
HTTP::payload replace 0 $length $new_payload
}
}
Andy
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