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);
}
}
网友评论