parent
e400ee8b05
commit
e92ddeab81
@ -1,48 +0,0 @@ |
||||
package com.github.catvod.net; |
||||
|
||||
import com.github.catvod.utils.Util; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.zip.Inflater; |
||||
import java.util.zip.InflaterInputStream; |
||||
|
||||
import okhttp3.Interceptor; |
||||
import okhttp3.MediaType; |
||||
import okhttp3.Request; |
||||
import okhttp3.Response; |
||||
import okhttp3.ResponseBody; |
||||
import okio.BufferedSource; |
||||
import okio.Okio; |
||||
|
||||
public class OkhttpInterceptor implements Interceptor { |
||||
|
||||
@Override |
||||
public Response intercept(Chain chain) throws IOException { |
||||
Response response = chain.proceed(getRequest(chain)); |
||||
String encoding = response.header("Content-Encoding"); |
||||
if (response.body() == null || encoding == null || !encoding.equals("deflate")) return response; |
||||
InflaterInputStream is = new InflaterInputStream(response.body().byteStream(), new Inflater(true)); |
||||
return response.newBuilder().headers(response.headers()).body(new ResponseBody() { |
||||
@Override |
||||
public MediaType contentType() { |
||||
return response.body().contentType(); |
||||
} |
||||
|
||||
@Override |
||||
public long contentLength() { |
||||
return response.body().contentLength(); |
||||
} |
||||
|
||||
@Override |
||||
public BufferedSource source() { |
||||
return Okio.buffer(Okio.source(is)); |
||||
} |
||||
}).build(); |
||||
} |
||||
|
||||
private Request getRequest(Chain chain) { |
||||
Request request = chain.request(); |
||||
if (request.url().host().equals("gitcode.net")) return request.newBuilder().addHeader("User-Agent", Util.CHROME).build(); |
||||
return request; |
||||
} |
||||
} |
||||
Binary file not shown.
@ -1 +1 @@ |
||||
30 3e ad d6 15 ea 12 22 47 a0 0e 08 68 9f 07 87 |
||||
1d4ff8f544bca8e9c4c931bc67f186c9 |
||||
|
||||
@ -1 +0,0 @@ |
||||
DedeUserID=690781341;DedeUserID__ckMd5=cabc96906269c5b6;SESSDATA=2245ba24%2C1684212125%2C466fd%2Ab2;bili_jct=de6fdb60c10f8a83910aa55d79407b4e; |
||||
Loading…
Reference in new issue