Skip to content

Commit 4f273e9

Browse files
committed
Fix Response Charset to UTF-8.
patch for issue sendgrid#6
1 parent d651997 commit 4f273e9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/sendgrid/Client.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.apache.http.Header;
44
import org.apache.http.annotation.NotThreadSafe;
5-
import org.apache.http.client.ResponseHandler;
65
import org.apache.http.client.methods.CloseableHttpResponse;
76
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
87
import org.apache.http.client.methods.HttpDelete;
@@ -31,10 +30,12 @@
3130
import java.net.URLEncoder;
3231

3332
import java.nio.charset.Charset;
33+
import java.nio.charset.StandardCharsets;
3434
import java.util.HashMap;
3535
import java.util.List;
3636
import java.util.Map;
3737
import java.util.Scanner;
38+
import org.apache.http.util.EntityUtils;
3839

3940
// Hack to get DELETE to accept a request body
4041
@NotThreadSafe
@@ -129,13 +130,12 @@ public URI buildUri(String baseUri, String endpoint, Map<String,String> queryPar
129130
* @param response from a call to a CloseableHttpClient
130131
*/
131132
public Response getResponse(CloseableHttpResponse response) throws IOException {
132-
ResponseHandler<String> handler = new BasicResponseHandler();
133133
String responseBody = "";
134134

135135
int statusCode = response.getStatusLine().getStatusCode();
136136

137137
try {
138-
responseBody = handler.handleResponse(response);
138+
responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
139139
} catch (IOException ex) {
140140
throw ex;
141141
}

0 commit comments

Comments
 (0)