Forum Discussion
Dachicourt_Fabi
Nimbostratus
Jan 10, 2005Add multiple content on mutliple match in DATA RESPONSE
Hello,
i want redirect all images (under image folder that call relativly in code) of my web site directly by modifying the http answer without modify the code, i write this :
when HTTP_RESPONSE {
set clen [HTTP::header Content-Length]
if {$clen > 0} {
HTTP::collect $clen
}
}
when HTTP_RESPONSE_DATA {
set found [string first "images/" [HTTP::payload $clen] $x]
HTTP::payload replace $found 0 [binary format "A*" "http/195.6.184/"]
}
and that work but only for may first image. So i write this to do on all images without succes :
when HTTP_RESPONSE {
set clen [HTTP::header Content-Length]
if {$clen > 0} {
HTTP::collect $clen
}
}
when HTTP_RESPONSE_DATA {
set last [string last "images/" [HTTP::payload $clen] ]
for {set x 0} {$x<$last} {}
{
incr x
set found [string first "images/" [HTTP::payload $clen] $x]
HTTP::payload replace $found 0 [binary format "A*" "http/195.6.184/"]
set x $found
}
}
have you any idea that i doing wrong ?
5 Replies
- unRuleY_95363Historic F5 AccountI tried the following rule and it works fine for me using 9.0.3 (it could be something we fixed in 9.0.3):
rule image_replace { when HTTP_RESPONSE { set clen [HTTP::header Content-Length] if { $clen > 0 } { HTTP::collect $clen } } when HTTP_RESPONSE_DATA { set last [string last "images/" [HTTP::payload $clen]] for {set found 0} {$found < $last} {incr found 22} { set found [string first "images/" [HTTP::payload $clen] $found] HTTP::payload replace $found 0 "http/195.6.184" } } }
profile stream image_replace { source "images/" target "http/195.6.184/images/" } virtual my_vip { destination a.b.c.d:80 ip protocol tcp profile http tcp profile image_replace serverside snat automap ... }
- Dachicourt_Fabi
Nimbostratus
i have try both the irules and the stream profile. - unRuleY_95363Historic F5 AccountIs using the stream profile going to work ok for you, or would you like us to continue to help with what's going on in your rule?
- costinvilcu_103
Nimbostratus
Hello, - JRahm
Admin
Yes, you can do this with a stream profile, no iRule required. Make sure you have chunking set to rechunk in your http profile.
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