1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Improved HTTP buffering

This commit is contained in:
Christophe Beyls 2017-02-20 16:54:56 +01:00
parent d8e56147d2
commit d03f18d5d7

View file

@ -24,6 +24,7 @@ import javax.net.ssl.SSLSession;
public class HttpUtils {
private static final int DEFAULT_TIMEOUT = 10000;
private static final int BUFFER_SIZE = 8192;
static {
// HTTP connection reuse was buggy pre-froyo
@ -86,7 +87,7 @@ public class HttpUtils {
}
final int length = connection.getContentLength();
result.inputStream = new BufferedInputStream(connection.getInputStream());
result.inputStream = connection.getInputStream();
if ((progressAction != null) && (length != -1)) {
// Broadcast the progression in percents, with a precision of 1/10 of the total file size
@ -105,7 +106,9 @@ public class HttpUtils {
}
if ("gzip".equals(contentEncoding)) {
result.inputStream = new GZIPInputStream(result.inputStream);
result.inputStream = new GZIPInputStream(result.inputStream, BUFFER_SIZE);
} else {
result.inputStream = new BufferedInputStream(result.inputStream, BUFFER_SIZE);
}
return result;
}