disable caches in HttpUrlConnections

This commit is contained in:
Daniel Gultsch 2018-03-13 11:59:32 +01:00
parent ca625f1e8e
commit 25a49a28ce
2 changed files with 3 additions and 0 deletions

View file

@ -226,6 +226,7 @@ public class HttpDownloadConnection implements Transferable {
connection = (HttpURLConnection) mUrl.openConnection(); connection = (HttpURLConnection) mUrl.openConnection();
} }
connection.setRequestMethod("HEAD"); connection.setRequestMethod("HEAD");
connection.setUseCaches(false);
Log.d(Config.LOGTAG, "url: " + connection.getURL().toString()); Log.d(Config.LOGTAG, "url: " + connection.getURL().toString());
Log.d(Config.LOGTAG, "connection: " + connection.toString()); Log.d(Config.LOGTAG, "connection: " + connection.toString());
connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName()); connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName());
@ -295,6 +296,7 @@ public class HttpDownloadConnection implements Transferable {
if (connection instanceof HttpsURLConnection) { if (connection instanceof HttpsURLConnection) {
mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive); mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive);
} }
connection.setUseCaches(false);
connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName()); connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName());
final boolean tryResume = file.exists() && file.getKey() == null && file.getSize() > 0; final boolean tryResume = file.exists() && file.getKey() == null && file.getSize() > 0;
long resumeSize = 0; long resumeSize = 0;

View file

@ -186,6 +186,7 @@ public class HttpUploadConnection implements Transferable {
if (connection instanceof HttpsURLConnection) { if (connection instanceof HttpsURLConnection) {
mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, true); mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, true);
} }
connection.setUseCaches(false);
connection.setRequestMethod("PUT"); connection.setRequestMethod("PUT");
connection.setFixedLengthStreamingMode(expectedFileSize); connection.setFixedLengthStreamingMode(expectedFileSize);
connection.setRequestProperty("Content-Type", mime == null ? "application/octet-stream" : mime); connection.setRequestProperty("Content-Type", mime == null ? "application/octet-stream" : mime);