Forum Discussion
STREAM::expression doesn't seem to work
- May 24, 2022
So this is the solution that we arrived at, thanks to you and your suggestion of using HTTP::header remove "Accept-Encoding". I've removed it and it fails just like before. Add it back in and everythign is working.
when HTTP_REQUEST {
HTTP::header remove "Accept-Encoding"
}when HTTP_RESPONSE {
if { [HTTP::header exists "Location"] }{
set internal_host "https://internal.com"
set external_host "https://external.com"
if { [HTTP::header "Location"] contains $internal_host } {
HTTP::header replace "Location" [string map "$internal_host $external_host" [HTTP::header "Location"]]
}
}
STREAM::disable
if { [HTTP::payload] contains "internal.com"} {
log local0. "Before if, payload contains : $[HTTP::payload]"
set oldString "internal.com"
set newString "external.com"
STREAM::expression @$oldString@$newString@@
STREAM::enable
log local0. "Before if, payload contains : $[HTTP::payload]"
}
}Something that is interesting is that I'm seeing readable payload both before and after using HTTP::header remove "Accept-Encoding" in the HTTP_REQUEST section. I can't explain it, but the important part is we have a working solution.
Thanks for all of your help, Alex! Really appreciate it!
- May 26, 2022
Hi Kevin,
Great to hear! Indeed interesting as to why this didn't work beforehand, but at least it's working now. Also thanks for posting to solution, I'm sure someone else will come across it and be happy with it as well. 😉
Well, you would still see a payload, but wouldn't make any sense. (garbled text) If you did see readable text, then compression indeed wouldn't be the issue.
Can you tell some more about the payload that you are looking into? E.g. Is it HTML/JSON/JS/etc. and the amount of data per response? And just to confirm, the text "internal.com" is indeed in the payload of the HTTP response rather than the headers?
So this is the solution that we arrived at, thanks to you and your suggestion of using HTTP::header remove "Accept-Encoding". I've removed it and it fails just like before. Add it back in and everythign is working.
when HTTP_REQUEST {
HTTP::header remove "Accept-Encoding"
}
when HTTP_RESPONSE {
if { [HTTP::header exists "Location"] }{
set internal_host "https://internal.com"
set external_host "https://external.com"
if { [HTTP::header "Location"] contains $internal_host } {
HTTP::header replace "Location" [string map "$internal_host $external_host" [HTTP::header "Location"]]
}
}
STREAM::disable
if { [HTTP::payload] contains "internal.com"} {
log local0. "Before if, payload contains : $[HTTP::payload]"
set oldString "internal.com"
set newString "external.com"
STREAM::expression @$oldString@$newString@@
STREAM::enable
log local0. "Before if, payload contains : $[HTTP::payload]"
}
}
Something that is interesting is that I'm seeing readable payload both before and after using HTTP::header remove "Accept-Encoding" in the HTTP_REQUEST section. I can't explain it, but the important part is we have a working solution.
Thanks for all of your help, Alex! Really appreciate it!
- AlexBCTMay 26, 2022Cumulonimbus
Hi Kevin,
Great to hear! Indeed interesting as to why this didn't work beforehand, but at least it's working now. Also thanks for posting to solution, I'm sure someone else will come across it and be happy with it as well. 😉
Recent Discussions
Related Content
* 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