思路
- 自定义一个拦截器
- 在拦截器中重置超时时间等配置
关键代码
HeadersEx.java
1 | import lombok.Getter; |
TimeoutInterceptor.java
1 | import top.ylonline.common.okhttp.util.HeadersEx; |
OkHttpTest.java
1 | private OkHttpClient okHttpClient() { |
HeadersEx.java
1 | import lombok.Getter; |
TimeoutInterceptor.java
1 | import top.ylonline.common.okhttp.util.HeadersEx; |
OkHttpTest.java
1 | private OkHttpClient okHttpClient() { |