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

  

相關文章
相關標籤/搜索