Thornid
Sep 13, 2019Nimbostratus
Modify HTTP Payload in Response Question
Hello all
We have a requirement to modify the <HEAD> HTML tag in responses for a specific URL. I've been looking around trying to piece bits together but not having too much luck in the lab.
My understanding is to use the HTTP::collect to collect response data then access that data via the HTTP::payload command. I found an example online which I have attempt to butcher with no luck, as below. Hoping for some guidance.
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/home"}{
continue }
}
when HTTP_RESPONSE {
HTTP::collect [expr 1024*1024]
}
when HTTP_RESPONSE_DATA {
set find "<HEAD>"
set replace "<HEAD> SOME_OTHER_DATA"
if {[ regsub -all $find [HTTP::payload] $replace new_response] > 0} {
HTTP::payload replace 0 [HTTP::payload length] $new_response
}
}
Thank you.