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);
}
}