Skip to content

Commit

Permalink
Merge pull request #5 from DanailMinchev/fix-charset
Browse files Browse the repository at this point in the history
Fix charset: Use "UTF-8" charset instead of default "ISO-8859-1"
  • Loading branch information
thinkingserious authored Jul 8, 2016
2 parents 18aad2f + 3744be3 commit 5b26ceb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ target/
build/
gradle.properties
.gradle
repo/
repo/

# JetBrains IDEs
*.iml
**/.idea/
41 changes: 13 additions & 28 deletions src/main/java/com/sendgrid/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5b26ceb

Please sign in to comment.