;1、问题点在于 下图红框里写成 text/html了,需要改成application/json,造成的问题有:unexpected end of stream 这个是406错误;加上日志之后okhttp好用了:
日志:
.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain paramAnonymousChain)
throws IOException {
return paramAnonymousChain.proceed(paramAnonymousChain.request().newBuilder()
//.addHeader("Connection", "close")
.addHeader("Accept", "Application/Json")
// .addHeader("token", SharedPreferenesUtil.getLoginUserToken(RestSource.this.context)
.build());
}
})
.addInterceptor(new HttpLoggingInterceptor().//开启日志信息
setLevel(HttpLoggingInterceptor.Level.BODY))
.build();