Forum Discussion
Keep encoding when request is handled by irule
Can you pare down your irule to the simplest operation that causes the problem and post it, along with a curl command to reproduce the results? Chrome Browser Dev Tools now allows you to right-click and network request and select "Copy as cURL" to make this very easy.
Dealing with encoding issues and iRules can sometimes be troublesome. Additionally, the behavior can change with dynamic conditions like response chunking and compression. The best way to handle these is with a good reproducible test case.
During troubleshooting I did simples possible condition to replicate issue also for other endpoint. As I received report for specific endpoint where custom irule was written I covered another endpoint to replicate issue. And it's behave same. Below is part of irule.
when HTTP_REQUEST {
catch {
if { [HTTP::uri] starts_with "/api/test/endpoint" } {
log local0. "DEBUG: Edit URL detected"
set UrlEdit 1
}
}
if { [HTTP::header value Content-Length] > 0 } then {
log local0. "DEBUG: myapp - collecting data for edit URL"
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_REQUEST_DATA {
catch {
if { $UrlEdit } {
#set editpayload [HTTP::payload]
#binary scan $editpayload [HTTP::payload]
#HTTP::payload replace 0 [HTTP::header "Content-Length"] $editpayload
log local0. "DEBUG: myapp: edit page detected with payload: $editpayload"
HTTP::release
}
}
}
Part of the payload is:
--data-raw '{"customer":{"name":"漢字__字汉__"
There is no compression. Only small payload is forwarded.
At the end in application is string with Chinese characters represent as æ¼¢å—å—汉
If we take first character 漢 in UTF-8 it is 0xE6 0xBC 0xA2 what is converted back as E6 (æ) + BC (¼) + A2(¢). In summary 漢 = æ¼¢.
Adding also part of the log from ltm. Characters were already converted:
{"customer":{"name":"æ¼¢å�__å�æ±�__
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