-1在setConnectTimeout(-1)的参数中指的是什么

时间:2019-05-06 00:08:42

标签: http

值是什么:-1在setConnectTimeout()的参数中引用。 就像值0意味着等待不确定,-1意味着什么。

RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(-1)
                .setConnectTimeout(-1)
                .build();

1 个答案:

答案 0 :(得分:0)

在Apache HttpClient中,setConnectTimeout(-1)的意思是“使用系统默认值”。

方法setConnectTimeout()属于类RequestConfig.Builder,并且由于其source code(src / main / java / org / apache / http / client / config / RequestConfig.java):< / p>

/**
 * Determines the timeout in milliseconds until a connection is established.
 * A timeout value of zero is interpreted as an infinite timeout.
 * <p>
 * A timeout value of zero is interpreted as an infinite timeout.
 * A negative value is interpreted as undefined (system default).
 * </p>
 * <p>
 * Default: {@code -1}
 * </p>
 */
public int getConnectTimeout() {
    return connectTimeout;
}