Click Here To show my issue,我只想设置每个请求超时和其他参数, 所以只需使用:
<!-- language: lang-java -->
private static final OkHttpClient globalOkHttpClient = new OkHttpClient.Builder().build();
private static final OkHttpClient otherOkHttpClient10 = globalOkHttpClient.newBuilder()
.connectTimeout(10,TimeUnit.SECONDS)
.build();
private static final OkHttpClient otherOkHttpClient20 = globalOkHttpClient.newBuilder()
.connectTimeout(20,TimeUnit.SECONDS)
.build();
但是,这可能不会重复使用单个OkHttp
实例?所以,我只是想问一下?如何设置OkHttpClient
超时Per Request
。
我的OkHttp3
maven依赖:
<!-- language: lang-xml -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.9.0</version>
</dependency>