-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Use charset of request to create the String content. #1571
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, still need unti test for the change
@@ -135,7 +135,12 @@ ClassicHttpRequest toClassicHttpRequest(Request request, Request.Options options | |||
entity = new ByteArrayEntity(data, null); | |||
} else { | |||
final ContentType contentType = getContentType(request); | |||
entity = new StringEntity(new String(data), contentType); | |||
if (request.charset() != null) { | |||
String content = new String(request.body(), request.charset()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use data
instead?
if not, need a comment explaining why need to use request.body()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
entity = new StringEntity(new String(data), contentType); | ||
if (request.charset() != null) { | ||
String content = new String(request.body(), request.charset()); | ||
entity = new StringEntity(content, contentType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this line outside the if, and let the if block just handle the String content
creation?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Any chance of we having a unit test around this change? |
I don't know how to manipulate the request.charset() to return a changed encoding, and I don't know how to change the default for a single test. The issue happens if e.g. the client has default charset ISO_8859_1 and the server has UTF_8. |
Co-authored-by: Marvin Froeder <[email protected]>
Co-authored-by: Marvin Froeder <[email protected]>
This PR fixes #1570