diff --git a/pom.xml b/pom.xml
index bb85294..3512822 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
avew.github.io
retrofit-mask
- 1.0.0
+ 1.0.1
jar
Custom retrofit with masking log
diff --git a/src/main/java/io/github/avew/CustomHttpConfig.java b/src/main/java/io/github/avew/CustomHttpConfig.java
index 17f3b08..1e715af 100644
--- a/src/main/java/io/github/avew/CustomHttpConfig.java
+++ b/src/main/java/io/github/avew/CustomHttpConfig.java
@@ -23,4 +23,22 @@ public class CustomHttpConfig {
private String proxyHost;
private int proxyPort;
private String agent;
+ @Builder.Default
+ private CustomTimeout customTimeout = new CustomTimeout();
+
+ @Override
+ public String toString() {
+ return "CustomHttpConfig{" +
+ "url='" + url + '\'' +
+ ", proxy=" + proxy +
+ ", proxyAuth=" + proxyAuth +
+ ", proxyUsername='" + proxyUsername + '\'' +
+ ", proxyPassword='" + proxyPassword + '\'' +
+ ", urlSkipProxy=" + urlSkipProxy +
+ ", proxyHost='" + proxyHost + '\'' +
+ ", proxyPort=" + proxyPort +
+ ", agent='" + agent + '\'' +
+ ", customTimeout=" + customTimeout +
+ '}';
+ }
}
diff --git a/src/main/java/io/github/avew/CustomTimeout.java b/src/main/java/io/github/avew/CustomTimeout.java
new file mode 100644
index 0000000..ba044eb
--- /dev/null
+++ b/src/main/java/io/github/avew/CustomTimeout.java
@@ -0,0 +1,30 @@
+package io.github.avew;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.concurrent.TimeUnit;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class CustomTimeout {
+
+ @Builder.Default
+ private long connectTimeout = 1L;
+ @Builder.Default
+ private TimeUnit connectTimeoutUnit = TimeUnit.MINUTES;
+
+ @Builder.Default
+ private long readTimeout = 10L;
+ @Builder.Default
+ private TimeUnit readTimeoutUnit = TimeUnit.MINUTES;
+
+ @Builder.Default
+ private long writeTimeout = 5L;
+ @Builder.Default
+ private TimeUnit writeTimeoutUnit = TimeUnit.MINUTES;
+}
diff --git a/src/main/java/io/github/avew/OkHttpCustomConfiguration.java b/src/main/java/io/github/avew/OkHttpCustomConfiguration.java
index f5fffff..f972a37 100644
--- a/src/main/java/io/github/avew/OkHttpCustomConfiguration.java
+++ b/src/main/java/io/github/avew/OkHttpCustomConfiguration.java
@@ -19,7 +19,6 @@
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -46,9 +45,9 @@ public Retrofit.Builder builder() throws RuntimeException {
OkHttpClient.Builder httpClient = new OkHttpClient().newBuilder();
- httpClient.connectTimeout(5L, TimeUnit.MINUTES);
- httpClient.readTimeout(10L, TimeUnit.MINUTES);
- httpClient.writeTimeout(5L, TimeUnit.MINUTES);
+ httpClient.connectTimeout(config.getCustomTimeout().getConnectTimeout(), config.getCustomTimeout().getConnectTimeoutUnit());
+ httpClient.readTimeout(config.getCustomTimeout().getReadTimeout(), config.getCustomTimeout().getReadTimeoutUnit());
+ httpClient.writeTimeout(config.getCustomTimeout().getWriteTimeout(), config.getCustomTimeout().getWriteTimeoutUnit());
httpClient.addInterceptor(chain -> {
Request original = chain.request();
diff --git a/src/test/java/io/github/avew/OkHttpTest.java b/src/test/java/io/github/avew/OkHttpTest.java
index 655160a..0d2b435 100644
--- a/src/test/java/io/github/avew/OkHttpTest.java
+++ b/src/test/java/io/github/avew/OkHttpTest.java
@@ -38,6 +38,7 @@ public void init() {
.url("https://reqres.in")
.agent("OkHttp/4.1.0")
.build();
+ log.debug("CONFIG {}", customHttpConfig.getCustomTimeout());
retrofit = new OkHttpCustomConfiguration(customHttpConfig, maskingLog, true)
.builder()
.addConverterFactory(GsonConverterFactory.create())