Http method selectable

This commit is contained in:
Jens 2023-12-12 23:40:12 +01:00
parent 1b8dc5de5f
commit 3f76813e80
5 changed files with 24 additions and 25 deletions

View File

@ -674,7 +674,7 @@ public class Action
Miscellaneous.logEvent("i", "HTTP", "Attempting download of " + url, 4); //getResources().getString("attemptingDownloadOf"); Miscellaneous.logEvent("i", "HTTP", "Attempting download of " + url, 4); //getResources().getString("attemptingDownloadOf");
if(this.getParameter1()) // use authentication if(this.getParameter1()) // use authentication
new DownloadTask().execute(url, username, password, methodnochindiesignaturaufnehmen); new DownloadTask().execute(url, username, password, method);
else else
new DownloadTask().execute(url, null, null); new DownloadTask().execute(url, null, null);
} }

View File

@ -22,7 +22,7 @@ public class AsyncTasks
try try
{ {
String result = Miscellaneous.downloadURL("https://server47.de/automation/?action=getLatestVersionCode", null, null).trim(); String result = Miscellaneous.downloadURL("https://server47.de/automation/?action=getLatestVersionCode", null, null, ActivityManageActionTriggerUrl.methodGet).trim();
int latestVersion = Integer.parseInt(result); int latestVersion = Integer.parseInt(result);
// At this point the update check itself has already been successful. // At this point the update check itself has already been successful.

View File

@ -48,6 +48,7 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams; import org.apache.http.params.BasicHttpParams;
@ -181,8 +182,6 @@ public class Miscellaneous extends Service
public static String downloadURLwithoutCertificateChecking(String url, String username, String password, String method) public static String downloadURLwithoutCertificateChecking(String url, String username, String password, String method)
{ {
boolean errorFound = false;
try try
{ {
HttpParams params = new BasicHttpParams(); HttpParams params = new BasicHttpParams();
@ -191,23 +190,23 @@ public class Miscellaneous extends Service
HttpClient httpclient = new DefaultHttpClient(params); HttpClient httpclient = new DefaultHttpClient(params);
httpclient = Actions.getInsecureSslClient(httpclient); httpclient = Actions.getInsecureSslClient(httpclient);
HttpEntityEnclosingRequestBase httpRequest; HttpRequestBase httpRequest;
switch (method) if(
{ method.equals(ActivityManageActionTriggerUrl.methodPost)
case ActivityManageActionTriggerUrl.methodPost: ||
(username != null && password != null)
)
httpRequest = new HttpPost(url); httpRequest = new HttpPost(url);
break; else
case ActivityManageActionTriggerUrl.methodGet: httpRequest = new HttpGet(url);
default: /*httpRequest = new HttpEntityEnclosingRequestBase()
httpRequest = new HttpEntityEnclosingRequestBase()
{ {
@Override @Override
public String getMethod() public String getMethod()
{somethingMissing {
return null; return "GET";
}
};
} }
};*/
// Add http simple authentication if specified // Add http simple authentication if specified
if(username != null && password != null) if(username != null && password != null)
@ -227,7 +226,6 @@ public class Miscellaneous extends Service
catch(Exception e) catch(Exception e)
{ {
Miscellaneous.logEvent("e", "HTTP error", Log.getStackTraceString(e), 3); Miscellaneous.logEvent("e", "HTTP error", Log.getStackTraceString(e), 3);
errorFound = true;
return "httpError"; return "httpError";
} }
// finally // finally

View File

@ -79,7 +79,7 @@ public class News
if (!(new File(filePath)).exists() || Settings.lastNewsPolltime == Settings.default_lastNewsPolltime || now.getTimeInMillis() >= Settings.lastNewsPolltime + (long)(Settings.newsDisplayForXDays * 24 * 60 * 60 * 1000)) if (!(new File(filePath)).exists() || Settings.lastNewsPolltime == Settings.default_lastNewsPolltime || now.getTimeInMillis() >= Settings.lastNewsPolltime + (long)(Settings.newsDisplayForXDays * 24 * 60 * 60 * 1000))
{ {
String newsUrl = "https://server47.de/automation/appNews.php"; String newsUrl = "https://server47.de/automation/appNews.php";
newsContent = Miscellaneous.downloadURL(newsUrl, null, null); newsContent = Miscellaneous.downloadURL(newsUrl, null, null, ActivityManageActionTriggerUrl.methodGet);
// Cache content to local storage // Cache content to local storage
if(Miscellaneous.writeStringToFile(filePath, newsContent)) if(Miscellaneous.writeStringToFile(filePath, newsContent))

View File

@ -1,2 +1,3 @@
* Fixed: Overlay permission for start other program action only required if startByActivity() is selected * Fixed: Overlay permission for start other program action only required if startByActivity() is selected
* Fixed: Broadcast receiver trigger would not trigger anything, but crash * Fixed: Broadcast receiver trigger would not trigger anything, but crash
* Added: One can now choose between GET and POST when using triggerURL action