Skip to content

Commit

Permalink
quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LuftVerbot committed Jul 19, 2024
1 parent 6847ea3 commit 6d55b60
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/src/main/java/dev/brahmkshatriya/echo/extension/DeezerApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ class DeezerApi {
proxy(Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved("uk.proxy.murglar.app", 3128)))
}.build()

private val clientNP: OkHttpClient = OkHttpClient.Builder().apply {
addInterceptor { chain ->
val originalResponse = chain.proceed(chain.request())
if (originalResponse.header("Content-Encoding") == "gzip") {
val gzipSource = GZIPInputStream(originalResponse.body?.byteStream())
val decompressedBody = gzipSource.readBytes().toResponseBody(originalResponse.body?.contentType())
originalResponse.newBuilder().body(decompressedBody).build()
} else {
originalResponse
}
}
}.build()

private val json = Json {
isLenient = true
ignoreUnknownKeys = true
Expand Down Expand Up @@ -310,7 +323,7 @@ class DeezerApi {
.build()

// Execute request
val response = client.newCall(request).execute()
val response = clientNP.newCall(request).execute()
val responseBody = response.body?.string()
val body = responseBody.toString()

Expand Down Expand Up @@ -348,7 +361,7 @@ class DeezerApi {
.build()

// Execute request
val response = client.newCall(request).execute()
val response = clientNP.newCall(request).execute()
val responseBody = response.body?.string()
val body = responseBody.toString()

Expand Down

0 comments on commit 6d55b60

Please sign in to comment.