美文网首页
Android OkHeaderInterceptor

Android OkHeaderInterceptor

作者: 人心所向便是阳光 | 来源:发表于2018-12-10 07:53 被阅读0次
public class OkHeaderInterceptor implements Interceptor {

@Override
public Response intercept(Chain chain) throws IOException {
    Request request = chain.request();
    Request.Builder builder = request.newBuilder();
    //builder.addHeader("userId",""+SharedPreferencesUtil.getInt("userId",-1));
    //builder.addHeader("sessionId",""+SharedPreferencesUtil.getInt("sessionId",-1));
    builder.addHeader("userId",SharedPreferencesUtil.getString("userId",""));
    builder.addHeader("sessionId",SharedPreferencesUtil.getString("sessionId",""));
    request = builder.build();
    return chain.proceed(request);
}

}

相关文章

网友评论

      本文标题:Android OkHeaderInterceptor

      本文链接:https://www.haomeiwen.com/subject/hawlhqtx.html