mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 14:21:16 +00:00
Explicitly set UTF-8 encoding when sending data (fixes #228).
This commit is contained in:
parent
703578aeb5
commit
8edf8201e3
2 changed files with 4 additions and 7 deletions
|
@ -12,6 +12,7 @@ import org.apache.http.client.utils.URLEncodedUtils;
|
|||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -53,7 +54,7 @@ public class GetTask extends AsyncTask<String, Void, String> {
|
|||
if (params.length == 5) {
|
||||
LinkedList<NameValuePair> urlParams = new LinkedList<>();
|
||||
urlParams.add(new BasicNameValuePair(params[3], params[4]));
|
||||
fullUri += "?" + URLEncodedUtils.format(urlParams, "utf-8");
|
||||
fullUri += "?" + URLEncodedUtils.format(urlParams, HTTP.UTF_8);
|
||||
}
|
||||
HttpGet get = new HttpGet(fullUri);
|
||||
get.addHeader(new BasicHeader(RestApi.HEADER_API_KEY, params[2]));
|
||||
|
|
|
@ -3,18 +3,14 @@ package com.nutomic.syncthingandroid.syncthing;
|
|||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* Performs a POST request with no parameters to the URL in uri[0] with the path in uri[1].
|
||||
|
@ -44,7 +40,7 @@ public class PostTask extends AsyncTask<String, Void, Boolean> {
|
|||
|
||||
try {
|
||||
if (params.length > 3) {
|
||||
post.setEntity(new StringEntity(params[3]));
|
||||
post.setEntity(new StringEntity(params[3], HTTP.UTF_8));
|
||||
}
|
||||
httpclient.execute(post);
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Reference in a new issue