Skip to content

Commit 985b302

Browse files
author
Yevhen Babiichuk (DustDFG)
committed
Add brotli support to downloader
1 parent 9f1e2c6 commit 985b302

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ ksp {
132132
arg("room.schemaLocation", "$projectDir/schemas")
133133
}
134134

135-
136135
// Custom dependency configuration for ktlint
137136
val ktlint by configurations.creating
138137

@@ -256,6 +255,7 @@ dependencies {
256255

257256
// HTTP client
258257
implementation(libs.squareup.okhttp)
258+
implementation(libs.squareup.okhttp.brotli)
259259

260260
// Media player
261261
implementation(libs.google.exoplayer.core)

app/src/main/java/org/schabi/newpipe/DownloaderImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
import java.util.stream.Collectors;
2424
import java.util.stream.Stream;
2525

26+
import okhttp3.CompressionInterceptor;
27+
import okhttp3.Gzip;
2628
import okhttp3.OkHttpClient;
2729
import okhttp3.RequestBody;
2830
import okhttp3.ResponseBody;
31+
import okhttp3.brotli.Brotli;
2932

3033
public final class DownloaderImpl extends Downloader {
3134
public static final String USER_AGENT =
@@ -44,6 +47,9 @@ private DownloaderImpl(final OkHttpClient.Builder builder) {
4447
.readTimeout(30, TimeUnit.SECONDS)
4548
// .cache(new Cache(new File(context.getExternalCacheDir(), "okhttp"),
4649
// 16 * 1024 * 1024))
50+
.addInterceptor(new CompressionInterceptor(
51+
Brotli.INSTANCE,
52+
Gzip.INSTANCE))
4753
.build();
4854
this.mCookies = new HashMap<>();
4955
}

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ squareup-leakcanary-core = { module = "com.squareup.leakcanary:leakcanary-androi
128128
squareup-leakcanary-plumber = { module = "com.squareup.leakcanary:plumber-android", version.ref = "leakcanary" }
129129
squareup-leakcanary-watcher = { module = "com.squareup.leakcanary:leakcanary-object-watcher-android", version.ref = "leakcanary" }
130130
squareup-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
131+
squareup-okhttp-brotli = { module = "com.squareup.okhttp3:okhttp-brotli", version.ref = "okhttp" }
131132
zacsweers-autoservice-compiler = { module = "dev.zacsweers.autoservice:auto-service-ksp", version.ref = "autoservice-zacsweers" }
132133

133134
[plugins]

0 commit comments

Comments
 (0)