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");
if(this.getParameter1()) // use authentication
new DownloadTask().execute(url, username, password, methodnochindiesignaturaufnehmen);
new DownloadTask().execute(url, username, password, method);
else
new DownloadTask().execute(url, null, null);
}

View File

@ -22,7 +22,7 @@ public class AsyncTasks
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);
// 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.HttpPost;
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.impl.client.DefaultHttpClient;
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)
{
boolean errorFound = false;
try
{
HttpParams params = new BasicHttpParams();
@ -191,23 +190,23 @@ public class Miscellaneous extends Service
HttpClient httpclient = new DefaultHttpClient(params);
httpclient = Actions.getInsecureSslClient(httpclient);
HttpEntityEnclosingRequestBase httpRequest;
switch (method)
{
case ActivityManageActionTriggerUrl.methodPost:
HttpRequestBase httpRequest;
if(
method.equals(ActivityManageActionTriggerUrl.methodPost)
||
(username != null && password != null)
)
httpRequest = new HttpPost(url);
break;
case ActivityManageActionTriggerUrl.methodGet:
default:
httpRequest = new HttpEntityEnclosingRequestBase()
else
httpRequest = new HttpGet(url);
/*httpRequest = new HttpEntityEnclosingRequestBase()
{
@Override
public String getMethod()
{somethingMissing
return null;
}
};
{
return "GET";
}
};*/
// Add http simple authentication if specified
if(username != null && password != null)
@ -227,7 +226,6 @@ public class Miscellaneous extends Service
catch(Exception e)
{
Miscellaneous.logEvent("e", "HTTP error", Log.getStackTraceString(e), 3);
errorFound = true;
return "httpError";
}
// 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))
{
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
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: Broadcast receiver trigger would not trigger anything, but crash
* Added: One can now choose between GET and POST when using triggerURL action