Skip to content

Commit

Permalink
Merge pull request #1 from D3DXInitPerDX/fix/json-encoding
Browse files Browse the repository at this point in the history
Set request body encoding to UTF-8 to comply to the JSON specification
  • Loading branch information
G1org1owo authored Jan 12, 2024
2 parents 78cc8b7 + 78ee91a commit 78235db
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/jszuru/SzurubooruAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -217,7 +218,7 @@ public Map<String, Object> call(String method,
httpRequest.setHeader("Content", "application/json");

if(body!=null && httpRequest instanceof HttpEntityEnclosingRequest sendRequest){
sendRequest.setEntity(new StringEntity(gson.toJson(body)));
sendRequest.setEntity(new StringEntity(gson.toJson(body), ContentType.APPLICATION_JSON));
}

HttpResponse response = httpClient.execute((HttpUriRequest) httpRequest);
Expand Down

0 comments on commit 78235db

Please sign in to comment.