【发布时间】:2017-04-25 14:40:11
【问题描述】:
我在我的改造适配器中设置了一个全局超时
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setReadTimeout(20, TimeUnit.SECONDS);
okHttpClient.setConnectTimeout(20, TimeUnit.SECONDS);
retrofit = new Retrofit.Builder()
.client(okHttpClient)
.build();
太棒了!但我想为某些请求设置一个特定的超时时间 例如
public interface MyAPI {
@GET()
Call<Void> notImportant (@Url String url);
@GET
Call<Void> veryImportant(@Url String url);
所以veryImportant 调用我想要 35 秒的超时,但 notImportant 是默认值
这可能吗?
我的研究一落千丈。
我遇到了这个,但不确定它是否可以在 Retrofit 中工作
https://github.com/square/okhttp/wiki/Recipes#per-call-configuration
感谢您的阅读。请帮忙。
【问题讨论】:
标签: android retrofit okhttp retrofit2 okhttp3