为什么是connectTimeout&只有OkHttpClient可用的ReadTimeout? “okhttp3.Request”不是正确的地方吗?
此外,
答案 0 :(得分:0)
您可以通过以下方式进行操作:
HTTP客户端3:
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS)
.writeTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS)
.build();
HTTP客户端2:
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(5, TimeUnit.SECONDS);
client.setReadTimeout(5, TimeUnit.SECONDS);
client.setWriteTimeout(5, TimeUnit.SECONDS);