Skip to content

Commit 150738a

Browse files
author
akankari
committed
Use "utf-8" encoding for StringEntity
1 parent afd923d commit 150738a

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/net/authorize/util/HttpClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private static HttpPost createHttpPost(Environment env, Transaction transaction)
8585
httpPost.getParams().setIntParameter(HttpConnectionParams.SO_TIMEOUT, httpReadTimeout);
8686

8787
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
88-
httpPost.setEntity(new StringEntity(transaction.toNVPString()));
88+
httpPost.setEntity(new StringEntity(transaction.toNVPString(), HTTP.UTF_8));
8989
} else if (transaction instanceof net.authorize.arb.Transaction ||
9090
transaction instanceof net.authorize.cim.Transaction ||
9191
transaction instanceof net.authorize.reporting.Transaction) {
@@ -100,7 +100,7 @@ private static HttpPost createHttpPost(Environment env, Transaction transaction)
100100
httpPost.getParams().setIntParameter(HttpConnectionParams.SO_TIMEOUT, httpReadTimeout);
101101

102102
httpPost.setHeader("Content-Type", "text/xml; charset=utf-8");
103-
httpPost.setEntity(new StringEntity(transaction.toXMLString()));
103+
httpPost.setEntity(new StringEntity(transaction.toXMLString(), HTTP.UTF_8));
104104
}
105105

106106
return httpPost;

src/main/java/net/authorize/util/HttpUtility.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.http.entity.StringEntity;
2222
import org.apache.http.params.CoreProtocolPNames;
2323
import org.apache.http.params.HttpConnectionParams;
24+
import org.apache.http.protocol.HTTP;
2425

2526
import net.authorize.Environment;
2627
import net.authorize.api.contract.v1.ANetApiRequest;
@@ -81,7 +82,7 @@ static HttpPost createPostRequest(Environment env, ANetApiRequest request) throw
8182

8283
String xmlRequest = XmlUtility.getXml(request);
8384
logger.debug(String.format("Request: '%s%s%s'", LogHelper.LineSeparator, xmlRequest, LogHelper.LineSeparator));
84-
httpPost.setEntity(new StringEntity(xmlRequest));
85+
httpPost.setEntity(new StringEntity(xmlRequest, HTTP.UTF_8));
8586
}
8687

8788
return httpPost;

0 commit comments

Comments
 (0)