Renamed RequestConfig#connectionTimeout to RequestConfig#connectTimeout

This commit is contained in:
Oleg Kalnichevski 2018-10-22 15:14:04 +02:00
parent e92c75be8a
commit b74cb12d44
21 changed files with 57 additions and 59 deletions

View File

@ -52,7 +52,8 @@ public class FluentExecutor {
// Execute a GET with timeout settings and return response content as String. // Execute a GET with timeout settings and return response content as String.
executor.execute(Request.Get("http://somehost/") executor.execute(Request.Get("http://somehost/")
.connectionTimeout(Timeout.ofSeconds(1))).returnContent().asString(); .connectTimeout(Timeout.ofSeconds(1)))
.returnContent().asString();
// Execute a POST with the 'expect-continue' handshake, using HTTP/1.1, // Execute a POST with the 'expect-continue' handshake, using HTTP/1.1,
// containing a request body as String and return response content as byte array. // containing a request body as String and return response content as byte array.

View File

@ -43,7 +43,7 @@ public class FluentRequests {
public static void main(String[] args)throws Exception { public static void main(String[] args)throws Exception {
// Execute a GET with timeout settings and return response content as String. // Execute a GET with timeout settings and return response content as String.
Request.Get("http://somehost/") Request.Get("http://somehost/")
.connectionTimeout(Timeout.ofSeconds(1)) .connectTimeout(Timeout.ofSeconds(1))
.execute().returnContent().asString(); .execute().returnContent().asString();
// Execute a POST with the 'expect-continue' handshake, using HTTP/1.1, // Execute a POST with the 'expect-continue' handshake, using HTTP/1.1,

View File

@ -76,7 +76,7 @@ public class Request {
private final ClassicHttpRequest request; private final ClassicHttpRequest request;
private Boolean useExpectContinue; private Boolean useExpectContinue;
private Timeout connectionTimeout; private Timeout connectTimeout;
private HttpHost proxy; private HttpHost proxy;
private SimpleDateFormat dateFormatter; private SimpleDateFormat dateFormatter;
@ -174,8 +174,8 @@ public class Request {
if (this.useExpectContinue != null) { if (this.useExpectContinue != null) {
builder.setExpectContinueEnabled(this.useExpectContinue); builder.setExpectContinueEnabled(this.useExpectContinue);
} }
if (this.connectionTimeout != null) { if (this.connectTimeout != null) {
builder.setConnectionTimeout(this.connectionTimeout); builder.setConnectTimeout(this.connectTimeout);
} }
if (this.proxy != null) { if (this.proxy != null) {
builder.setProxy(this.proxy); builder.setProxy(this.proxy);
@ -287,8 +287,8 @@ public class Request {
//// HTTP connection parameter operations //// HTTP connection parameter operations
public Request connectionTimeout(final Timeout timeout) { public Request connectTimeout(final Timeout timeout) {
this.connectionTimeout = timeout; this.connectTimeout = timeout;
return this; return this;
} }

View File

@ -90,8 +90,8 @@ public abstract class AbstractHttp1IntegrationTestBase extends AbstractServerTes
protected void before() throws Throwable { protected void before() throws Throwable {
clientBuilder = HttpAsyncClientBuilder.create() clientBuilder = HttpAsyncClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.setConnectTimeout(TIMEOUT)
.build()) .build())
.setConnectionManager(connManager); .setConnectionManager(connManager);
} }

View File

@ -95,8 +95,8 @@ public class TestHttp1Async extends AbstractHttpAsyncFundamentalsTest<CloseableH
protected void before() throws Throwable { protected void before() throws Throwable {
clientBuilder = HttpAsyncClientBuilder.create() clientBuilder = HttpAsyncClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.setConnectTimeout(TIMEOUT)
.build()) .build())
.setConnectionManager(connManager); .setConnectionManager(connManager);
} }

View File

@ -116,8 +116,8 @@ public class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest<Clos
protected void before() throws Throwable { protected void before() throws Throwable {
clientBuilder = HttpAsyncClientBuilder.create() clientBuilder = HttpAsyncClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.setConnectTimeout(TIMEOUT)
.build()) .build())
.setConnectionManager(connManager); .setConnectionManager(connManager);
} }

View File

@ -90,7 +90,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
protected void before() throws Throwable { protected void before() throws Throwable {
clientBuilder = HttpAsyncClientBuilder.create() clientBuilder = HttpAsyncClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT) .setConnectTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.build()) .build())
.setConnectionManager(connManager); .setConnectionManager(connManager);

View File

@ -106,8 +106,8 @@ public class TestHttp1ClientAuthentication extends AbstractHttpAsyncClientAuthen
protected void before() throws Throwable { protected void before() throws Throwable {
clientBuilder = HttpAsyncClientBuilder.create() clientBuilder = HttpAsyncClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.setConnectTimeout(TIMEOUT)
.build()) .build())
.setConnectionManager(connManager); .setConnectionManager(connManager);
} }

View File

@ -62,8 +62,8 @@ public class TestHttp2Async extends AbstractHttpAsyncFundamentalsTest<CloseableH
protected void before() throws Throwable { protected void before() throws Throwable {
clientBuilder = Http2AsyncClientBuilder.create() clientBuilder = Http2AsyncClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.setConnectTimeout(TIMEOUT)
.build()) .build())
.setTlsStrategy(new BasicClientTlsStrategy(SSLTestContexts.createClientSSLContext())); .setTlsStrategy(new BasicClientTlsStrategy(SSLTestContexts.createClientSSLContext()));
} }

View File

@ -65,8 +65,8 @@ public class TestHttp2AsyncRedirect extends AbstractHttpAsyncRedirectsTest<Close
protected void before() throws Throwable { protected void before() throws Throwable {
clientBuilder = Http2AsyncClientBuilder.create() clientBuilder = Http2AsyncClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.setConnectTimeout(TIMEOUT)
.build()) .build())
.setTlsStrategy(new DefaultClientTlsStrategy(SSLTestContexts.createClientSSLContext())); .setTlsStrategy(new DefaultClientTlsStrategy(SSLTestContexts.createClientSSLContext()));
} }

View File

@ -66,8 +66,8 @@ public class TestHttp2ClientAuthentication extends AbstractHttpAsyncClientAuthen
protected void before() throws Throwable { protected void before() throws Throwable {
clientBuilder = Http2AsyncClientBuilder.create() clientBuilder = Http2AsyncClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.setConnectTimeout(TIMEOUT)
.build()) .build())
.setTlsStrategy(new DefaultClientTlsStrategy(SSLTestContexts.createClientSSLContext())); .setTlsStrategy(new DefaultClientTlsStrategy(SSLTestContexts.createClientSSLContext()));
} }

View File

@ -111,9 +111,9 @@ public abstract class LocalServerTestBase {
.build()); .build());
clientBuilder = HttpClientBuilder.create() clientBuilder = HttpClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setConnectionTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT)
.setConnectionRequestTimeout(TIMEOUT) .setConnectTimeout(TIMEOUT)
.build()) .build())
.setConnectionManager(connManager); .setConnectionManager(connManager);
} }

View File

@ -212,8 +212,8 @@ public class ClientConfiguration {
// Request configuration can be overridden at the request level. // Request configuration can be overridden at the request level.
// They will take precedence over the one set at the client level. // They will take precedence over the one set at the client level.
final RequestConfig requestConfig = RequestConfig.copy(defaultRequestConfig) final RequestConfig requestConfig = RequestConfig.copy(defaultRequestConfig)
.setConnectionTimeout(Timeout.ofSeconds(5))
.setConnectionRequestTimeout(Timeout.ofSeconds(5)) .setConnectionRequestTimeout(Timeout.ofSeconds(5))
.setConnectTimeout(Timeout.ofSeconds(5))
.setProxy(new HttpHost("myotherproxy", 8080)) .setProxy(new HttpHost("myotherproxy", 8080))
.build(); .build();
httpget.setConfig(requestConfig); httpget.setConfig(requestConfig);

View File

@ -42,7 +42,7 @@ import org.apache.hc.core5.util.Timeout;
public class RequestConfig implements Cloneable { public class RequestConfig implements Cloneable {
private static final Timeout DEFAULT_CONNECTION_REQUEST_TIMEOUT = Timeout.ofMinutes(3); private static final Timeout DEFAULT_CONNECTION_REQUEST_TIMEOUT = Timeout.ofMinutes(3);
private static final Timeout DEFAULT_CONNECTION_TIMEOUT = Timeout.ofMinutes(3); private static final Timeout DEFAULT_CONNECT_TIMEOUT = Timeout.ofMinutes(3);
public static final RequestConfig DEFAULT = new Builder().build(); public static final RequestConfig DEFAULT = new Builder().build();
@ -56,7 +56,7 @@ public class RequestConfig implements Cloneable {
private final Collection<String> targetPreferredAuthSchemes; private final Collection<String> targetPreferredAuthSchemes;
private final Collection<String> proxyPreferredAuthSchemes; private final Collection<String> proxyPreferredAuthSchemes;
private final Timeout connectionRequestTimeout; private final Timeout connectionRequestTimeout;
private final Timeout connectionTimeout; private final Timeout connectTimeout;
private final boolean contentCompressionEnabled; private final boolean contentCompressionEnabled;
private final boolean hardCancellationEnabled; private final boolean hardCancellationEnabled;
@ -64,7 +64,8 @@ public class RequestConfig implements Cloneable {
* Intended for CDI compatibility * Intended for CDI compatibility
*/ */
protected RequestConfig() { protected RequestConfig() {
this(false, null, null, false, false, 0, false, null, null, DEFAULT_CONNECTION_REQUEST_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT, false, false); this(false, null, null, false, false, 0, false, null, null,
DEFAULT_CONNECTION_REQUEST_TIMEOUT, DEFAULT_CONNECT_TIMEOUT, false, false);
} }
RequestConfig( RequestConfig(
@ -78,7 +79,7 @@ public class RequestConfig implements Cloneable {
final Collection<String> targetPreferredAuthSchemes, final Collection<String> targetPreferredAuthSchemes,
final Collection<String> proxyPreferredAuthSchemes, final Collection<String> proxyPreferredAuthSchemes,
final Timeout connectionRequestTimeout, final Timeout connectionRequestTimeout,
final Timeout connectionTimeout, final Timeout connectTimeout,
final boolean contentCompressionEnabled, final boolean contentCompressionEnabled,
final boolean hardCancellationEnabled) { final boolean hardCancellationEnabled) {
super(); super();
@ -92,7 +93,7 @@ public class RequestConfig implements Cloneable {
this.targetPreferredAuthSchemes = targetPreferredAuthSchemes; this.targetPreferredAuthSchemes = targetPreferredAuthSchemes;
this.proxyPreferredAuthSchemes = proxyPreferredAuthSchemes; this.proxyPreferredAuthSchemes = proxyPreferredAuthSchemes;
this.connectionRequestTimeout = connectionRequestTimeout; this.connectionRequestTimeout = connectionRequestTimeout;
this.connectionTimeout = connectionTimeout; this.connectTimeout = connectTimeout;
this.contentCompressionEnabled = contentCompressionEnabled; this.contentCompressionEnabled = contentCompressionEnabled;
this.hardCancellationEnabled = hardCancellationEnabled; this.hardCancellationEnabled = hardCancellationEnabled;
} }
@ -210,12 +211,10 @@ public class RequestConfig implements Cloneable {
} }
/** /**
* Returns the timeout in milliseconds used when requesting a connection * Returns the connection lease request timeout used when requesting
* from the connection manager. A timeout value of zero is interpreted * a connection from the connection manager.
* as an infinite timeout.
* <p> * <p>
* A timeout value of zero is interpreted as an infinite timeout. * A timeout value of zero is interpreted as an infinite timeout.
* A negative value is interpreted as undefined (system default).
* </p> * </p>
* <p> * <p>
* Default: 3 minutes. * Default: 3 minutes.
@ -226,9 +225,9 @@ public class RequestConfig implements Cloneable {
} }
/** /**
* Determines the timeout in milliseconds until a new connection is * Determines the timeout until a new connection is fully established.
* fully established or established connection transmits a data packet. * This may also include transport security negotiation exchanges
* A timeout value of zero is interpreted as an infinite timeout. * such as {@code SSL} or {@code TLS} protocol negotiation).
* <p> * <p>
* A timeout value of zero is interpreted as an infinite timeout. * A timeout value of zero is interpreted as an infinite timeout.
* A negative value is interpreted as undefined (system default). * A negative value is interpreted as undefined (system default).
@ -236,11 +235,9 @@ public class RequestConfig implements Cloneable {
* <p> * <p>
* Default: 3 minutes * Default: 3 minutes
* </p> * </p>
*
* @since 5.0
*/ */
public Timeout getConnectionTimeout() { public Timeout getConnectTimeout() {
return connectionTimeout; return connectTimeout;
} }
/** /**
@ -305,7 +302,7 @@ public class RequestConfig implements Cloneable {
builder.append(", targetPreferredAuthSchemes=").append(targetPreferredAuthSchemes); builder.append(", targetPreferredAuthSchemes=").append(targetPreferredAuthSchemes);
builder.append(", proxyPreferredAuthSchemes=").append(proxyPreferredAuthSchemes); builder.append(", proxyPreferredAuthSchemes=").append(proxyPreferredAuthSchemes);
builder.append(", connectionRequestTimeout=").append(connectionRequestTimeout); builder.append(", connectionRequestTimeout=").append(connectionRequestTimeout);
builder.append(", connectionTimeout=").append(connectionTimeout); builder.append(", connectTimeout=").append(connectTimeout);
builder.append(", contentCompressionEnabled=").append(contentCompressionEnabled); builder.append(", contentCompressionEnabled=").append(contentCompressionEnabled);
builder.append(", hardCancellationEnabled=").append(hardCancellationEnabled); builder.append(", hardCancellationEnabled=").append(hardCancellationEnabled);
builder.append("]"); builder.append("]");
@ -328,7 +325,7 @@ public class RequestConfig implements Cloneable {
.setTargetPreferredAuthSchemes(config.getTargetPreferredAuthSchemes()) .setTargetPreferredAuthSchemes(config.getTargetPreferredAuthSchemes())
.setProxyPreferredAuthSchemes(config.getProxyPreferredAuthSchemes()) .setProxyPreferredAuthSchemes(config.getProxyPreferredAuthSchemes())
.setConnectionRequestTimeout(config.getConnectionRequestTimeout()) .setConnectionRequestTimeout(config.getConnectionRequestTimeout())
.setConnectionTimeout(config.getConnectionTimeout()) .setConnectTimeout(config.getConnectTimeout())
.setContentCompressionEnabled(config.isContentCompressionEnabled()) .setContentCompressionEnabled(config.isContentCompressionEnabled())
.setHardCancellationEnabled(config.isHardCancellationEnabled()); .setHardCancellationEnabled(config.isHardCancellationEnabled());
} }
@ -345,7 +342,7 @@ public class RequestConfig implements Cloneable {
private Collection<String> targetPreferredAuthSchemes; private Collection<String> targetPreferredAuthSchemes;
private Collection<String> proxyPreferredAuthSchemes; private Collection<String> proxyPreferredAuthSchemes;
private Timeout connectionRequestTimeout; private Timeout connectionRequestTimeout;
private Timeout connectionTimeout; private Timeout connectTimeout;
private boolean contentCompressionEnabled; private boolean contentCompressionEnabled;
private boolean hardCancellationEnabled; private boolean hardCancellationEnabled;
@ -355,7 +352,7 @@ public class RequestConfig implements Cloneable {
this.maxRedirects = 50; this.maxRedirects = 50;
this.authenticationEnabled = true; this.authenticationEnabled = true;
this.connectionRequestTimeout = DEFAULT_CONNECTION_REQUEST_TIMEOUT; this.connectionRequestTimeout = DEFAULT_CONNECTION_REQUEST_TIMEOUT;
this.connectionTimeout = DEFAULT_CONNECTION_TIMEOUT; this.connectTimeout = DEFAULT_CONNECT_TIMEOUT;
this.contentCompressionEnabled = true; this.contentCompressionEnabled = true;
this.hardCancellationEnabled = true; this.hardCancellationEnabled = true;
} }
@ -415,13 +412,13 @@ public class RequestConfig implements Cloneable {
return this; return this;
} }
public Builder setConnectionTimeout(final Timeout connectionTimeout) { public Builder setConnectTimeout(final Timeout connectTimeout) {
this.connectionTimeout = connectionTimeout; this.connectTimeout = connectTimeout;
return this; return this;
} }
public Builder setConnectionTimeout(final long connectTimeout, final TimeUnit timeUnit) { public Builder setConnectTimeout(final long connectTimeout, final TimeUnit timeUnit) {
this.connectionTimeout = Timeout.of(connectTimeout, timeUnit); this.connectTimeout = Timeout.of(connectTimeout, timeUnit);
return this; return this;
} }
@ -447,7 +444,7 @@ public class RequestConfig implements Cloneable {
targetPreferredAuthSchemes, targetPreferredAuthSchemes,
proxyPreferredAuthSchemes, proxyPreferredAuthSchemes,
connectionRequestTimeout != null ? connectionRequestTimeout : DEFAULT_CONNECTION_REQUEST_TIMEOUT, connectionRequestTimeout != null ? connectionRequestTimeout : DEFAULT_CONNECTION_REQUEST_TIMEOUT,
connectionTimeout != null ? connectionTimeout : DEFAULT_CONNECTION_TIMEOUT, connectTimeout != null ? connectTimeout : DEFAULT_CONNECT_TIMEOUT,
contentCompressionEnabled, contentCompressionEnabled,
hardCancellationEnabled); hardCancellationEnabled);
} }

View File

@ -85,7 +85,7 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
if (sessionRef.get() == null) { if (sessionRef.get() == null) {
final HttpHost target = route.getTargetHost(); final HttpHost target = route.getTargetHost();
final RequestConfig requestConfig = context.getRequestConfig(); final RequestConfig requestConfig = context.getRequestConfig();
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
return Operations.cancellable(connPool.getSession( return Operations.cancellable(connPool.getSession(
target, target,
connectTimeout, connectTimeout,
@ -169,7 +169,7 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
} }
final HttpHost target = endpoint.target; final HttpHost target = endpoint.target;
final RequestConfig requestConfig = context.getRequestConfig(); final RequestConfig requestConfig = context.getRequestConfig();
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
return Operations.cancellable(connPool.getSession(target, connectTimeout, new FutureCallback<IOSession>() { return Operations.cancellable(connPool.getSession(target, connectTimeout, new FutureCallback<IOSession>() {
@Override @Override
@ -213,7 +213,7 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
} else { } else {
final HttpHost target = endpoint.target; final HttpHost target = endpoint.target;
final RequestConfig requestConfig = context.getRequestConfig(); final RequestConfig requestConfig = context.getRequestConfig();
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
connPool.getSession(target, connectTimeout, new FutureCallback<IOSession>() { connPool.getSession(target, connectTimeout, new FutureCallback<IOSession>() {
@Override @Override

View File

@ -192,7 +192,7 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
return Operations.nonCancellable(); return Operations.nonCancellable();
} }
final RequestConfig requestConfig = context.getRequestConfig(); final RequestConfig requestConfig = context.getRequestConfig();
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
return Operations.cancellable(manager.connect( return Operations.cancellable(manager.connect(
endpoint, endpoint,
connectionInitiator, connectionInitiator,
@ -224,7 +224,7 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
public void upgradeTls(final HttpClientContext context) { public void upgradeTls(final HttpClientContext context) {
final AsyncConnectionEndpoint endpoint = ensureValid(); final AsyncConnectionEndpoint endpoint = ensureValid();
final RequestConfig requestConfig = context.getRequestConfig(); final RequestConfig requestConfig = context.getRequestConfig();
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
if (TimeValue.isPositive(connectTimeout)) { if (TimeValue.isPositive(connectTimeout)) {
endpoint.setSocketTimeout(connectTimeout); endpoint.setSocketTimeout(connectTimeout);
} }

View File

@ -153,7 +153,7 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien
} else { } else {
requestConfig = clientContext.getRequestConfig(); requestConfig = clientContext.getRequestConfig();
} }
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
final HttpHost target = new HttpHost(request.getAuthority(), request.getScheme()); final HttpHost target = new HttpHost(request.getAuthority(), request.getScheme());
final Future<IOSession> sessionFuture = connPool.getSession(target, connectTimeout, new FutureCallback<IOSession>() { final Future<IOSession> sessionFuture = connPool.getSession(target, connectTimeout, new FutureCallback<IOSession>() {

View File

@ -210,7 +210,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
final HttpClientContext clientContext = HttpClientContext.adapt(context); final HttpClientContext clientContext = HttpClientContext.adapt(context);
final RequestConfig requestConfig = clientContext.getRequestConfig(); final RequestConfig requestConfig = clientContext.getRequestConfig();
final Timeout connectionRequestTimeout = requestConfig.getConnectionRequestTimeout(); final Timeout connectionRequestTimeout = requestConfig.getConnectionRequestTimeout();
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
final BasicFuture<AsyncClientEndpoint> future = new BasicFuture<>(callback); final BasicFuture<AsyncClientEndpoint> future = new BasicFuture<>(callback);
leaseEndpoint( leaseEndpoint(
host, host,
@ -264,7 +264,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
requestConfig = clientContext.getRequestConfig(); requestConfig = clientContext.getRequestConfig();
} }
final Timeout connectionRequestTimeout = requestConfig.getConnectionRequestTimeout(); final Timeout connectionRequestTimeout = requestConfig.getConnectionRequestTimeout();
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
final HttpHost target = new HttpHost(request.getAuthority(), request.getScheme()); final HttpHost target = new HttpHost(request.getAuthority(), request.getScheme());
final Future<AsyncConnectionEndpoint> leaseFuture = leaseEndpoint( final Future<AsyncConnectionEndpoint> leaseFuture = leaseEndpoint(

View File

@ -149,7 +149,7 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
} }
} }
final RequestConfig requestConfig = context.getRequestConfig(); final RequestConfig requestConfig = context.getRequestConfig();
final Timeout connectTimeout = requestConfig.getConnectionTimeout(); final Timeout connectTimeout = requestConfig.getConnectTimeout();
manager.connect(endpoint, connectTimeout, context); manager.connect(endpoint, connectTimeout, context);
} }
@ -174,7 +174,7 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
public void upgradeTls(final HttpClientContext context) throws IOException { public void upgradeTls(final HttpClientContext context) throws IOException {
final ConnectionEndpoint endpoint = ensureValid(); final ConnectionEndpoint endpoint = ensureValid();
final RequestConfig requestConfig = context.getRequestConfig(); final RequestConfig requestConfig = context.getRequestConfig();
final Timeout timeout = requestConfig.getConnectionTimeout(); final Timeout timeout = requestConfig.getConnectTimeout();
if (TimeValue.isPositive(timeout)) { if (TimeValue.isPositive(timeout)) {
endpoint.setSocketTimeout(timeout); endpoint.setSocketTimeout(timeout);
} }

View File

@ -49,7 +49,7 @@ public class TestRequestConfig {
@Test @Test
public void testDefaults() { public void testDefaults() {
final RequestConfig config = RequestConfig.DEFAULT; final RequestConfig config = RequestConfig.DEFAULT;
Assert.assertEquals(Timeout.ofMinutes(3), config.getConnectionTimeout()); Assert.assertEquals(Timeout.ofMinutes(3), config.getConnectTimeout());
Assert.assertEquals(Timeout.ofMinutes(3), config.getConnectionRequestTimeout()); Assert.assertEquals(Timeout.ofMinutes(3), config.getConnectionRequestTimeout());
Assert.assertEquals(false, config.isExpectContinueEnabled()); Assert.assertEquals(false, config.isExpectContinueEnabled());
Assert.assertEquals(true, config.isAuthenticationEnabled()); Assert.assertEquals(true, config.isAuthenticationEnabled());
@ -66,7 +66,7 @@ public class TestRequestConfig {
@Test @Test
public void testBuildAndCopy() throws Exception { public void testBuildAndCopy() throws Exception {
final RequestConfig config0 = RequestConfig.custom() final RequestConfig config0 = RequestConfig.custom()
.setConnectionTimeout(33, TimeUnit.MILLISECONDS) .setConnectTimeout(33, TimeUnit.MILLISECONDS)
.setConnectionRequestTimeout(44, TimeUnit.MILLISECONDS) .setConnectionRequestTimeout(44, TimeUnit.MILLISECONDS)
.setExpectContinueEnabled(true) .setExpectContinueEnabled(true)
.setAuthenticationEnabled(false) .setAuthenticationEnabled(false)
@ -80,7 +80,7 @@ public class TestRequestConfig {
.setContentCompressionEnabled(false) .setContentCompressionEnabled(false)
.build(); .build();
final RequestConfig config = RequestConfig.copy(config0).build(); final RequestConfig config = RequestConfig.copy(config0).build();
Assert.assertEquals(TimeValue.ofMillis(33), config.getConnectionTimeout()); Assert.assertEquals(TimeValue.ofMillis(33), config.getConnectTimeout());
Assert.assertEquals(TimeValue.ofMillis(44), config.getConnectionRequestTimeout()); Assert.assertEquals(TimeValue.ofMillis(44), config.getConnectionRequestTimeout());
Assert.assertEquals(true, config.isExpectContinueEnabled()); Assert.assertEquals(true, config.isExpectContinueEnabled());
Assert.assertEquals(false, config.isAuthenticationEnabled()); Assert.assertEquals(false, config.isAuthenticationEnabled());

View File

@ -82,8 +82,8 @@ public class TestInternalExecRuntime {
public void testAcquireEndpoint() throws Exception { public void testAcquireEndpoint() throws Exception {
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
final RequestConfig config = RequestConfig.custom() final RequestConfig config = RequestConfig.custom()
.setConnectionTimeout(123, TimeUnit.MILLISECONDS)
.setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS) .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
.setConnectTimeout(123, TimeUnit.MILLISECONDS)
.build(); .build();
context.setRequestConfig(config); context.setRequestConfig(config);
final HttpRoute route = new HttpRoute(new HttpHost("host", 80)); final HttpRoute route = new HttpRoute(new HttpHost("host", 80));
@ -248,8 +248,8 @@ public class TestInternalExecRuntime {
public void testConnectEndpoint() throws Exception { public void testConnectEndpoint() throws Exception {
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
final RequestConfig config = RequestConfig.custom() final RequestConfig config = RequestConfig.custom()
.setConnectionTimeout(123, TimeUnit.MILLISECONDS)
.setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS) .setConnectionRequestTimeout(345, TimeUnit.MILLISECONDS)
.setConnectTimeout(123, TimeUnit.MILLISECONDS)
.build(); .build();
context.setRequestConfig(config); context.setRequestConfig(config);