Http method selectable
This commit is contained in:
parent
1b8dc5de5f
commit
3f76813e80
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
|
@ -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,9 +182,7 @@ 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();
|
||||||
params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
|
params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
|
||||||
@ -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:
|
||
|
||||||
httpRequest = new HttpPost(url);
|
(username != null && password != null)
|
||||||
break;
|
)
|
||||||
case ActivityManageActionTriggerUrl.methodGet:
|
httpRequest = new HttpPost(url);
|
||||||
default:
|
else
|
||||||
httpRequest = new HttpEntityEnclosingRequestBase()
|
httpRequest = new HttpGet(url);
|
||||||
|
/*httpRequest = new HttpEntityEnclosingRequestBase()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public String getMethod()
|
||||||
{
|
{
|
||||||
@Override
|
return "GET";
|
||||||
public String getMethod()
|
}
|
||||||
{somethingMissing
|
};*/
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add http simple authentication if specified
|
// Add http simple authentication if specified
|
||||||
if(username != null && password != null)
|
if(username != null && password != null)
|
||||||
@ -227,8 +226,7 @@ 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
|
||||||
// {
|
// {
|
||||||
|
@ -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))
|
||||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user