Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #22 from Filter94/encoding-fix
Browse files Browse the repository at this point in the history
Kinda fixed encoding issues.
  • Loading branch information
kosteman authored Oct 26, 2017
2 parents d059df4 + 27f18a1 commit 730bd43
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public Bullet get(String url, Map<String, String> headers) throws ApiRestExcepti
}

try {
bullet = new Bullet(headersResponse, EntityUtils.toString(response.getEntity()));
bullet = new Bullet(headersResponse,
EntityUtils.toString(response.getEntity(), Props.get("api.encoding")));
} catch (IOException | ParseException ex) {
LOG.error("Error in response body get", ex);
}
Expand All @@ -100,6 +101,7 @@ public Bullet post(String url, Map<String, String> headers, Object body) throws
LOG.info("Headers are: {}", headers);

List<NameValuePair> postParams = new ArrayList<>();
String encoding = Props.get("api.encoding");
if (body instanceof Map) {
Map<String, String> params = (Map<String, String>) body;

Expand All @@ -112,7 +114,7 @@ public Bullet post(String url, Map<String, String> headers, Object body) throws
}
LOG.info("Body (form-data) is: {}", body);
} else if (body instanceof String) {
post.setEntity(new StringEntity((String) body, Props.get("api.encoding")));
post.setEntity(new StringEntity((String) body, encoding));
}

HttpResponse response = client.execute(post);
Expand All @@ -132,7 +134,7 @@ public Bullet post(String url, Map<String, String> headers, Object body) throws
}
}

return new Bullet(headersResponse, EntityUtils.toString(response.getEntity()));
return new Bullet(headersResponse, EntityUtils.toString(response.getEntity(), encoding));
} catch (IOException ex) {
LOG.error("Failed to get response", ex);
} finally {
Expand Down

0 comments on commit 730bd43

Please sign in to comment.