Forum Discussion
Editing JSON HTTP Response
Is http:// and :80 in the payload or headers?
For example, you'd normally see this in Location headers (redirects) and in payload data referencing document objects. But if in payload, it's probably better to avoid regex and just do multiple string maps.
when HTTP_RESPONSE_DATA {
set payload [string map [list "\}\}\}\}" "\}\}"] [HTTP::payload]]
set payload [string map [list "http://" "https://"] [HTTP::payload]]
set payload [string map [list ":80" ""] [HTTP::payload]]
HTTP::payload replace 0 $clen $payload $fixeddata1
HTTP::release
}
What you're doing is grabbing the existing payload into a variable, making changes to that variable, and then completely replacing the HTTP::payload with the contents of that variable.
Just to confirm that this works for you to replace the brackets?
We've just implemented this change and it still doesn't want to replace them...
- Kevin_StewartOct 19, 2022
Employee
Try this:
when HTTP_RESPONSE_DATA { log local0. "payload before: [HTTP::payload]" set payload [string map [list "\}\}\}\}" "\}\}"] [HTTP::payload]] set payload [string map [list "http://" "https://"] [HTTP::payload]] set payload [string map [list ":80" ""] [HTTP::payload]] log local0. "payload after: $payload" HTTP::payload replace 0 $clen $payload $fixeddata1 HTTP::release }
Tail the LTM log:
tail -f /var/log/ltm
And send a request. This should show you the payload before and after manipulation.
- Chris_BatesOct 20, 2022
Nimbostratus
Okay... so this was interesting...
After checking the logs both the before and after payloads did not have the 4 brackets. So somewhere else these are being added...
- Kevin_StewartOct 20, 2022
Employee
Might there be another iRule and/or device in front of this handling HTTP? Or maybe some client side JavaScript that could be modifying the response?
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