private class LogginIntecepter implements Interceptor{
@Override
public Response intercept(Chain chain) throws IOException {
SharedPreferences sp = MyApplication.getSp();
/* String sessionId = result.getSessionId();
int userId = result.getUserId();*/
int userId = sp.getInt("userId", 0);
String sessionId = sp.getString("sessionId",null);
Log.e("nhj", "添加用户id="+userId+"添加sessionID="+sessionId);
Request request = chain.request();
Request request1 = request.newBuilder()
.addHeader("userId", String.valueOf(userId))
.addHeader("sessionId", sessionId)
.build();
Response proceed = chain.proceed(request1);
return proceed;
}
请求头
最新推荐文章于 2023-12-19 17:19:44 发布