Comments (4)
请帖上代码看看
from retrofitcache.
@OverRide
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
// Add access_token parameter if user login
UserInfo userInfo = mFRVAccountManager.getUserInfo();
String accessToken = userInfo != null ? userInfo.token() : null;
HttpUrl originalUrl = request.url();
if (!TextUtils.isEmpty(accessToken) && originalUrl != null && TextUtils.isEmpty(originalUrl.queryParameter("access_token"))) {
HttpUrl url = originalUrl.newBuilder().addEncodedQueryParameter("access_token", accessToken).build();
request = request.newBuilder().url(url).build();
}
return chain.proceed(request);
}
通过intercept添加access_token
from retrofitcache.
你自己给url添加新的字段,导致原始请求url链接发生变化,最后找不到这个新的链接,cache time就成默认值了;
我下版本再想办法兼容处理一下这个问题
from retrofitcache.
请更新至1.0.7
RetrofitCache.getInstance().addIgnoreParam("access_token");
from retrofitcache.
Related Issues (20)
- 请问如何让请求在一段时间内只使用缓存的数据 HOT 13
- 有网络先加载缓存,再加载网络 HOT 15
- 报错NoSuchMethodException HOT 4
- 后台规定全用post HOT 3
- release版本不能获取mock数据么 HOT 7
- 如何在下拉刷新的时候不走缓存. HOT 6
- 设置缓存时间在使用CacheForceInterceptorNoNet的时候无效?
- 请求添加对协程的支持 HOT 1
- rxjava2的库mock不了 HOT 5
- 大佬什么时候更新支持最新retrofit2啊? HOT 4
- Mock 与CacheForceInterceptorNoNet HOT 7
- 当使用【zip】操作符合并网络请求时,MOCK注解失效
- 为何我设置了也不走缓存呢,都是走的服务器? HOT 5
- 缓存只支持get请求吗,post不支持吗 HOT 2
- 设置忽略某个参数,可以做成针对不同接口来设置吗
- ren.yale.android.retrofitcachelibrx2.intercept.CacheForceInterceptorNoNet.intercept
- @Cache(time = 10) //缓存设置为10秒 设置10秒无效,缓存一直在
- 能通过修改哪块代码来支持post请求吗
- 不支持https?? HOT 2
- retrofit 2.6版本此库失效 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from retrofitcache.