aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-09-20 20:02:25 +0200
committerChristian Schneppe <christian@pix-art.de>2016-09-23 22:17:39 +0200
commit0443a77d669bdcca4b3651544e7162b57f61af45 (patch)
tree660eab4d9db02016b90fb9b89dadb6b4700750b9 /src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
parent4fe3b4539a63c99515450af069d51e20722d3992 (diff)
add timeouts to HTTPUrlConnections and allow cancelation of all sending files
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
index 44f66735e..9a6676154 100644
--- a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
+++ b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
@@ -220,6 +220,8 @@ public class HttpDownloadConnection implements Transferable {
if (connection instanceof HttpsURLConnection) {
mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive);
}
+ connection.setConnectTimeout(Config.SOCKET_TIMEOUT * 1000);
+ connection.setReadTimeout(Config.SOCKET_TIMEOUT * 1000);
connection.connect();
String contentLength = connection.getHeaderField("Content-Length");
connection.disconnect();
@@ -288,6 +290,8 @@ public class HttpDownloadConnection implements Transferable {
long size = file.getSize();
connection.setRequestProperty("Range", "bytes="+size+"-");
}
+ connection.setConnectTimeout(Config.SOCKET_TIMEOUT * 1000);
+ connection.setReadTimeout(Config.SOCKET_TIMEOUT * 1000);
connection.connect();
is = new BufferedInputStream(connection.getInputStream());
boolean serverResumed = "bytes".equals(connection.getHeaderField("Accept-Ranges"));