mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 06:08:31 +02:00
Refactoring
This commit is contained in:
@@ -42,7 +42,6 @@ import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -50,6 +49,8 @@ import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
public class LanguageTool {
|
||||
static final String LT_URI = "https://api.languagetool.org/v2/";
|
||||
static final String LT_URI_PLUS = "https://api.languagetoolplus.com/v2/";
|
||||
@@ -87,7 +88,7 @@ public class LanguageTool {
|
||||
Log.i("LT uri=" + uri);
|
||||
|
||||
URL url = new URL(uri.toString());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(false);
|
||||
connection.setReadTimeout(LT_TIMEOUT * 1000);
|
||||
@@ -248,7 +249,7 @@ public class LanguageTool {
|
||||
Log.i("LT uri=" + uri + " request=" + request);
|
||||
|
||||
URL url = new URL(uri.toString());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setDoOutput(true);
|
||||
connection.setReadTimeout(LT_TIMEOUT * 1000);
|
||||
@@ -327,7 +328,7 @@ public class LanguageTool {
|
||||
Log.i("LT uri=" + uri + " request=" + request);
|
||||
|
||||
URL url = new URL(uri.toString());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setDoOutput(true);
|
||||
connection.setReadTimeout(LT_TIMEOUT * 1000);
|
||||
@@ -378,7 +379,7 @@ public class LanguageTool {
|
||||
Log.i("LT uri=" + uri);
|
||||
|
||||
URL url = new URL(uri.toString());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(false);
|
||||
connection.setReadTimeout(LT_TIMEOUT * 1000);
|
||||
@@ -460,9 +461,9 @@ public class LanguageTool {
|
||||
return (!TextUtils.isEmpty(lt_user) && !TextUtils.isEmpty(lt_key));
|
||||
}
|
||||
|
||||
private static void checkStatus(HttpURLConnection connection) throws IOException {
|
||||
private static void checkStatus(HttpsURLConnection connection) throws IOException {
|
||||
int status = connection.getResponseCode();
|
||||
if (status != HttpURLConnection.HTTP_OK) {
|
||||
if (status != HttpsURLConnection.HTTP_OK) {
|
||||
String error = "Error " + status + ": " + connection.getResponseMessage();
|
||||
try {
|
||||
InputStream is = connection.getErrorStream();
|
||||
|
||||
Reference in New Issue
Block a user