Permalink
Browse files

Bugfix: pass encoding ("utf8") when creating StringEntity

Otherwise you will get error messages about invalid UTF-8 JSON
from CouchDB.
  • Loading branch information...
1 parent 49ea5f4 commit 1beee992f3f921e55415f7b2a4135016d906c992 @stapelberg stapelberg committed Oct 14, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/se/msc/android/droidcouch/DroidCouch.java
@@ -71,7 +71,7 @@ public static String createDocument(String hostUrl, String databaseName,
try {
HttpPut httpPutRequest = new HttpPut(hostUrl + databaseName + "/"
+ docId);
- StringEntity body = new StringEntity(jsonDoc.toString());
+ StringEntity body = new StringEntity(jsonDoc.toString(), "utf8");
httpPutRequest.setEntity(body);
httpPutRequest.setHeader("Accept", "application/json");
httpPutRequest.setHeader("Content-type", "application/json");
@@ -226,7 +226,7 @@ public static String updateDocument(String hostUrl, String databaseName,
String docId = jsonDoc.getString("_id");
HttpPut httpPutRequest = new HttpPut(hostUrl + databaseName + "/"
+ docId);
- StringEntity body = new StringEntity(jsonDoc.toString());
+ StringEntity body = new StringEntity(jsonDoc.toString(), "utf8");
httpPutRequest.setEntity(body);
httpPutRequest.setHeader("Accept", "application/json");
httpPutRequest.setHeader("Content-type", "application/json");

0 comments on commit 1beee99

Please sign in to comment.