diff --git a/.idea/misc.xml b/.idea/misc.xml
index cca2cdae1104f24be36cbc5479e56329cbcde55d..7158618b85341a59364023b0c758790897c83c56 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/app/src/main/java/me/jessyan/mvparms/demo/app/WEApplication.java b/app/src/main/java/me/jessyan/mvparms/demo/app/WEApplication.java
index 2a3b468b7fedb75076c04f25e4825fc7cf14d688..c92a7549798d7c51fb551b20bbb3b16c0d1b961a 100644
--- a/app/src/main/java/me/jessyan/mvparms/demo/app/WEApplication.java
+++ b/app/src/main/java/me/jessyan/mvparms/demo/app/WEApplication.java
@@ -112,21 +112,18 @@ public class WEApplication extends BaseApplication {
}
- //这里如果发现token过期,可以先请求最新的token,然后在拿新的token去重新请求之前的http请求
+ //这里如果发现token过期,可以先请求最新的token,然后在拿新的token放入request里去重新请求
+ //注意在这个回调之前已经调用过proceed,所以这里必须自己去建立网络请求,如使用okhttp使用新的request去请求
// create a new request and modify it accordingly using the new token
// Request newRequest = chain.request().newBuilder().header("token", newToken)
// .build();
-//
+
// // retry the request
//
// response.body().close();
-// try {
-// return chain.proceed(newRequest);
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
+ //如果使用okhttp将新的请求,请求成功后,将返回的response return出去即可
- //如果需要返回新的结果,则直接把response参数返回出去
+ //如果不需要返回新的结果,则直接把response参数返回出去
return response;
}
diff --git a/arms/src/main/java/com/jess/arms/http/RequestIntercept.java b/arms/src/main/java/com/jess/arms/http/RequestIntercept.java
index ccd84517daf69c9d1c1854ae01346d1bf566263e..50087e1622baf6cdb308312e3666c9268308fd33 100644
--- a/arms/src/main/java/com/jess/arms/http/RequestIntercept.java
+++ b/arms/src/main/java/com/jess/arms/http/RequestIntercept.java
@@ -4,7 +4,6 @@ import android.support.annotation.NonNull;
import com.jess.arms.utils.ZipHelper;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@@ -78,17 +77,9 @@ public class RequestIntercept implements Interceptor {
//解析response content
if (encoding != null && encoding.equalsIgnoreCase("gzip")) {//content使用gzip压缩
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- clone.writeTo(outputStream);
- byte[] bytes = outputStream.toByteArray();
- bodyString = ZipHelper.decompressForGzip(bytes);//解压
- outputStream.close();
+ bodyString = ZipHelper.decompressForGzip(clone.readByteArray());//解压
} else if (encoding != null && encoding.equalsIgnoreCase("zlib")) {//content使用zlib压缩
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- clone.writeTo(outputStream);
- byte[] bytes = outputStream.toByteArray();
- bodyString = ZipHelper.decompressToStringForZlib(bytes);//解压
- outputStream.close();
+ bodyString = ZipHelper.decompressToStringForZlib(clone.readByteArray());//解压
} else {//content没有被压缩
Charset charset = Charset.forName("UTF-8");
MediaType contentType = responseBody.contentType();