Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request help: request body charset - chinese error #220

Closed
fitz-97 opened this issue Dec 9, 2022 · 7 comments
Closed

request help: request body charset - chinese error #220

fitz-97 opened this issue Dec 9, 2022 · 7 comments

Comments

@fitz-97
Copy link

fitz-97 commented Dec 9, 2022

apisix-java-plugin-runner version:0.4.0
apsix version:3.0.0

Test post request contain chinese characters in OKHttp:
{ "name":"测试" }
Custom filter in apisix-java-plugin-runner, get request body:
{ "name":"æµu008Bè¯u0095" }

@fitz-97
Copy link
Author

fitz-97 commented Dec 9, 2022

in request body , Not in response

@fitz-97
Copy link
Author

fitz-97 commented Dec 9, 2022

How can I modify the character set of a request before the PluginFilter.filter() ?

@fitz-97
Copy link
Author

fitz-97 commented Dec 9, 2022

like this
{"name":"??????","nonce":"4317740522","timestamp":"1670570280","sign":"ff8eaa5caff13c78863c99d5b6b6264d"}

@tzssangglass
Copy link
Member

same as #154

@fitz-97
Copy link
Author

fitz-97 commented Dec 12, 2022

same as #154

This method doesn't seem to solve the problem. You can try it

@tzssangglass
Copy link
Member

This method doesn't seem to solve the problem. You can try it

It mainly depends on what encoding (maybe GBK?) your client is using for Chinese characters, and then use the same encoding to decode Chinese characters in java runner.

@fitz-97
Copy link
Author

fitz-97 commented Dec 13, 2022

This method doesn't seem to solve the problem. You can try it

It mainly depends on what encoding (maybe GBK?) your client is using for Chinese characters, and then use the same encoding to decode Chinese characters in java runner.

The client and code uses the same character set.
However, I found the reason because my docker did not set the character set.
when java plugin start System.getProperty("file.encoding") to be ANSI X3.4-1968 .
The startup parameter plus -Dfile.encoding=utf-8 solves the problem.
System.getProperty("file.encoding") will be utf-8 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants