|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
package com.github.catvod.net; |
|
|
|
|
package com.github.catvod.net.interceptor; |
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
@ -18,12 +18,12 @@ import okhttp3.ResponseBody; |
|
|
|
|
import okio.BufferedSource; |
|
|
|
|
import okio.Okio; |
|
|
|
|
|
|
|
|
|
public class OkhttpInterceptor implements Interceptor { |
|
|
|
|
public class DefaultInterceptor implements Interceptor { |
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
|
@Override |
|
|
|
|
public Response intercept(@NonNull Chain chain) throws IOException { |
|
|
|
|
Response response = chain.proceed(getRequest(chain)); |
|
|
|
|
Response response = chain.proceed(getRequest(chain.request())); |
|
|
|
|
String encoding = response.header(HttpHeaders.CONTENT_ENCODING); |
|
|
|
|
if (response.body() == null || encoding == null || !encoding.equals("deflate")) return response; |
|
|
|
|
InflaterInputStream is = new InflaterInputStream(response.body().byteStream(), new Inflater(true)); |
|
|
|
|
@ -47,8 +47,7 @@ public class OkhttpInterceptor implements Interceptor { |
|
|
|
|
}).build(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Request getRequest(@NonNull Chain chain) { |
|
|
|
|
Request request = chain.request(); |
|
|
|
|
private Request getRequest(@NonNull Request request) { |
|
|
|
|
String url = request.url().toString(); |
|
|
|
|
Request.Builder builder = request.newBuilder(); |
|
|
|
|
if (url.contains("+")) builder.url(url.replace("+", "%2B")); |