|
29 | 29 | import android.os.Looper;
|
30 | 30 | import android.support.annotation.NonNull;
|
31 | 31 |
|
32 |
| -import org.apache.http.entity.StringEntity; |
33 |
| -import org.apache.http.message.BasicHeader; |
34 |
| -import org.apache.http.protocol.HTTP; |
35 | 32 | import org.json.JSONArray;
|
36 | 33 | import org.json.JSONException;
|
37 | 34 | import org.json.JSONObject;
|
|
41 | 38 | import java.io.IOException;
|
42 | 39 | import java.io.InputStream;
|
43 | 40 | import java.io.InputStreamReader;
|
| 41 | +import java.io.OutputStreamWriter; |
44 | 42 | import java.io.UnsupportedEncodingException;
|
45 | 43 | import java.net.HttpURLConnection;
|
46 | 44 | import java.net.URL;
|
@@ -686,11 +684,11 @@ private byte[] _requestRaw(Method m, String url, String json, List<String> hosts
|
686 | 684 | if (!(requestMethod.equals("PUT") || requestMethod.equals("POST"))) {
|
687 | 685 | throw new IllegalArgumentException("Method " + m + " cannot enclose entity");
|
688 | 686 | }
|
689 |
| - hostConnection.setRequestProperty("Content-type", "application/json"); |
| 687 | + hostConnection.setRequestProperty("Content-type", "application/json; charset=UTF-8"); |
690 | 688 | hostConnection.setDoOutput(true);
|
691 |
| - StringEntity se = new StringEntity(json, "UTF-8"); |
692 |
| - se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); |
693 |
| - se.writeTo(hostConnection.getOutputStream()); |
| 689 | + OutputStreamWriter writer = new OutputStreamWriter(hostConnection.getOutputStream(), "UTF-8"); |
| 690 | + writer.write(json); |
| 691 | + writer.close(); |
694 | 692 | }
|
695 | 693 |
|
696 | 694 | // read response
|
|
0 commit comments