Android OkHeaderInterceptor

2018-12-10  本文已影响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);
}

}

上一篇 下一篇

猜你喜欢

热点阅读