From 4670e2daa6c10f425edbb338cef2e49604d6498e Mon Sep 17 00:00:00 2001 From: Danail Date: Thu, 30 Jun 2016 14:50:42 +0100 Subject: [PATCH 1/2] Added JetBrains IDEs to .gitignore --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2a6854d..2f46584 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,8 @@ target/ build/ gradle.properties .gradle -repo/ \ No newline at end of file +repo/ + +# JetBrains IDEs +*.iml +**/.idea/ From 3744be3e5770693fab1ea910fc40d0e8f97f2679 Mon Sep 17 00:00:00 2001 From: Danail Date: Thu, 30 Jun 2016 15:07:10 +0100 Subject: [PATCH 2/2] Use "UTF-8" charset instead of default "ISO-8859-1" --- src/main/java/com/sendgrid/Client.java | 41 ++++++++------------------ 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/sendgrid/Client.java b/src/main/java/com/sendgrid/Client.java index 9a0c2f1..6179d7f 100644 --- a/src/main/java/com/sendgrid/Client.java +++ b/src/main/java/com/sendgrid/Client.java @@ -30,6 +30,7 @@ import java.net.URISyntaxException; import java.net.URLEncoder; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -206,13 +207,9 @@ public Response post(Request request) throws URISyntaxException, IOException { } } - try { - httpPost.setEntity(new StringEntity(request.body)); - if (request.body != "") { - httpPost.setHeader("Content-Type", "application/json"); - } - } catch (IOException ex) { - throw ex; + httpPost.setEntity(new StringEntity(request.body, Charset.forName("UTF-8"))); + if (request.body != "") { + httpPost.setHeader("Content-Type", "application/json"); } try { @@ -252,13 +249,9 @@ public Response patch(Request request) throws URISyntaxException, IOException { } } - try { - httpPatch.setEntity(new StringEntity(request.body)); - if (request.body != "") { - httpPatch.setHeader("Content-Type", "application/json"); - } - } catch (IOException ex) { - throw ex; + httpPatch.setEntity(new StringEntity(request.body, Charset.forName("UTF-8"))); + if (request.body != "") { + httpPatch.setHeader("Content-Type", "application/json"); } try { @@ -299,13 +292,9 @@ public Response put(Request request) throws URISyntaxException, IOException { } - try { - httpPut.setEntity(new StringEntity(request.body)); - if (request.body != "") { - httpPut.setHeader("Content-Type", "application/json"); - } - } catch (IOException ex) { - throw ex; + httpPut.setEntity(new StringEntity(request.body, Charset.forName("UTF-8"))); + if (request.body != "") { + httpPut.setHeader("Content-Type", "application/json"); } try { @@ -345,13 +334,9 @@ public Response delete(Request request) throws URISyntaxException, IOException { } } - try { - httpDelete.setEntity(new StringEntity(request.body)); - if (request.body != "") { - httpDelete.setHeader("Content-Type", "application/json"); - } - } catch (IOException ex) { - throw ex; + httpDelete.setEntity(new StringEntity(request.body, Charset.forName("UTF-8"))); + if (request.body != "") { + httpDelete.setHeader("Content-Type", "application/json"); } try {