From f064e33de93426d2016311c464f963831b26b468 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 7 Jan 2019 16:02:33 +0100 Subject: [PATCH] disable all compression when downloading on < android-19 Compression seems to just give stacktraces: HttpDownloaderTest I URL: https://en.wikipedia.org/wiki/Index.html TestRunner I failed: downloadUninterruptedTest(org.fdroid.fdroid.net.HttpDownloaderTest) I ----- begin exception ----- I java.io.EOFException I at java.util.zip.GZIPInputStream.readFully(GZIPInputStream.java:206) I at java.util.zip.GZIPInputStream.(GZIPInputStream.java:98) I at java.util.zip.GZIPInputStream.(GZIPInputStream.java:81) I at libcore.net.http.HttpEngine.initContentStream(HttpEngine.java:541) I at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:844) I at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283) I at libcore.net.http.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:139) I at libcore.net.http.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:246) I at org.fdroid.fdroid.net.HttpDownloader.download(HttpDownloader.java:111) I at org.fdroid.fdroid.net.HttpDownloaderTest.downloadUninterruptedTest(HttpDownloaderTest.java:74) I at java.lang.reflect.Method.invokeNative(Native Method) I at java.lang.reflect.Method.invoke(Method.java:511) I at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) I at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) I at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) I at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) I at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) I at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) I at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) I at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) I at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) I at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) I at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) I at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) I at org.junit.runners.ParentRunner.run(ParentRunner.java:363) I at org.junit.runners.Suite.runChild(Suite.java:128) I at org.junit.runners.Suite.runChild(Suite.java:27) I at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) I at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) I at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) I at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) I at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) I at org.junit.runners.ParentRunner.run(ParentRunner.java:363) I at org.junit.runner.JUnitCore.run(JUnitCore.java:137) I at org.junit.runner.JUnitCore.run(JUnitCore.java:115) I at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:56) I at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:384) I at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661) --- app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java b/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java index eab3097f1..a6fe63dc2 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java +++ b/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java @@ -177,6 +177,10 @@ public class HttpDownloader extends Downloader { connection.setRequestProperty("User-Agent", "F-Droid " + BuildConfig.VERSION_NAME); connection.setConnectTimeout(getTimeout()); + if (Build.VERSION.SDK_INT < 19) { // gzip encoding can be troublesome on old Androids + connection.setRequestProperty("Accept-Encoding", "identity"); + } + if (username != null && password != null) { // add authorization header from username / password if set String authString = username + ":" + password;