Find out the system defaults for HttpClient timeouts

How to find out what the actual timeout values ​​are for HttpClient 4.3? I know how to set them explicitly, but I would like to know what values ​​are used implicitly if I do not overwrite them.

Example

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"));
    }

}

Output

ConnectionRequestTimeout: -1
ConnectTimeout: -1
SocketTimeout: -1
Exception in thread "main" java.lang.UnsupportedOperationException

client.getParams () throws a java.lang.UnsupportedOperationException exception. Does anyone know a way to read the actual values ​​to be used?

+4
source share
2 answers
 public static class Builder {
private boolean expectContinueEnabled;
private HttpHost proxy;
private InetAddress localAddress;
private boolean staleConnectionCheckEnabled = false;
private String cookieSpec;
private boolean redirectsEnabled = true;
private boolean relativeRedirectsAllowed = true;
private boolean circularRedirectsAllowed;
private int maxRedirects = 50;
private boolean authenticationEnabled = true;
private Collection<String> targetPreferredAuthSchemes;
private Collection<String> proxyPreferredAuthSchemes;
private int connectionRequestTimeout = -1;
private int connectTimeout = -1;
private int socketTimeout = -1;
private boolean contentCompressionEnabled = true;

A piece of code from Apache RequestConfig, so for all three of these defaults there is NO timeout, connectionRequestTimeout, connectTimeout and socketTimeout

0
source

- , 0 ( )

-1

All Articles