Stetho 和 chrome:inspect 待处理的 REST 请愿书
Stetho and chrome:inspect pending REST petitions
我将 Stetho、Retrofit 和 OkHttp 与 Chrome 开发人员工具一起用于调试目的,一切似乎都正常,我看到了我的本地数据库内容,我可以检查我的 UI,但是如果我在启用网络检查的情况下向我的服务器执行一些 REST 请愿书,请愿书仍为 "Pending",但如果我复制 URL 并粘贴到 Chrome 选项卡上,请愿书会正确执行,我不知道发生了什么。
这些是我的 gradle 进口商品:
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
我在这里找到了答案
https://github.com/facebook/stetho/issues/346
我不小心使用了常规拦截器而不是网络拦截器。
所以这是我的错误版本
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
httpClient.addInterceptor(new StethoInterceptor());
这是正确的版本:
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
httpClient.addNetworkInterceptor(new StethoInterceptor());
我将 Stetho、Retrofit 和 OkHttp 与 Chrome 开发人员工具一起用于调试目的,一切似乎都正常,我看到了我的本地数据库内容,我可以检查我的 UI,但是如果我在启用网络检查的情况下向我的服务器执行一些 REST 请愿书,请愿书仍为 "Pending",但如果我复制 URL 并粘贴到 Chrome 选项卡上,请愿书会正确执行,我不知道发生了什么。
这些是我的 gradle 进口商品:
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
我在这里找到了答案 https://github.com/facebook/stetho/issues/346
我不小心使用了常规拦截器而不是网络拦截器。
所以这是我的错误版本
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
httpClient.addInterceptor(new StethoInterceptor());
这是正确的版本:
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
httpClient.addNetworkInterceptor(new StethoInterceptor());