okhttp 内网能够有,但外网访问数据返不回来,代码同样

;一、问题点在于 下图红框里写成 text/html了,须要改为application/json,形成的问题有:unexpected end of stream  这个是406错误;加上日志以后okhttp好用了:html

日志:json

.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();

  

相关文章
相关标签/搜索