|
|
|
@ -50,8 +50,6 @@ 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/";
|
|
|
|
@ -82,7 +80,7 @@ public class LanguageTool {
|
|
|
|
|
Log.i("LT uri=" + uri);
|
|
|
|
|
|
|
|
|
|
URL url = new URL(uri.toString());
|
|
|
|
|
HttpURLConnection connection = (HttpsURLConnection) url.openConnection();
|
|
|
|
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
connection.setRequestMethod("GET");
|
|
|
|
|
connection.setDoOutput(false);
|
|
|
|
|
connection.setReadTimeout(LT_TIMEOUT * 1000);
|
|
|
|
@ -243,7 +241,7 @@ public class LanguageTool {
|
|
|
|
|
Log.i("LT uri=" + uri + " request=" + request);
|
|
|
|
|
|
|
|
|
|
URL url = new URL(uri.toString());
|
|
|
|
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
|
|
|
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
connection.setRequestMethod("POST");
|
|
|
|
|
connection.setDoOutput(true);
|
|
|
|
|
connection.setReadTimeout(LT_TIMEOUT * 1000);
|
|
|
|
@ -319,7 +317,7 @@ public class LanguageTool {
|
|
|
|
|
Log.i("LT uri=" + uri + " request=" + request);
|
|
|
|
|
|
|
|
|
|
URL url = new URL(uri.toString());
|
|
|
|
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
|
|
|
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
connection.setRequestMethod("POST");
|
|
|
|
|
connection.setDoOutput(true);
|
|
|
|
|
connection.setReadTimeout(LT_TIMEOUT * 1000);
|
|
|
|
@ -370,7 +368,7 @@ public class LanguageTool {
|
|
|
|
|
Log.i("LT uri=" + uri);
|
|
|
|
|
|
|
|
|
|
URL url = new URL(uri.toString());
|
|
|
|
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
|
|
|
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
connection.setRequestMethod("GET");
|
|
|
|
|
connection.setDoOutput(false);
|
|
|
|
|
connection.setReadTimeout(LT_TIMEOUT * 1000);
|
|
|
|
@ -436,7 +434,7 @@ public class LanguageTool {
|
|
|
|
|
|
|
|
|
|
private static void checkStatus(HttpURLConnection connection) throws IOException {
|
|
|
|
|
int status = connection.getResponseCode();
|
|
|
|
|
if (status != HttpsURLConnection.HTTP_OK) {
|
|
|
|
|
if (status != HttpURLConnection.HTTP_OK) {
|
|
|
|
|
String error = "Error " + status + ": " + connection.getResponseMessage();
|
|
|
|
|
try {
|
|
|
|
|
InputStream is = connection.getErrorStream();
|
|
|
|
|