Java okhttp-gson client: get/set connect timeout

This commit is contained in:
xhh
2015-12-23 18:58:16 +08:00
parent 55fece195d
commit a58901f375
3 changed files with 48 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Date;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -471,6 +472,23 @@ public class ApiClient {
return this;
}
/**
* Connect timeout (in milliseconds).
*/
public int getConnectTimeout() {
return httpClient.getConnectTimeout();
}
/**
* Sets the connect timeout.
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*/
public ApiClient setConnectTimeout(int connectionTimeout) {
httpClient.setConnectTimeout(connectionTimeout, TimeUnit.MILLISECONDS);
return this;
}
/**
* Format the given parameter object into string.
*/