Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/http/requests/PostRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void addData(String key, String value)
public void addData(String json)
{
try{
stringEntity = new StringEntity(json);
stringEntity = new StringEntity(json, encoding);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this variable defined anywhere? Seems like it might be missing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late answer, I'm not much on github.
encoding is a class member variable and set in the constructor.
If one uses addData(String key, String value), then the added value will be encoded using this class member variable encoding during send() (in line 100). However, if one sets the json directly using addData(String json), the string will be added to the request without using encoding (line 117). In my own code, I therefore added the encoding directly when setting stringEntity. Otherwise, any UTF-8 characters (like umlauts) won't be sent correctly. Alternatively, you can apply the encoding in send() as well. Without this fix, the class advertises to use an encoding which is not actually used everywhere.

} catch( Exception e ) {
e.printStackTrace();
}
Expand Down