如何找出HttpClient 4.3的实际超时值?我知道如何明确地设置它们,但是如果我不覆盖它们,我想知道哪些值是隐式使用的。
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.params.HttpParams;
public class HttpClientDefaults
{
public static void main(String[] args)
{
RequestConfig config = RequestConfig.custom().build();
System.out.println("ConnectionRequestTimeout: " + config.getConnectionRequestTimeout());
System.out.println("ConnectTimeout: " + config.getConnectTimeout());
System.out.println("SocketTimeout: " + config.getSocketTimeout());
CloseableHttpClient client = HttpClientBuilder.create().setRetryHandler(new DefaultHttpRequestRetryHandler()).build();
HttpParams params = client.getParams();
System.out.println(params.getParameter("http.socket.timeout"));
}
}
ConnectionRequestTimeout: -1
ConnectTimeout: -1
SocketTimeout: -1
Exception in thread "main" java.lang.UnsupportedOperationException
client.getParams()抛出java.lang.UnsupportedOperationException异常。有人知道一种方法来读出将要使用的实际值吗?
答案 0 :(得分:0)
套接字,连接和连接请求超时的默认值为0(无超时)