mirror of https://github.com/FOME-Tech/fome-fw.git
dead console deps
This commit is contained in:
parent
99640ccae9
commit
85fc86c446
|
@ -22,7 +22,6 @@ dependencies {
|
|||
implementation group: 'com.fazecast', name: 'jSerialComm', version: '2.9.2'
|
||||
implementation group: 'tel.schich', name: 'javacan-core', version: '3.2.0'
|
||||
implementation global_libs.json
|
||||
implementation ts_plugin_libs.httpclient
|
||||
|
||||
// junit 4.13 does not mix well with httpclient :(
|
||||
testImplementation group: 'junit', name: 'junit', version: '4.8.2'
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
package com.rusefi.tools.online;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.HttpConnectionParams;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
||||
public class HttpUtil {
|
||||
private static final Logging log = getLogging(Logging.class);
|
||||
|
||||
// todo: migrate proxy http json API server to TLS
|
||||
public static final int PROXY_JSON_API_HTTP_PORT = getIntProperty("http.port", 8001);
|
||||
|
||||
/**
|
||||
* hostname of PROXY server, not primary rusEFI web server - those are two separate hosts at the moment
|
||||
*/
|
||||
public static String RUSEFI_PROXY_HOSTNAME = System.getProperty("RUSEFI_PROXY_URL", "proxy.rusefi.com");
|
||||
|
||||
public static String RUSEFI_ONLINE_JSON_API_PREFIX = "https://rusefi.com/online/api.php?method=";
|
||||
|
||||
public static <T> T getJsonResponse(String responseString) throws ParseException {
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
return (T) parser.parse(responseString);
|
||||
}
|
||||
|
||||
public static String getResponse(HttpResponse response) throws IOException {
|
||||
HttpEntity entity = response.getEntity();
|
||||
String responseString = EntityUtils.toString(entity, "UTF-8");
|
||||
log.info("responseString=" + responseString);
|
||||
return responseString;
|
||||
}
|
||||
|
||||
public static String executeGet(String url) throws IOException {
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
HttpParams httpParameters = httpclient.getParams();
|
||||
// HttpConnectionParams.setConnectionTimeout(httpParameters, CONNECTION_TIMEOUT);
|
||||
// HttpConnectionParams.setSoTimeout(httpParameters, WAIT_RESPONSE_TIMEOUT);
|
||||
// without this magic http response is pretty slow
|
||||
HttpConnectionParams.setTcpNoDelay(httpParameters, true);
|
||||
log.info("GET " + url);
|
||||
HttpGet httpget = new HttpGet(url);
|
||||
|
||||
// in case of emergency
|
||||
// -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG -Dorg.apache.commons.logging.simplelog.log.org.apache.http.wire=ERROR
|
||||
try {
|
||||
HttpResponse httpResponse = httpclient.execute(httpget);
|
||||
return HttpUtil.getResponse(httpResponse);
|
||||
} finally {
|
||||
httpget.releaseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject parse(String jsonString) {
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = (JSONObject) parser.parse(jsonString);
|
||||
} catch (ParseException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
public static int getIntProperty(String propertyName, int defaultValue) {
|
||||
return Integer.parseInt(System.getProperty(propertyName, Integer.toString(defaultValue)));
|
||||
}
|
||||
}
|
|
@ -8,7 +8,5 @@ dependencies {
|
|||
api project(':core_ui')
|
||||
api project(':ecu_io')
|
||||
api project(':models')
|
||||
api ts_plugin_libs.httpclient
|
||||
api ts_plugin_libs.httpmime
|
||||
api global_libs.json
|
||||
}
|
|
@ -10,11 +10,4 @@ ext {
|
|||
commons_logging: "commons-logging:commons-logging:1.2",
|
||||
jcip : 'net.jcip:jcip-annotations:1.0',
|
||||
]
|
||||
|
||||
ts_plugin_libs = [
|
||||
httpclient : "org.apache.httpcomponents:httpclient:4.5.13",
|
||||
httpcore : "org.apache.httpcomponents:httpcore:4.4.13",
|
||||
httpmime : "org.apache.httpcomponents:httpmime:4.5.12",
|
||||
launcher_api: fileTree( dir: "lib", include: "TunerStudioPluginAPI.jar" )
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue