You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.
While integrating the hipchat-api library, I noticed an encoding issue and opened viascom/hipchat-api#30. However, digging deeper shows that the problem is caused by FoxHttp... so I'm opening an issue here as well.
Here's the problem: if the request contains a non-ASCII character in its body, the character will not be properly encoded.
The culprit is the following method: ch.viascom.groundwork.foxhttp.body.request.FoxHttpRequestBody#writeBody
DataOutputStream wr = new DataOutputStream(outputStream);
wr.writeBytes(json);
And here's the javadoc of java.io.DataOutputStream#writeBytes:
Writes out the string to the underlying output stream as a
sequence of bytes. Each character in the string is written out, in
sequence, by discarding its high eight bits. If no exception is
thrown, the counter written is incremented by the
length of s.
Since internally writeBytes(String) calls charAt, it does not support UTF-8, which is why the character is not properly encoded in the request.
The text was updated successfully, but these errors were encountered:
Thanks for your bug report. Your analysis on viascom/hipchat-api#30 is very nice and will help a lot. I will check our code and fix this bug as soon as possible.
- Add Charset support to FoxHttpRequestBody
- Add new annotation SerializeContentType which allows to set the content type in interface, method or model level
- Update unit test to check for correct encoding
While integrating the hipchat-api library, I noticed an encoding issue and opened viascom/hipchat-api#30. However, digging deeper shows that the problem is caused by FoxHttp... so I'm opening an issue here as well.
Here's the problem: if the request contains a non-ASCII character in its body, the character will not be properly encoded.
The culprit is the following method:
ch.viascom.groundwork.foxhttp.body.request.FoxHttpRequestBody#writeBody
And here's the javadoc of
java.io.DataOutputStream#writeBytes
:Since internally
writeBytes(String)
callscharAt
, it does not support UTF-8, which is why the character is not properly encoded in the request.The text was updated successfully, but these errors were encountered: