Upgraded HttpCore dependency to version 5.0-beta3
This commit is contained in:
parent
3aa9c1fd33
commit
1614c25168
|
@ -137,7 +137,8 @@
|
|||
<source>${maven.compiler.source}</source>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5-h2/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
|
|
|
@ -175,7 +175,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -305,7 +306,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse backendResponse, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse backendResponse,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final Date responseDate = getCurrentDate();
|
||||
backendResponse.addHeader("Via", generateViaHeader(backendResponse));
|
||||
|
||||
|
@ -342,7 +344,6 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
|
|||
private final AsyncExecCallback fallback;
|
||||
private final HttpResponse backendResponse;
|
||||
private final EntityDetails entityDetails;
|
||||
private final Date responseDate;
|
||||
private final AtomicBoolean writtenThrough;
|
||||
private final AtomicReference<ByteArrayBuffer> bufferRef;
|
||||
private final AtomicReference<AsyncDataConsumer> dataConsumerRef;
|
||||
|
@ -350,11 +351,9 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
|
|||
CachingAsyncDataConsumer(
|
||||
final AsyncExecCallback fallback,
|
||||
final HttpResponse backendResponse,
|
||||
final EntityDetails entityDetails,
|
||||
final Date responseDate) {
|
||||
final EntityDetails entityDetails) {
|
||||
this.fallback = fallback;
|
||||
this.backendResponse = backendResponse;
|
||||
this.responseDate = responseDate;
|
||||
this.entityDetails = entityDetails;
|
||||
this.writtenThrough = new AtomicBoolean(false);
|
||||
this.bufferRef = new AtomicReference<>(entityDetails != null ? new ByteArrayBuffer(1024) : null);
|
||||
|
@ -475,7 +474,7 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
|
|||
});
|
||||
final boolean cacheable = responseCachingPolicy.isResponseCacheable(request, backendResponse);
|
||||
if (cacheable) {
|
||||
cachingConsumerRef.set(new CachingAsyncDataConsumer(asyncExecCallback, backendResponse, entityDetails, responseDate));
|
||||
cachingConsumerRef.set(new CachingAsyncDataConsumer(asyncExecCallback, backendResponse, entityDetails));
|
||||
storeRequestIfModifiedSinceFor304Response(request, backendResponse);
|
||||
} else {
|
||||
log.debug("Backend response is not cacheable");
|
||||
|
@ -764,7 +763,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse backendResponse1, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse backendResponse1,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
|
||||
final Date responseDate1 = getCurrentDate();
|
||||
|
||||
|
@ -783,7 +783,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse backendResponse2, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse backendResponse2,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final Date responseDate2 = getCurrentDate();
|
||||
final AsyncExecCallback callback2 = evaluateResponse(backendResponse2, responseDate2);
|
||||
callbackRef.set(callback2);
|
||||
|
@ -966,7 +967,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse backendResponse, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse backendResponse,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final Date responseDate = getCurrentDate();
|
||||
backendResponse.addHeader("Via", generateViaHeader(backendResponse));
|
||||
|
||||
|
|
|
@ -124,7 +124,8 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase {
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
responseRef.set(response);
|
||||
return asyncExecCallback.handleResponse(response, entityDetails);
|
||||
}
|
||||
|
|
|
@ -122,7 +122,8 @@
|
|||
<source>${maven.compiler.source}</source>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5-h2/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
|
|
|
@ -106,7 +106,8 @@
|
|||
<source>${maven.compiler.source}</source>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5-h2/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.hc.client5.http.async.methods.SimpleBody;
|
|||
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
|
||||
import org.apache.hc.core5.http.ContentType;
|
||||
import org.apache.hc.core5.http.EntityDetails;
|
||||
import org.apache.hc.core5.http.HttpException;
|
||||
import org.apache.hc.core5.http.HttpRequest;
|
||||
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
|
||||
|
@ -53,6 +54,7 @@ public abstract class AbstractSimpleServerExchangeHandler extends AbstractServer
|
|||
@Override
|
||||
protected final AsyncRequestConsumer<SimpleHttpRequest> supplyConsumer(
|
||||
final HttpRequest request,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException {
|
||||
return new AbstractAsyncRequesterConsumer<SimpleHttpRequest, byte[]>(new BasicAsyncEntityConsumer()) {
|
||||
|
||||
|
@ -88,7 +90,7 @@ public abstract class AbstractSimpleServerExchangeHandler extends AbstractServer
|
|||
} else {
|
||||
entityProducer = null;
|
||||
}
|
||||
responseTrigger.submitResponse(new BasicResponseProducer(response, entityProducer));
|
||||
responseTrigger.submitResponse(new BasicResponseProducer(response, entityProducer), context);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class AsyncEchoHandler implements AsyncServerExchangeHandler {
|
|||
final BasicAsyncEntityProducer entityProducer = new BasicAsyncEntityProducer(content, contentType);
|
||||
entityProducerRef.set(entityProducer);
|
||||
try {
|
||||
responseChannel.sendResponse(new BasicHttpResponse(HttpStatus.SC_OK), entityProducer);
|
||||
responseChannel.sendResponse(new BasicHttpResponse(HttpStatus.SC_OK), entityProducer, context);
|
||||
} catch (final IOException | HttpException ex) {
|
||||
failed(ex);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class AsyncEchoHandler implements AsyncServerExchangeHandler {
|
|||
|
||||
});
|
||||
} else {
|
||||
responseChannel.sendResponse(new BasicHttpResponse(HttpStatus.SC_OK), null);
|
||||
responseChannel.sendResponse(new BasicHttpResponse(HttpStatus.SC_OK), null, context);
|
||||
entityConsumer.releaseResources();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class AsyncRandomHandler implements AsyncServerExchangeHandler {
|
|||
final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK);
|
||||
final AsyncEntityProducer entityProducer = new RandomBinAsyncEntityProducer(n);
|
||||
entityProducerRef.set(entityProducer);
|
||||
responseChannel.sendResponse(response, entityProducer);
|
||||
responseChannel.sendResponse(response, entityProducer, context);
|
||||
} else {
|
||||
throw new ProtocolException("Invalid request path: " + path);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class AuthenticatingAsyncDecorator implements AsyncServerExchangeHandler
|
|||
|
||||
if (authenticated) {
|
||||
if (expectContinue) {
|
||||
responseChannel.sendInformation(new BasicClassicHttpResponse(HttpStatus.SC_CONTINUE));
|
||||
responseChannel.sendInformation(new BasicClassicHttpResponse(HttpStatus.SC_CONTINUE), context);
|
||||
}
|
||||
exchangeHandler.handleRequest(request, entityDetails, responseChannel, context);
|
||||
} else {
|
||||
|
@ -103,7 +103,7 @@ public class AuthenticatingAsyncDecorator implements AsyncServerExchangeHandler
|
|||
unauthorized,
|
||||
new BasicAsyncEntityProducer("Unauthorized", ContentType.TEXT_PLAIN));
|
||||
responseProducerRef.set(responseProducer);
|
||||
responseProducer.sendResponse(responseChannel);
|
||||
responseProducer.sendResponse(responseChannel, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.hc.core5.http.config.H1Config;
|
|||
import org.apache.hc.core5.http.impl.HttpProcessors;
|
||||
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
|
||||
import org.apache.hc.core5.http.protocol.HttpProcessor;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.ListenerEndpoint;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.ExternalResource;
|
||||
|
@ -99,7 +99,7 @@ public abstract class AbstractHttp1IntegrationTestBase extends AbstractServerTes
|
|||
@Override
|
||||
protected void after() {
|
||||
if (httpclient != null) {
|
||||
httpclient.shutdown(ShutdownType.GRACEFUL);
|
||||
httpclient.shutdown(CloseMode.GRACEFUL);
|
||||
httpclient = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.hc.core5.http.config.H1Config;
|
|||
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
|
||||
import org.apache.hc.core5.http.protocol.HttpProcessor;
|
||||
import org.apache.hc.core5.http2.config.H2Config;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.ListenerEndpoint;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.ExternalResource;
|
||||
|
@ -63,7 +63,7 @@ public abstract class AbstractIntegrationTestBase<T extends CloseableHttpAsyncCl
|
|||
@Override
|
||||
protected void after() {
|
||||
if (httpclient != null) {
|
||||
httpclient.shutdown(ShutdownType.GRACEFUL);
|
||||
httpclient.shutdown(CloseMode.GRACEFUL);
|
||||
httpclient = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,10 +40,10 @@ import org.apache.hc.client5.testing.classic.RandomHandler;
|
|||
import org.apache.hc.core5.function.Decorator;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.URIScheme;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.io.HttpServerRequestHandler;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpProcessor;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.testing.classic.ClassicTestServer;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
import org.junit.Rule;
|
||||
|
@ -87,7 +87,7 @@ public abstract class LocalServerTestBase {
|
|||
protected void after() {
|
||||
if (server != null) {
|
||||
try {
|
||||
server.shutdown(ShutdownType.IMMEDIATE);
|
||||
server.shutdown(CloseMode.IMMEDIATE);
|
||||
server = null;
|
||||
} catch (final Exception ignore) {
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ import org.apache.hc.core5.http.impl.bootstrap.SSLServerSetupHandler;
|
|||
import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
|
||||
import org.apache.hc.core5.http.protocol.BasicHttpContext;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.ssl.SSLContexts;
|
||||
import org.apache.hc.core5.ssl.TrustStrategy;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
|
@ -72,7 +72,7 @@ public class TestSSLSocketFactory {
|
|||
@After
|
||||
public void shutDown() throws Exception {
|
||||
if (this.server != null) {
|
||||
this.server.shutdown(ShutdownType.GRACEFUL);
|
||||
this.server.close(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,9 @@
|
|||
<quiet>true</quiet>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/6/docs/api/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/</link>
|
||||
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5-h2/apidocs/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
<reportSets>
|
||||
|
|
|
@ -134,7 +134,8 @@
|
|||
<source>${maven.compiler.source}</source>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5/apidocs/</link>
|
||||
<link>http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5-h2/apidocs/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
<reportSets>
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
|||
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
|
||||
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
|
||||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
|
||||
/**
|
||||
* A simple example that uses HttpClient to execute an HTTP request against
|
||||
|
@ -83,7 +83,7 @@ public class AsyncClientAuthentication {
|
|||
future.get();
|
||||
|
||||
System.out.println("Shutting down");
|
||||
httpclient.shutdown(ShutdownType.GRACEFUL);
|
||||
httpclient.shutdown(CloseMode.GRACEFUL);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
|||
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
|
||||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
@ -121,7 +121,7 @@ public class AsyncClientConnectionEviction {
|
|||
future2.get();
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.apache.hc.client5.http.ssl.H2TlsStrategy;
|
|||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.ssl.SSLContexts;
|
||||
import org.apache.hc.core5.ssl.TrustStrategy;
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class AsyncClientCustomSSL {
|
|||
future.get();
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,10 @@ import org.apache.hc.core5.http.nio.DataStreamChannel;
|
|||
import org.apache.hc.core5.http.nio.RequestChannel;
|
||||
import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
|
||||
import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.http2.config.H2Config;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -101,8 +102,8 @@ public class AsyncClientFullDuplexExchange {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void produceRequest(final RequestChannel channel) throws HttpException, IOException {
|
||||
requestProducer.sendRequest(channel);
|
||||
public void produceRequest(final RequestChannel channel, final HttpContext context) throws HttpException, IOException {
|
||||
requestProducer.sendRequest(channel, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,14 +117,19 @@ public class AsyncClientFullDuplexExchange {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void consumeInformation(final HttpResponse response) throws HttpException, IOException {
|
||||
public void consumeInformation(
|
||||
final HttpResponse response,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
System.out.println(requestUri + "->" + response.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeResponse(final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
public void consumeResponse(
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
System.out.println(requestUri + "->" + response.getCode());
|
||||
responseConsumer.consumeResponse(response, entityDetails, null);
|
||||
responseConsumer.consumeResponse(response, entityDetails, context, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,7 +151,7 @@ public class AsyncClientFullDuplexExchange {
|
|||
latch.await(1, TimeUnit.MINUTES);
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.apache.hc.core5.http.HttpHost;
|
|||
import org.apache.hc.core5.http.config.H1Config;
|
||||
import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
|
||||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class AsyncClientHttp1Pipelining {
|
|||
}
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,9 +48,10 @@ import org.apache.hc.core5.http.nio.DataStreamChannel;
|
|||
import org.apache.hc.core5.http.nio.RequestChannel;
|
||||
import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
|
||||
import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.http2.config.H2Config;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -97,8 +98,8 @@ public class AsyncClientHttp2FullDuplexExchange {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void produceRequest(final RequestChannel channel) throws HttpException, IOException {
|
||||
requestProducer.sendRequest(channel);
|
||||
public void produceRequest(final RequestChannel channel, final HttpContext context) throws HttpException, IOException {
|
||||
requestProducer.sendRequest(channel, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,14 +113,19 @@ public class AsyncClientHttp2FullDuplexExchange {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void consumeInformation(final HttpResponse response) throws HttpException, IOException {
|
||||
public void consumeInformation(
|
||||
final HttpResponse response,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
System.out.println(requestUri + "->" + response.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeResponse(final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
public void consumeResponse(
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
System.out.println(requestUri + "->" + response.getCode());
|
||||
responseConsumer.consumeResponse(response, entityDetails, null);
|
||||
responseConsumer.consumeResponse(response, entityDetails, context, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,7 +147,7 @@ public class AsyncClientHttp2FullDuplexExchange {
|
|||
latch.await(1, TimeUnit.MINUTES);
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.apache.hc.core5.http.HttpHost;
|
|||
import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
|
||||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.http2.config.H2Config;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class AsyncClientHttp2Multiplexing {
|
|||
}
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.apache.hc.core5.http.message.StatusLine;
|
|||
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
|
||||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.http2.config.H2Config;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -159,7 +159,7 @@ public class AsyncClientHttp2ServerPush {
|
|||
future.get();
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
|
|||
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
|
||||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class AsyncClientHttpExchange {
|
|||
}
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.hc.core5.http.HttpException;
|
|||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.message.StatusLine;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class AsyncClientHttpExchangeStreaming {
|
|||
}
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ import org.apache.hc.core5.http.message.BasicHttpResponse;
|
|||
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
|
||||
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class AsyncClientInterceptors {
|
|||
}
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.apache.hc.core5.http.nio.AsyncEntityProducer;
|
|||
import org.apache.hc.core5.http.nio.AsyncRequestProducer;
|
||||
import org.apache.hc.core5.http.nio.entity.DigestingEntityProducer;
|
||||
import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class AsyncClientMessageTrailers {
|
|||
future.get();
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.hc.core5.concurrent.FutureCallback;
|
|||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.ssl.SSLContexts;
|
||||
|
||||
/**
|
||||
|
@ -113,7 +113,7 @@ public class AsyncClientTlsAlpn {
|
|||
future.get();
|
||||
|
||||
System.out.println("Shutting down");
|
||||
client.shutdown(ShutdownType.GRACEFUL);
|
||||
client.shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ import org.apache.hc.core5.http.config.CharCodingConfig;
|
|||
import org.apache.hc.core5.http.config.H1Config;
|
||||
import org.apache.hc.core5.http.config.Registry;
|
||||
import org.apache.hc.core5.http.config.RegistryBuilder;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.impl.io.DefaultClassicHttpResponseFactory;
|
||||
import org.apache.hc.core5.http.impl.io.DefaultHttpRequestWriterFactory;
|
||||
import org.apache.hc.core5.http.impl.io.DefaultHttpResponseParser;
|
||||
|
@ -74,6 +73,7 @@ import org.apache.hc.core5.http.io.HttpConnectionFactory;
|
|||
import org.apache.hc.core5.http.io.HttpMessageParser;
|
||||
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
|
||||
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.io.entity.EntityUtils;
|
||||
import org.apache.hc.core5.http.message.BasicHeader;
|
||||
import org.apache.hc.core5.http.message.BasicLineParser;
|
||||
|
|
|
@ -35,7 +35,9 @@ import org.apache.hc.core5.http.nio.AsyncDataConsumer;
|
|||
|
||||
public interface AsyncExecCallback {
|
||||
|
||||
AsyncDataConsumer handleResponse(HttpResponse response, EntityDetails entityDetails) throws HttpException, IOException;
|
||||
AsyncDataConsumer handleResponse(
|
||||
HttpResponse response,
|
||||
EntityDetails entityDetails) throws HttpException, IOException;
|
||||
|
||||
void completed();
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.hc.core5.http.HttpRequest;
|
|||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
|
||||
import org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
|
||||
public abstract class AbstractBinPushConsumer extends AbstractBinDataConsumer implements AsyncPushConsumer {
|
||||
|
||||
|
@ -46,7 +47,8 @@ public abstract class AbstractBinPushConsumer extends AbstractBinDataConsumer im
|
|||
public final void consumePromise(
|
||||
final HttpRequest promise,
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
if (entityDetails != null) {
|
||||
final ContentType contentType;
|
||||
try {
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.hc.core5.http.HttpException;
|
|||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
|
||||
import org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
|
||||
public abstract class AbstractBinResponseConsumer<T> extends AbstractBinDataConsumer implements AsyncResponseConsumer<T> {
|
||||
|
||||
|
@ -46,10 +47,17 @@ public abstract class AbstractBinResponseConsumer<T> extends AbstractBinDataCons
|
|||
|
||||
protected abstract T buildResult();
|
||||
|
||||
@Override
|
||||
public void informationResponse(
|
||||
final HttpResponse response,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void consumeResponse(
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context,
|
||||
final FutureCallback<T> resultCallback) throws HttpException, IOException {
|
||||
this.resultCallback = resultCallback;
|
||||
if (entityDetails != null) {
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.hc.core5.http.HttpRequest;
|
|||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
|
||||
import org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
|
||||
public abstract class AbstractCharPushConsumer extends AbstractCharDataConsumer implements AsyncPushConsumer {
|
||||
|
||||
|
@ -48,7 +49,8 @@ public abstract class AbstractCharPushConsumer extends AbstractCharDataConsumer
|
|||
public final void consumePromise(
|
||||
final HttpRequest promise,
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
if (entityDetails != null) {
|
||||
final ContentType contentType;
|
||||
try {
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.hc.core5.http.HttpException;
|
|||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
|
||||
import org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
|
||||
public abstract class AbstractCharResponseConsumer<T> extends AbstractCharDataConsumer implements AsyncResponseConsumer<T> {
|
||||
|
||||
|
@ -48,10 +49,17 @@ public abstract class AbstractCharResponseConsumer<T> extends AbstractCharDataCo
|
|||
|
||||
protected abstract T buildResult() throws IOException;
|
||||
|
||||
@Override
|
||||
public void informationResponse(
|
||||
final HttpResponse response,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void consumeResponse(
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context,
|
||||
final FutureCallback<T> resultCallback) throws HttpException, IOException {
|
||||
this.resultCallback = resultCallback;
|
||||
if (entityDetails != null) {
|
||||
|
|
|
@ -26,11 +26,15 @@
|
|||
*/
|
||||
package org.apache.hc.client5.http.async.methods;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.hc.core5.http.ContentType;
|
||||
import org.apache.hc.core5.http.HttpException;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.nio.AsyncEntityConsumer;
|
||||
import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityConsumer;
|
||||
import org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
|
||||
public final class SimpleResponseConsumer extends AbstractAsyncResponseConsumer<SimpleHttpResponse, byte[]> {
|
||||
|
||||
|
@ -42,6 +46,10 @@ public final class SimpleResponseConsumer extends AbstractAsyncResponseConsumer<
|
|||
return new SimpleResponseConsumer(new BasicAsyncEntityConsumer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informationResponse(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SimpleHttpResponse buildResult(final HttpResponse response, final byte[] entity, final ContentType contentType) {
|
||||
final SimpleHttpResponse simpleResponse = SimpleHttpResponse.copy(response);
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
|
||||
import org.apache.hc.core5.function.Supplier;
|
||||
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
||||
import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
|
||||
import org.apache.hc.core5.reactor.ExceptionEvent;
|
||||
|
@ -120,17 +120,17 @@ abstract class AbstractHttpAsyncClientBase extends CloseableHttpAsyncClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final void shutdown(final ShutdownType shutdownType) {
|
||||
public final void shutdown(final CloseMode closeMode) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Shutdown " + shutdownType);
|
||||
log.debug("Shutdown " + closeMode);
|
||||
}
|
||||
ioReactor.initiateShutdown();
|
||||
ioReactor.shutdown(shutdownType);
|
||||
ioReactor.close(closeMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
shutdown(ShutdownType.GRACEFUL);
|
||||
shutdown(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -247,7 +247,8 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
return asyncExecCallback.handleResponse(response, entityDetails);
|
||||
}
|
||||
|
||||
|
@ -326,7 +327,8 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
|
||||
clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
|
||||
proxyHttpProcessor.process(response, entityDetails, clientContext);
|
||||
|
|
|
@ -171,7 +171,8 @@ class AsyncProtocolExec implements AsyncExecChainHandler {
|
|||
|
||||
@Override
|
||||
public AsyncDataConsumer handleResponse(
|
||||
final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
|
||||
clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
|
||||
httpProcessor.process(response, entityDetails, clientContext);
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.hc.core5.http.nio.AsyncPushConsumer;
|
|||
import org.apache.hc.core5.http.nio.AsyncRequestProducer;
|
||||
import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.ExceptionEvent;
|
||||
import org.apache.hc.core5.reactor.IOReactorStatus;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
|
@ -69,7 +69,7 @@ public abstract class CloseableHttpAsyncClient implements HttpAsyncClient, Close
|
|||
|
||||
public abstract void initiateShutdown();
|
||||
|
||||
public abstract void shutdown(ShutdownType shutdownType);
|
||||
public abstract void shutdown(CloseMode closeMode);
|
||||
|
||||
public final <T> Future<T> execute(
|
||||
final AsyncRequestProducer requestProducer,
|
||||
|
|
|
@ -105,7 +105,8 @@ import org.apache.hc.core5.http2.nio.pool.H2ConnPool;
|
|||
import org.apache.hc.core5.http2.protocol.H2RequestConnControl;
|
||||
import org.apache.hc.core5.http2.protocol.H2RequestContent;
|
||||
import org.apache.hc.core5.http2.protocol.H2RequestTargetHost;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.Command;
|
||||
import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
|
||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
|
@ -720,7 +721,7 @@ public class Http2AsyncClientBuilder {
|
|||
|
||||
@Override
|
||||
public void execute(final IOSession ioSession) {
|
||||
ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
|
||||
ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.apache.hc.core5.http2.impl.nio.Http2OnlyClientProtocolNegotiator;
|
|||
import org.apache.hc.core5.http2.impl.nio.Http2StreamListener;
|
||||
import org.apache.hc.core5.reactor.IOEventHandler;
|
||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||
import org.apache.hc.core5.reactor.TlsCapableIOSession;
|
||||
import org.apache.hc.core5.reactor.ProtocolIOSession;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -81,7 +81,7 @@ class Http2AsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IOEventHandler createHandler(final TlsCapableIOSession ioSession, final Object attachment) {
|
||||
public IOEventHandler createHandler(final ProtocolIOSession ioSession, final Object attachment) {
|
||||
final Logger sessionLog = LoggerFactory.getLogger(ioSession.getClass());
|
||||
if (sessionLog.isDebugEnabled()
|
||||
|| wireLog.isDebugEnabled()
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.apache.hc.core5.http.nio.AsyncEntityProducer;
|
|||
import org.apache.hc.core5.http.nio.CapacityChannel;
|
||||
import org.apache.hc.core5.http.nio.DataStreamChannel;
|
||||
import org.apache.hc.core5.http.nio.RequestChannel;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -97,8 +98,8 @@ class Http2AsyncMainClientExec implements AsyncExecChainHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void produceRequest(final RequestChannel channel) throws HttpException, IOException {
|
||||
channel.sendRequest(request, entityProducer);
|
||||
public void produceRequest(final RequestChannel channel, final HttpContext context) throws HttpException, IOException {
|
||||
channel.sendRequest(request, entityProducer, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,11 +113,14 @@ class Http2AsyncMainClientExec implements AsyncExecChainHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void consumeInformation(final HttpResponse response) throws HttpException, IOException {
|
||||
public void consumeInformation(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeResponse(final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
public void consumeResponse(
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
entityConsumerRef.set(asyncExecCallback.handleResponse(response, entityDetails));
|
||||
if (entityDetails == null) {
|
||||
execRuntime.validateConnection();
|
||||
|
|
|
@ -114,8 +114,9 @@ import org.apache.hc.core5.http2.config.H2Config;
|
|||
import org.apache.hc.core5.http2.protocol.H2RequestConnControl;
|
||||
import org.apache.hc.core5.http2.protocol.H2RequestContent;
|
||||
import org.apache.hc.core5.http2.protocol.H2RequestTargetHost;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.pool.ConnPoolControl;
|
||||
import org.apache.hc.core5.reactor.Command;
|
||||
import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
|
||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
|
@ -926,7 +927,7 @@ public class HttpAsyncClientBuilder {
|
|||
|
||||
@Override
|
||||
public void execute(final IOSession ioSession) {
|
||||
ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
|
||||
ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -62,7 +62,7 @@ import org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiator;
|
|||
import org.apache.hc.core5.http2.impl.nio.Http2StreamListener;
|
||||
import org.apache.hc.core5.reactor.IOEventHandler;
|
||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||
import org.apache.hc.core5.reactor.TlsCapableIOSession;
|
||||
import org.apache.hc.core5.reactor.ProtocolIOSession;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -110,7 +110,7 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IOEventHandler createHandler(final TlsCapableIOSession ioSession, final Object attachment) {
|
||||
public IOEventHandler createHandler(final ProtocolIOSession ioSession, final Object attachment) {
|
||||
final Logger sessionLog = LoggerFactory.getLogger(ioSession.getClass());
|
||||
if (sessionLog.isDebugEnabled()
|
||||
|| streamLog.isDebugEnabled()
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.apache.hc.core5.http.nio.AsyncEntityProducer;
|
|||
import org.apache.hc.core5.http.nio.CapacityChannel;
|
||||
import org.apache.hc.core5.http.nio.DataStreamChannel;
|
||||
import org.apache.hc.core5.http.nio.RequestChannel;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -113,8 +114,10 @@ class HttpAsyncMainClientExec implements AsyncExecChainHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void produceRequest(final RequestChannel channel) throws HttpException, IOException {
|
||||
channel.sendRequest(request, entityProducer);
|
||||
public void produceRequest(
|
||||
final RequestChannel channel,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
channel.sendRequest(request, entityProducer, context);
|
||||
if (entityProducer == null) {
|
||||
messageCountDown.decrementAndGet();
|
||||
}
|
||||
|
@ -159,11 +162,16 @@ class HttpAsyncMainClientExec implements AsyncExecChainHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void consumeInformation(final HttpResponse response) throws HttpException, IOException {
|
||||
public void consumeInformation(
|
||||
final HttpResponse response,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeResponse(final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
public void consumeResponse(
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
entityConsumerRef.set(asyncExecCallback.handleResponse(response, entityDetails));
|
||||
if (response.getCode() >= HttpStatus.SC_CLIENT_ERROR) {
|
||||
messageCountDown.decrementAndGet();
|
||||
|
|
|
@ -146,7 +146,8 @@ abstract class InternalAbstractHttpAsyncClient extends AbstractHttpAsyncClientBa
|
|||
@Override
|
||||
public void sendRequest(
|
||||
final HttpRequest request,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
|
||||
RequestConfig requestConfig = null;
|
||||
if (request instanceof Configurable) {
|
||||
|
@ -237,7 +238,7 @@ abstract class InternalAbstractHttpAsyncClient extends AbstractHttpAsyncClientBa
|
|||
outputTerminated.set(true);
|
||||
requestProducer.releaseResources();
|
||||
}
|
||||
responseConsumer.consumeResponse(response, entityDetails,
|
||||
responseConsumer.consumeResponse(response, entityDetails, context,
|
||||
new FutureCallback<T>() {
|
||||
|
||||
@Override
|
||||
|
@ -293,7 +294,7 @@ abstract class InternalAbstractHttpAsyncClient extends AbstractHttpAsyncClientBa
|
|||
});
|
||||
}
|
||||
|
||||
});
|
||||
}, context);
|
||||
} catch (final HttpException | IOException ex) {
|
||||
future.failed(ex);
|
||||
}
|
||||
|
|
|
@ -41,9 +41,10 @@ import org.apache.hc.core5.concurrent.ComplexCancellable;
|
|||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
|
||||
import org.apache.hc.core5.http.nio.command.ExecutionCommand;
|
||||
import org.apache.hc.core5.http.nio.command.RequestExecutionCommand;
|
||||
import org.apache.hc.core5.http2.nio.pool.H2ConnPool;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.Command;
|
||||
import org.apache.hc.core5.reactor.IOSession;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -108,7 +109,7 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
|
|||
public void releaseConnection() {
|
||||
final Endpoint endpoint = sessionRef.getAndSet(null);
|
||||
if (endpoint != null && !reusable) {
|
||||
endpoint.session.shutdown(ShutdownType.GRACEFUL);
|
||||
endpoint.session.close(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +117,7 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
|
|||
public void discardConnection() {
|
||||
final Endpoint endpoint = sessionRef.getAndSet(null);
|
||||
if (endpoint != null) {
|
||||
endpoint.session.shutdown(ShutdownType.GRACEFUL);
|
||||
endpoint.session.close(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
|
|||
}
|
||||
final Endpoint endpoint = sessionRef.getAndSet(null);
|
||||
if (endpoint != null) {
|
||||
endpoint.session.shutdown(ShutdownType.GRACEFUL);
|
||||
endpoint.session.close(CloseMode.GRACEFUL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -196,7 +197,9 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
|
|||
if (log.isDebugEnabled()) {
|
||||
log.debug(ConnPoolSupport.getId(endpoint) + ": executing " + ConnPoolSupport.getId(exchangeHandler));
|
||||
}
|
||||
session.addLast(new ExecutionCommand(exchangeHandler, complexCancellable, context));
|
||||
session.enqueue(
|
||||
new RequestExecutionCommand(exchangeHandler, null, complexCancellable, context),
|
||||
Command.Priority.NORMAL);
|
||||
} else {
|
||||
final HttpHost target = endpoint.target;
|
||||
final RequestConfig requestConfig = context.getRequestConfig();
|
||||
|
@ -209,7 +212,9 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
|
|||
if (log.isDebugEnabled()) {
|
||||
log.debug(ConnPoolSupport.getId(endpoint) + ": executing " + ConnPoolSupport.getId(exchangeHandler));
|
||||
}
|
||||
session.addLast(new ExecutionCommand(exchangeHandler, complexCancellable, context));
|
||||
session.enqueue(
|
||||
new RequestExecutionCommand(exchangeHandler, null, complexCancellable, context),
|
||||
Command.Priority.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
|
|||
import org.apache.hc.core5.http.nio.CapacityChannel;
|
||||
import org.apache.hc.core5.http.nio.DataStreamChannel;
|
||||
import org.apache.hc.core5.http.nio.RequestChannel;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.util.Identifiable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
@ -67,21 +68,22 @@ final class LoggingAsyncClientExchangeHandler implements AsyncClientExchangeHand
|
|||
}
|
||||
|
||||
@Override
|
||||
public void produceRequest(final RequestChannel channel) throws HttpException, IOException {
|
||||
public void produceRequest(final RequestChannel channel, final HttpContext context) throws HttpException, IOException {
|
||||
handler.produceRequest(new RequestChannel() {
|
||||
|
||||
@Override
|
||||
public void sendRequest(
|
||||
final HttpRequest request,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(exchangeId + ": send request " + new RequestLine(request) + ", " +
|
||||
(entityDetails != null ? "entity len " + entityDetails.getContentLength() : "null entity"));
|
||||
}
|
||||
channel.sendRequest(request, entityDetails);
|
||||
channel.sendRequest(request, entityDetails, context);
|
||||
}
|
||||
|
||||
});
|
||||
}, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,22 +131,25 @@ final class LoggingAsyncClientExchangeHandler implements AsyncClientExchangeHand
|
|||
}
|
||||
|
||||
@Override
|
||||
public void consumeInformation(final HttpResponse response) throws HttpException, IOException {
|
||||
public void consumeInformation(
|
||||
final HttpResponse response,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(exchangeId + ": information response " + new StatusLine(response));
|
||||
}
|
||||
handler.consumeInformation(response);
|
||||
handler.consumeInformation(response, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeResponse(
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(exchangeId + ": consume response " + new StatusLine(response) + ", " +
|
||||
(entityDetails != null ? "entity len " + entityDetails.getContentLength() : " null entity"));
|
||||
}
|
||||
handler.consumeResponse(response, entityDetails);
|
||||
handler.consumeResponse(response, entityDetails, context);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,29 +32,31 @@ import java.net.SocketAddress;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ByteChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.apache.hc.client5.http.impl.Wire;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.net.NamedEndpoint;
|
||||
import org.apache.hc.core5.reactor.Command;
|
||||
import org.apache.hc.core5.reactor.IOEventHandler;
|
||||
import org.apache.hc.core5.reactor.TlsCapableIOSession;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
|
||||
import org.apache.hc.core5.reactor.ProtocolIOSession;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
|
||||
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
class LoggingIOSession implements TlsCapableIOSession {
|
||||
class LoggingIOSession implements ProtocolIOSession {
|
||||
|
||||
private final Logger log;
|
||||
private final Wire wireLog;
|
||||
private final String id;
|
||||
private final TlsCapableIOSession session;
|
||||
private final ProtocolIOSession session;
|
||||
private final ByteChannel channel;
|
||||
|
||||
public LoggingIOSession(final TlsCapableIOSession session, final String id, final Logger log, final Logger wireLog) {
|
||||
public LoggingIOSession(final ProtocolIOSession session, final String id, final Logger log, final Logger wireLog) {
|
||||
super();
|
||||
this.session = session;
|
||||
this.id = id;
|
||||
|
@ -63,7 +65,7 @@ class LoggingIOSession implements TlsCapableIOSession {
|
|||
this.channel = new LoggingByteChannel();
|
||||
}
|
||||
|
||||
public LoggingIOSession(final TlsCapableIOSession session, final String id, final Logger log) {
|
||||
public LoggingIOSession(final ProtocolIOSession session, final String id, final Logger log) {
|
||||
this(session, id, log, null);
|
||||
}
|
||||
|
||||
|
@ -73,18 +75,23 @@ class LoggingIOSession implements TlsCapableIOSession {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addLast(final Command command) {
|
||||
this.session.addLast(command);
|
||||
public Lock lock() {
|
||||
return this.session.lock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFirst(final Command command) {
|
||||
this.session.addFirst(command);
|
||||
public boolean hasCommands() {
|
||||
return this.session.hasCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command getCommand() {
|
||||
return this.session.getCommand();
|
||||
public Command poll() {
|
||||
return this.session.poll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enqueue(final Command command, final Command.Priority priority) {
|
||||
this.session.enqueue(command, priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,29 +176,29 @@ class LoggingIOSession implements TlsCapableIOSession {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(final ShutdownType shutdownType) {
|
||||
public void close(final CloseMode closeMode) {
|
||||
if (this.log.isDebugEnabled()) {
|
||||
this.log.debug(this.id + " " + this.session + ": Shutdown " + shutdownType);
|
||||
this.log.debug(this.id + " " + this.session + ": Close " + closeMode);
|
||||
}
|
||||
this.session.shutdown(shutdownType);
|
||||
this.session.close(closeMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSocketTimeout() {
|
||||
return this.session.getSocketTimeout();
|
||||
public int getSocketTimeoutMillis() {
|
||||
return this.session.getSocketTimeoutMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSocketTimeout(final int timeout) {
|
||||
public void setSocketTimeoutMillis(final int timeout) {
|
||||
if (this.log.isDebugEnabled()) {
|
||||
this.log.debug(this.id + " " + this.session + ": Set timeout " + timeout);
|
||||
}
|
||||
this.session.setSocketTimeout(timeout);
|
||||
this.session.setSocketTimeoutMillis(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastReadTime() {
|
||||
return this.session.getLastReadTime();
|
||||
public long getLastReadTimeMillis() {
|
||||
return this.session.getLastReadTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,17 +222,18 @@ class LoggingIOSession implements TlsCapableIOSession {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setHandler(final IOEventHandler handler) {
|
||||
this.session.setHandler(handler);
|
||||
public void upgrade(final IOEventHandler handler) {
|
||||
this.session.upgrade(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startTls(
|
||||
final SSLContext sslContext,
|
||||
final SSLBufferManagement sslBufferManagement,
|
||||
final NamedEndpoint endpoint,
|
||||
final SSLBufferMode sslBufferMode,
|
||||
final SSLSessionInitializer initializer,
|
||||
final SSLSessionVerifier verifier) throws UnsupportedOperationException {
|
||||
session.startTls(sslContext, sslBufferManagement, initializer, verifier);
|
||||
session.startTls(sslContext, endpoint, sslBufferMode, initializer, verifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,12 +56,13 @@ import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
|
|||
import org.apache.hc.core5.http.nio.CapacityChannel;
|
||||
import org.apache.hc.core5.http.nio.DataStreamChannel;
|
||||
import org.apache.hc.core5.http.nio.RequestChannel;
|
||||
import org.apache.hc.core5.http.nio.command.ExecutionCommand;
|
||||
import org.apache.hc.core5.http.nio.command.RequestExecutionCommand;
|
||||
import org.apache.hc.core5.http.nio.command.ShutdownCommand;
|
||||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.http2.nio.pool.H2ConnPool;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.Command;
|
||||
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
||||
import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
|
||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||
|
@ -92,7 +93,7 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien
|
|||
|
||||
@Override
|
||||
public void execute(final IOSession ioSession) {
|
||||
ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
|
||||
ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE);
|
||||
}
|
||||
|
||||
}),
|
||||
|
@ -122,7 +123,8 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien
|
|||
@Override
|
||||
public void sendRequest(
|
||||
final HttpRequest request,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
RequestConfig requestConfig = null;
|
||||
if (request instanceof Configurable) {
|
||||
requestConfig = ((Configurable) request).getConfig();
|
||||
|
@ -158,8 +160,9 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien
|
|||
|
||||
@Override
|
||||
public void produceRequest(
|
||||
final RequestChannel channel) throws HttpException, IOException {
|
||||
channel.sendRequest(request, entityDetails);
|
||||
final RequestChannel channel,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
channel.sendRequest(request, entityDetails, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,14 +177,17 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien
|
|||
|
||||
@Override
|
||||
public void consumeInformation(
|
||||
final HttpResponse response) throws HttpException, IOException {
|
||||
exchangeHandler.consumeInformation(response);
|
||||
final HttpResponse response,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
exchangeHandler.consumeInformation(response, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeResponse(
|
||||
final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
exchangeHandler.consumeResponse(response, entityDetails);
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
exchangeHandler.consumeResponse(response, entityDetails, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,11 +209,15 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien
|
|||
if (log.isDebugEnabled()) {
|
||||
final String exchangeId = ExecSupport.getNextExchangeId();
|
||||
log.debug(ConnPoolSupport.getId(session) + ": executing message exchange " + exchangeId);
|
||||
session.addLast(new ExecutionCommand(
|
||||
new LoggingAsyncClientExchangeHandler(log, exchangeId, internalExchangeHandler),
|
||||
cancellable, clientContext));
|
||||
session.enqueue(
|
||||
new RequestExecutionCommand(
|
||||
new LoggingAsyncClientExchangeHandler(log, exchangeId, internalExchangeHandler),
|
||||
null, cancellable, clientContext),
|
||||
Command.Priority.NORMAL);
|
||||
} else {
|
||||
session.addLast(new ExecutionCommand(internalExchangeHandler, cancellable, clientContext));
|
||||
session.enqueue(
|
||||
new RequestExecutionCommand(internalExchangeHandler, null, cancellable, clientContext),
|
||||
Command.Priority.NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +242,7 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien
|
|||
});
|
||||
}
|
||||
|
||||
});
|
||||
}, context);
|
||||
} catch (final HttpException | IOException ex) {
|
||||
exchangeHandler.failed(ex);
|
||||
}
|
||||
|
|
|
@ -62,13 +62,16 @@ import org.apache.hc.core5.http.HttpResponse;
|
|||
import org.apache.hc.core5.http.HttpStatus;
|
||||
import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
|
||||
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
|
||||
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
|
||||
import org.apache.hc.core5.http.nio.CapacityChannel;
|
||||
import org.apache.hc.core5.http.nio.DataStreamChannel;
|
||||
import org.apache.hc.core5.http.nio.HandlerFactory;
|
||||
import org.apache.hc.core5.http.nio.RequestChannel;
|
||||
import org.apache.hc.core5.http.nio.command.ShutdownCommand;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.reactor.Command;
|
||||
import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
|
||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||
import org.apache.hc.core5.reactor.IOReactorConfig;
|
||||
|
@ -103,7 +106,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
|
|||
|
||||
@Override
|
||||
public void execute(final IOSession ioSession) {
|
||||
ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
|
||||
ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.NORMAL);
|
||||
}
|
||||
|
||||
}),
|
||||
|
@ -223,7 +226,8 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
|
|||
@Override
|
||||
public void sendRequest(
|
||||
final HttpRequest request,
|
||||
final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
RequestConfig requestConfig = null;
|
||||
if (request instanceof Configurable) {
|
||||
requestConfig = ((Configurable) request).getConfig();
|
||||
|
@ -270,8 +274,9 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
|
|||
|
||||
@Override
|
||||
public void produceRequest(
|
||||
final RequestChannel channel) throws HttpException, IOException {
|
||||
channel.sendRequest(request, entityDetails);
|
||||
final RequestChannel channel,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
channel.sendRequest(request, entityDetails, context);
|
||||
if (entityDetails == null) {
|
||||
messageCountDown.decrementAndGet();
|
||||
}
|
||||
|
@ -317,14 +322,17 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
|
|||
|
||||
@Override
|
||||
public void consumeInformation(
|
||||
final HttpResponse response) throws HttpException, IOException {
|
||||
exchangeHandler.consumeInformation(response);
|
||||
final HttpResponse response,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
exchangeHandler.consumeInformation(response, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeResponse(
|
||||
final HttpResponse response, final EntityDetails entityDetails) throws HttpException, IOException {
|
||||
exchangeHandler.consumeResponse(response, entityDetails);
|
||||
final HttpResponse response,
|
||||
final EntityDetails entityDetails,
|
||||
final HttpContext context) throws HttpException, IOException {
|
||||
exchangeHandler.consumeResponse(response, entityDetails, context);
|
||||
if (response.getCode() >= HttpStatus.SC_CLIENT_ERROR) {
|
||||
messageCountDown.decrementAndGet();
|
||||
}
|
||||
|
@ -378,7 +386,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
|
|||
|
||||
});
|
||||
}
|
||||
});
|
||||
}, context);
|
||||
|
||||
} catch (final HttpException | IOException ex) {
|
||||
exchangeHandler.failed(ex);
|
||||
|
@ -401,7 +409,10 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(final AsyncClientExchangeHandler exchangeHandler, final HttpContext context) {
|
||||
public void execute(
|
||||
final AsyncClientExchangeHandler exchangeHandler,
|
||||
final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
|
||||
final HttpContext context) {
|
||||
Asserts.check(!released.get(), "Endpoint has already been released");
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
|
|
|
@ -164,13 +164,13 @@ public final class CloseableHttpResponse implements ClassicHttpResponse {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeHeader(final Header header) {
|
||||
response.removeHeader(header);
|
||||
public boolean removeHeader(final Header header) {
|
||||
return response.removeHeader(header);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHeaders(final String name) {
|
||||
response.removeHeaders(name);
|
||||
public boolean removeHeaders(final String name) {
|
||||
return response.removeHeaders(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
|
|||
import org.apache.hc.core5.http.ConnectionRequestTimeoutException;
|
||||
import org.apache.hc.core5.http.HttpException;
|
||||
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
@ -239,7 +239,7 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
|
|||
final ConnectionEndpoint endpoint = endpointRef.getAndSet(null);
|
||||
if (endpoint != null) {
|
||||
try {
|
||||
endpoint.shutdown(ShutdownType.IMMEDIATE);
|
||||
endpoint.close(CloseMode.IMMEDIATE);
|
||||
log.debug("Connection discarded");
|
||||
} finally {
|
||||
manager.release(endpoint, null, TimeValue.ZERO_MILLISECONDS);
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.apache.hc.core5.http.ConnectionReuseStrategy;
|
|||
import org.apache.hc.core5.http.HttpEntity;
|
||||
import org.apache.hc.core5.http.HttpException;
|
||||
import org.apache.hc.core5.http.message.RequestLine;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -149,7 +149,7 @@ final class MainClientExec implements ExecChainHandler {
|
|||
execRuntime.discardConnection();
|
||||
throw ex;
|
||||
} catch (final Error error) {
|
||||
connectionManager.shutdown(ShutdownType.IMMEDIATE);
|
||||
connectionManager.close(CloseMode.IMMEDIATE);
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ import org.apache.hc.core5.http.protocol.HttpProcessor;
|
|||
import org.apache.hc.core5.http.protocol.RequestContent;
|
||||
import org.apache.hc.core5.http.protocol.RequestTargetHost;
|
||||
import org.apache.hc.core5.http.protocol.RequestUserAgent;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.net.URIAuthority;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.apache.hc.core5.util.VersionInfo;
|
||||
|
@ -166,7 +166,7 @@ public class MinimalHttpClient extends CloseableHttpClient {
|
|||
execRuntime.discardConnection();
|
||||
throw ex;
|
||||
} catch (final Error error) {
|
||||
connManager.shutdown(ShutdownType.IMMEDIATE);
|
||||
connManager.close(CloseMode.IMMEDIATE);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,11 +56,11 @@ import org.apache.hc.core5.http.HttpHost;
|
|||
import org.apache.hc.core5.http.config.Lookup;
|
||||
import org.apache.hc.core5.http.config.Registry;
|
||||
import org.apache.hc.core5.http.config.RegistryBuilder;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
|
||||
import org.apache.hc.core5.http.io.HttpConnectionFactory;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.apache.hc.core5.util.Asserts;
|
||||
import org.apache.hc.core5.util.LangUtils;
|
||||
|
@ -152,13 +152,13 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
|||
|
||||
@Override
|
||||
public void close() {
|
||||
shutdown(ShutdownType.GRACEFUL);
|
||||
close(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(final ShutdownType shutdownType) {
|
||||
public void close(final CloseMode closeMode) {
|
||||
if (this.closed.compareAndSet(false, true)) {
|
||||
closeConnection(shutdownType);
|
||||
closeConnection(closeMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,10 +205,10 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
|||
};
|
||||
}
|
||||
|
||||
private synchronized void closeConnection(final ShutdownType shutdownType) {
|
||||
private synchronized void closeConnection(final CloseMode closeMode) {
|
||||
if (this.conn != null) {
|
||||
this.log.debug("Shutting down connection " + shutdownType);
|
||||
this.conn.shutdown(shutdownType);
|
||||
this.log.debug("Closing connection " + closeMode);
|
||||
this.conn.close(closeMode);
|
||||
this.conn = null;
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
|||
if (this.log.isDebugEnabled()) {
|
||||
this.log.debug("Connection expired @ " + new Date(this.expiry));
|
||||
}
|
||||
closeConnection(ShutdownType.GRACEFUL);
|
||||
closeConnection(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
|||
}
|
||||
Asserts.check(!this.leased, "Connection is still allocated");
|
||||
if (!LangUtils.equals(this.route, route) || !LangUtils.equals(this.state, state)) {
|
||||
closeConnection(ShutdownType.GRACEFUL);
|
||||
closeConnection(CloseMode.GRACEFUL);
|
||||
}
|
||||
this.route = route;
|
||||
this.state = state;
|
||||
|
@ -263,7 +263,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
|||
}
|
||||
try {
|
||||
if (keepAlive == null) {
|
||||
this.conn.shutdown(ShutdownType.GRACEFUL);
|
||||
this.conn.close(CloseMode.GRACEFUL);
|
||||
}
|
||||
this.updated = System.currentTimeMillis();
|
||||
if (!this.conn.isOpen()) {
|
||||
|
@ -352,7 +352,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
|||
}
|
||||
final long deadline = System.currentTimeMillis() - time;
|
||||
if (this.updated <= deadline) {
|
||||
closeConnection(ShutdownType.GRACEFUL);
|
||||
closeConnection(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -396,10 +396,10 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
|||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(final ShutdownType shutdownType) {
|
||||
public void close(final CloseMode closeMode) {
|
||||
final ManagedHttpClientConnection conn = detach();
|
||||
if (conn != null) {
|
||||
conn.shutdown(shutdownType);
|
||||
conn.close(closeMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
|||
|
||||
@Override
|
||||
public void setSocketTimeout(final int timeout) {
|
||||
getValidatedConnection().setSocketTimeout(timeout);
|
||||
getValidatedConnection().setSocketTimeoutMillis(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
|
|||
import org.apache.hc.core5.http.ConnectionClosedException;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.config.Lookup;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.apache.hc.core5.http.io.HttpMessageParserFactory;
|
|||
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
|
||||
import org.apache.hc.core5.http.message.RequestLine;
|
||||
import org.apache.hc.core5.http.message.StatusLine;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.util.Identifiable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -133,20 +133,20 @@ final class DefaultManagedHttpClientConnection
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setSocketTimeout(final int timeout) {
|
||||
public void setSocketTimeoutMillis(final int timeout) {
|
||||
if (this.log.isDebugEnabled()) {
|
||||
this.log.debug(this.id + ": set socket timeout to " + timeout);
|
||||
}
|
||||
super.setSocketTimeout(timeout);
|
||||
super.setSocketTimeoutMillis(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(final ShutdownType shutdownType) {
|
||||
public void close(final CloseMode closeMode) {
|
||||
if (this.closed.compareAndSet(false, true)) {
|
||||
if (this.log.isDebugEnabled()) {
|
||||
this.log.debug(this.id + ": Shutdown connection " + shutdownType);
|
||||
this.log.debug(this.id + ": close connection " + closeMode);
|
||||
}
|
||||
super.shutdown(shutdownType);
|
||||
super.close(closeMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,12 +180,12 @@ final class DefaultManagedHttpClientConnection
|
|||
|
||||
@Override
|
||||
public void passivate() {
|
||||
super.setSocketTimeout(0);
|
||||
super.setSocketTimeoutMillis(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
super.setSocketTimeout(socketTimeout);
|
||||
super.setSocketTimeoutMillis(socketTimeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,11 +57,11 @@ import org.apache.hc.core5.http.HttpException;
|
|||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.config.Registry;
|
||||
import org.apache.hc.core5.http.config.RegistryBuilder;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
|
||||
import org.apache.hc.core5.http.io.HttpConnectionFactory;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.pool.ConnPoolControl;
|
||||
import org.apache.hc.core5.pool.LaxConnPool;
|
||||
import org.apache.hc.core5.pool.ManagedConnPool;
|
||||
|
@ -222,16 +222,16 @@ public class PoolingHttpClientConnectionManager
|
|||
|
||||
@Override
|
||||
public void close() {
|
||||
shutdown(ShutdownType.GRACEFUL);
|
||||
close(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(final ShutdownType shutdownType) {
|
||||
public void close(final CloseMode closeMode) {
|
||||
if (this.closed.compareAndSet(false, true)) {
|
||||
if (this.log.isDebugEnabled()) {
|
||||
this.log.debug("Shutdown connection pool " + shutdownType);
|
||||
this.log.debug("Shutdown connection pool " + closeMode);
|
||||
}
|
||||
this.pool.shutdown(shutdownType);
|
||||
this.pool.close(closeMode);
|
||||
this.log.debug("Connection pool shut down");
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ public class PoolingHttpClientConnectionManager
|
|||
if (log.isDebugEnabled()) {
|
||||
log.debug("Connection " + ConnPoolSupport.getId(conn) + " is stale");
|
||||
}
|
||||
poolEntry.discardConnection(ShutdownType.IMMEDIATE);
|
||||
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ public class PoolingHttpClientConnectionManager
|
|||
}
|
||||
final ManagedHttpClientConnection conn = entry.getConnection();
|
||||
if (conn != null && keepAlive == null) {
|
||||
conn.shutdown(ShutdownType.GRACEFUL);
|
||||
conn.close(CloseMode.GRACEFUL);
|
||||
}
|
||||
boolean reusable = conn != null && conn.isOpen();
|
||||
try {
|
||||
|
@ -523,10 +523,10 @@ public class PoolingHttpClientConnectionManager
|
|||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(final ShutdownType shutdownType) {
|
||||
public void close(final CloseMode closeMode) {
|
||||
final PoolEntry<HttpRoute, ManagedHttpClientConnection> poolEntry = poolEntryRef.get();
|
||||
if (poolEntry != null) {
|
||||
poolEntry.discardConnection(shutdownType);
|
||||
poolEntry.discardConnection(closeMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -534,7 +534,7 @@ public class PoolingHttpClientConnectionManager
|
|||
public void close() throws IOException {
|
||||
final PoolEntry<HttpRoute, ManagedHttpClientConnection> poolEntry = poolEntryRef.get();
|
||||
if (poolEntry != null) {
|
||||
poolEntry.discardConnection(ShutdownType.GRACEFUL);
|
||||
poolEntry.discardConnection(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ public class PoolingHttpClientConnectionManager
|
|||
|
||||
@Override
|
||||
public void setSocketTimeout(final int timeout) {
|
||||
getValidatedPoolEntry().getConnection().setSocketTimeout(timeout);
|
||||
getValidatedPoolEntry().getConnection().setSocketTimeoutMillis(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,8 +35,8 @@ import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
|
|||
import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.hc.core5.http.config.RegistryBuilder;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.io.HttpConnectionFactory;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.pool.PoolConcurrencyPolicy;
|
||||
import org.apache.hc.core5.pool.PoolReusePolicy;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
|
|
|
@ -42,11 +42,13 @@ import org.apache.hc.core5.http.HttpConnection;
|
|||
import org.apache.hc.core5.http.HttpVersion;
|
||||
import org.apache.hc.core5.http.ProtocolVersion;
|
||||
import org.apache.hc.core5.http.nio.command.ShutdownCommand;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.net.NamedEndpoint;
|
||||
import org.apache.hc.core5.reactor.Command;
|
||||
import org.apache.hc.core5.reactor.IOEventHandler;
|
||||
import org.apache.hc.core5.reactor.IOSession;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
|
||||
import org.apache.hc.core5.reactor.ProtocolLayer;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
|
||||
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||
|
@ -71,7 +73,7 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
|||
|
||||
public DefaultManagedAsyncClientConnection(final IOSession ioSession) {
|
||||
this.ioSession = ioSession;
|
||||
this.socketTimeout = ioSession.getSocketTimeout();
|
||||
this.socketTimeout = ioSession.getSocketTimeoutMillis();
|
||||
this.closed = new AtomicBoolean();
|
||||
}
|
||||
|
||||
|
@ -81,12 +83,12 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
|||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(final ShutdownType shutdownType) {
|
||||
public void close(final CloseMode closeMode) {
|
||||
if (this.closed.compareAndSet(false, true)) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(getId() + ": Shutdown connection " + shutdownType);
|
||||
log.debug(getId() + ": Shutdown connection " + closeMode);
|
||||
}
|
||||
ioSession.shutdown(shutdownType);
|
||||
ioSession.close(closeMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +98,7 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
|||
if (log.isDebugEnabled()) {
|
||||
log.debug(getId() + ": Close connection");
|
||||
}
|
||||
ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
|
||||
ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,13 +108,13 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setSocketTimeout(final int timeout) {
|
||||
ioSession.setSocketTimeout(timeout);
|
||||
public void setSocketTimeoutMillis(final int timeout) {
|
||||
ioSession.setSocketTimeoutMillis(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSocketTimeout() {
|
||||
return ioSession.getSocketTimeout();
|
||||
public int getSocketTimeoutMillis() {
|
||||
return ioSession.getSocketTimeoutMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,35 +129,38 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
|||
|
||||
@Override
|
||||
public EndpointDetails getEndpointDetails() {
|
||||
final IOEventHandler handler = ioSession.getHandler();
|
||||
if (handler instanceof HttpConnection) {
|
||||
return ((HttpConnection) handler).getEndpointDetails();
|
||||
} else {
|
||||
return null;
|
||||
if (ioSession instanceof ProtocolLayer) {
|
||||
final IOEventHandler handler = ((ProtocolLayer) ioSession).getHandler();
|
||||
if (handler instanceof HttpConnection) {
|
||||
return ((HttpConnection) handler).getEndpointDetails();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
final IOEventHandler handler = ioSession.getHandler();
|
||||
if (handler instanceof HttpConnection) {
|
||||
return ((HttpConnection) handler).getProtocolVersion();
|
||||
} else {
|
||||
return HttpVersion.DEFAULT;
|
||||
if (ioSession instanceof ProtocolLayer) {
|
||||
final IOEventHandler handler = ((ProtocolLayer) ioSession).getHandler();
|
||||
if (handler instanceof HttpConnection) {
|
||||
return ((HttpConnection) handler).getProtocolVersion();
|
||||
}
|
||||
}
|
||||
return HttpVersion.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startTls(
|
||||
final SSLContext sslContext,
|
||||
final SSLBufferManagement sslBufferManagement,
|
||||
final NamedEndpoint endpoint,
|
||||
final SSLBufferMode sslBufferMode,
|
||||
final SSLSessionInitializer initializer,
|
||||
final SSLSessionVerifier verifier) throws UnsupportedOperationException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(getId() + ": start TLS");
|
||||
}
|
||||
if (ioSession instanceof TransportSecurityLayer) {
|
||||
((TransportSecurityLayer) ioSession).startTls(sslContext, sslBufferManagement, initializer, verifier);
|
||||
((TransportSecurityLayer) ioSession).startTls(sslContext, endpoint, sslBufferMode, initializer, verifier);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("TLS upgrade not supported");
|
||||
}
|
||||
|
@ -177,7 +182,7 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
|||
if (log.isDebugEnabled()) {
|
||||
log.debug(getId() + ": priority command " + command);
|
||||
}
|
||||
ioSession.addFirst(command);
|
||||
ioSession.enqueue(command, Command.Priority.IMMEDIATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -185,17 +190,17 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
|||
if (log.isDebugEnabled()) {
|
||||
log.debug(getId() + ": command " + command);
|
||||
}
|
||||
ioSession.addLast(command);
|
||||
ioSession.enqueue(command, Command.Priority.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passivate() {
|
||||
ioSession.setSocketTimeout(0);
|
||||
ioSession.setSocketTimeoutMillis(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
ioSession.setSocketTimeout(socketTimeout);
|
||||
ioSession.setSocketTimeoutMillis(socketTimeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,12 +57,12 @@ import org.apache.hc.core5.http.ProtocolVersion;
|
|||
import org.apache.hc.core5.http.config.Lookup;
|
||||
import org.apache.hc.core5.http.config.RegistryBuilder;
|
||||
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
|
||||
import org.apache.hc.core5.http.nio.command.ExecutionCommand;
|
||||
import org.apache.hc.core5.http.nio.command.RequestExecutionCommand;
|
||||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.http2.nio.command.PingCommand;
|
||||
import org.apache.hc.core5.http2.nio.support.BasicPingHandler;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.pool.ConnPoolControl;
|
||||
import org.apache.hc.core5.pool.LaxConnPool;
|
||||
import org.apache.hc.core5.pool.ManagedConnPool;
|
||||
|
@ -188,16 +188,16 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
|||
|
||||
@Override
|
||||
public void close() {
|
||||
shutdown(ShutdownType.GRACEFUL);
|
||||
close(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(final ShutdownType shutdownType) {
|
||||
public void close(final CloseMode closeMode) {
|
||||
if (this.closed.compareAndSet(false, true)) {
|
||||
if (this.log.isDebugEnabled()) {
|
||||
this.log.debug("Shutdown connection pool " + shutdownType);
|
||||
this.log.debug("Shutdown connection pool " + closeMode);
|
||||
}
|
||||
this.pool.shutdown(shutdownType);
|
||||
this.pool.close(closeMode);
|
||||
this.log.debug("Connection pool shut down");
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
|||
if (log.isDebugEnabled()) {
|
||||
log.debug("Connection " + ConnPoolSupport.getId(connection) + " is stale");
|
||||
}
|
||||
poolEntry.discardConnection(ShutdownType.IMMEDIATE);
|
||||
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
||||
}
|
||||
leaseCompleted(poolEntry);
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
|||
if (log.isDebugEnabled()) {
|
||||
log.debug("Connection " + ConnPoolSupport.getId(connection) + " is closed");
|
||||
}
|
||||
poolEntry.discardConnection(ShutdownType.IMMEDIATE);
|
||||
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
||||
}
|
||||
leaseCompleted(poolEntry);
|
||||
}
|
||||
|
@ -513,9 +513,9 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
|||
final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry = poolEntryRef.get();
|
||||
if (poolEntry != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(id + ": shutdown " + ShutdownType.IMMEDIATE);
|
||||
log.debug(id + ": shutdown " + CloseMode.IMMEDIATE);
|
||||
}
|
||||
poolEntry.discardConnection(ShutdownType.IMMEDIATE);
|
||||
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -524,9 +524,9 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
|||
final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry = poolEntryRef.get();
|
||||
if (poolEntry != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(id + ": shutdown " + ShutdownType.GRACEFUL);
|
||||
log.debug(id + ": shutdown " + CloseMode.GRACEFUL);
|
||||
}
|
||||
poolEntry.discardConnection(ShutdownType.GRACEFUL);
|
||||
poolEntry.discardConnection(CloseMode.GRACEFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
|||
return false;
|
||||
}
|
||||
if (!connection.isOpen()) {
|
||||
poolEntry.discardConnection(ShutdownType.IMMEDIATE);
|
||||
poolEntry.discardConnection(CloseMode.IMMEDIATE);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -549,16 +549,17 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
|||
|
||||
@Override
|
||||
public void setSocketTimeout(final int timeout) {
|
||||
getValidatedPoolEntry().getConnection().setSocketTimeout(timeout);
|
||||
getValidatedPoolEntry().getConnection().setSocketTimeoutMillis(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final AsyncClientExchangeHandler exchangeHandler, final HttpContext context) {
|
||||
final ManagedAsyncClientConnection connection = getValidatedPoolEntry().getConnection();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(id + ": executing exchange " + ConnPoolSupport.getId(exchangeHandler) + " over " + ConnPoolSupport.getId(connection));
|
||||
log.debug(id + ": executing exchange " + ConnPoolSupport.getId(exchangeHandler) +
|
||||
" over " + ConnPoolSupport.getId(connection));
|
||||
}
|
||||
connection.submitCommand(new ExecutionCommand(exchangeHandler, context));
|
||||
connection.submitCommand(new RequestExecutionCommand(exchangeHandler, context));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
|
|||
import org.apache.hc.core5.http.HttpException;
|
||||
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.GracefullyCloseable;
|
||||
import org.apache.hc.core5.io.ModalCloseable;
|
||||
|
||||
/**
|
||||
* Client connection endpoint that can be used to execute message exchanges.
|
||||
|
@ -44,7 +44,7 @@ import org.apache.hc.core5.io.GracefullyCloseable;
|
|||
* @since 5.0
|
||||
*/
|
||||
@Contract(threading = ThreadingBehavior.SAFE)
|
||||
public abstract class ConnectionEndpoint implements GracefullyCloseable {
|
||||
public abstract class ConnectionEndpoint implements ModalCloseable {
|
||||
|
||||
public abstract ClassicHttpResponse execute(
|
||||
ClassicHttpRequest request,
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.io.IOException;
|
|||
|
||||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.GracefullyCloseable;
|
||||
import org.apache.hc.core5.io.ModalCloseable;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
|
@ -48,7 +48,7 @@ import org.apache.hc.core5.util.Timeout;
|
|||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public interface HttpClientConnectionManager extends GracefullyCloseable {
|
||||
public interface HttpClientConnectionManager extends ModalCloseable {
|
||||
|
||||
/**
|
||||
* Returns a {@link LeaseRequest} object which can be used to obtain
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.net.InetSocketAddress;
|
|||
|
||||
import org.apache.hc.core5.annotation.Internal;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.concurrent.Future;
|
|||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.GracefullyCloseable;
|
||||
import org.apache.hc.core5.io.ModalCloseable;
|
||||
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
@ -50,7 +50,7 @@ import org.apache.hc.core5.util.Timeout;
|
|||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface AsyncClientConnectionManager extends GracefullyCloseable {
|
||||
public interface AsyncClientConnectionManager extends ModalCloseable {
|
||||
|
||||
/**
|
||||
* Returns a {@link Future} object which can be used to obtain
|
||||
|
|
|
@ -50,7 +50,7 @@ import org.apache.hc.core5.http.HttpHost;
|
|||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||
import org.apache.hc.core5.http2.ssl.H2TlsSupport;
|
||||
import org.apache.hc.core5.net.NamedEndpoint;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
|
||||
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
|
||||
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||
|
@ -98,7 +98,7 @@ public class H2TlsStrategy implements TlsStrategy {
|
|||
SSLContexts.createSystemDefault(),
|
||||
split(getProperty("https.protocols")),
|
||||
split(getProperty("https.cipherSuites")),
|
||||
SSLBufferManagement.STATIC,
|
||||
SSLBufferMode.STATIC,
|
||||
getDefaultHostnameVerifier());
|
||||
}
|
||||
|
||||
|
@ -107,27 +107,27 @@ public class H2TlsStrategy implements TlsStrategy {
|
|||
private final SSLContext sslContext;
|
||||
private final String[] supportedProtocols;
|
||||
private final String[] supportedCipherSuites;
|
||||
private final SSLBufferManagement sslBufferManagement;
|
||||
private final SSLBufferMode sslBufferManagement;
|
||||
private final HostnameVerifier hostnameVerifier;
|
||||
|
||||
public H2TlsStrategy(
|
||||
final SSLContext sslContext,
|
||||
final String[] supportedProtocols,
|
||||
final String[] supportedCipherSuites,
|
||||
final SSLBufferManagement sslBufferManagement,
|
||||
final SSLBufferMode sslBufferManagement,
|
||||
final HostnameVerifier hostnameVerifier) {
|
||||
super();
|
||||
this.sslContext = Args.notNull(sslContext, "SSL context");
|
||||
this.supportedProtocols = supportedProtocols;
|
||||
this.supportedCipherSuites = supportedCipherSuites;
|
||||
this.sslBufferManagement = sslBufferManagement != null ? sslBufferManagement : SSLBufferManagement.STATIC;
|
||||
this.sslBufferManagement = sslBufferManagement != null ? sslBufferManagement : SSLBufferMode.STATIC;
|
||||
this.hostnameVerifier = hostnameVerifier != null ? hostnameVerifier : getDefaultHostnameVerifier();
|
||||
}
|
||||
|
||||
public H2TlsStrategy(
|
||||
final SSLContext sslcontext,
|
||||
final HostnameVerifier hostnameVerifier) {
|
||||
this(sslcontext, null, null, SSLBufferManagement.STATIC, hostnameVerifier);
|
||||
this(sslcontext, null, null, SSLBufferMode.STATIC, hostnameVerifier);
|
||||
}
|
||||
|
||||
public H2TlsStrategy(final SSLContext sslcontext) {
|
||||
|
@ -141,7 +141,7 @@ public class H2TlsStrategy implements TlsStrategy {
|
|||
final SocketAddress localAddress,
|
||||
final SocketAddress remoteAddress,
|
||||
final Object attachment) {
|
||||
tlsSession.startTls(sslContext, sslBufferManagement, H2TlsSupport.enforceRequirements(attachment, new SSLSessionInitializer() {
|
||||
tlsSession.startTls(sslContext, host, sslBufferManagement, H2TlsSupport.enforceRequirements(attachment, new SSLSessionInitializer() {
|
||||
|
||||
@Override
|
||||
public void initialize(final NamedEndpoint endpoint, final SSLEngine sslEngine) {
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.apache.hc.core5.concurrent.CancellableDependency;
|
|||
import org.apache.hc.core5.http.ConnectionRequestTimeoutException;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
import org.junit.Assert;
|
||||
|
@ -127,7 +127,7 @@ public class TestInternalExecRuntime {
|
|||
|
||||
Mockito.when(mgr.lease(Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any())).thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(
|
||||
Mockito.anyLong(), Mockito.<TimeUnit>any())).thenThrow(new TimeoutException());
|
||||
Mockito.anyLong(), Mockito.<TimeUnit>any())).thenThrow(new TimeoutException("timeout"));
|
||||
|
||||
execRuntime.acquireConnection(route, null, context);
|
||||
}
|
||||
|
@ -156,12 +156,12 @@ public class TestInternalExecRuntime {
|
|||
|
||||
Assert.assertFalse(execRuntime.isConnectionAcquired());
|
||||
|
||||
Mockito.verify(connectionEndpoint).shutdown(ShutdownType.IMMEDIATE);
|
||||
Mockito.verify(connectionEndpoint).close(CloseMode.IMMEDIATE);
|
||||
Mockito.verify(mgr).release(connectionEndpoint, null, TimeValue.ZERO_MILLISECONDS);
|
||||
|
||||
execRuntime.discardConnection();
|
||||
|
||||
Mockito.verify(connectionEndpoint, Mockito.times(1)).shutdown(ShutdownType.IMMEDIATE);
|
||||
Mockito.verify(connectionEndpoint, Mockito.times(1)).close(CloseMode.IMMEDIATE);
|
||||
Mockito.verify(mgr, Mockito.times(1)).release(
|
||||
Mockito.<ConnectionEndpoint>any(),
|
||||
Mockito.any(),
|
||||
|
@ -183,12 +183,12 @@ public class TestInternalExecRuntime {
|
|||
|
||||
Assert.assertFalse(execRuntime.isConnectionAcquired());
|
||||
|
||||
Mockito.verify(connectionEndpoint).shutdown(ShutdownType.IMMEDIATE);
|
||||
Mockito.verify(connectionEndpoint).close(CloseMode.IMMEDIATE);
|
||||
Mockito.verify(mgr).release(connectionEndpoint, null, TimeValue.ZERO_MILLISECONDS);
|
||||
|
||||
Assert.assertFalse(execRuntime.cancel());
|
||||
|
||||
Mockito.verify(connectionEndpoint, Mockito.times(1)).shutdown(ShutdownType.IMMEDIATE);
|
||||
Mockito.verify(connectionEndpoint, Mockito.times(1)).close(CloseMode.IMMEDIATE);
|
||||
Mockito.verify(mgr, Mockito.times(1)).release(
|
||||
Mockito.<ConnectionEndpoint>any(),
|
||||
Mockito.any(),
|
||||
|
|
|
@ -43,10 +43,10 @@ import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
|
|||
import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.config.Lookup;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.io.HttpConnectionFactory;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -192,7 +192,7 @@ public class TestBasicHttpClientConnectionManager {
|
|||
Assert.assertNotNull(conn2);
|
||||
Assert.assertFalse(conn2.isConnected());
|
||||
|
||||
Mockito.verify(conn).shutdown(ShutdownType.GRACEFUL);
|
||||
Mockito.verify(conn).close(CloseMode.GRACEFUL);
|
||||
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ public class TestBasicHttpClientConnectionManager {
|
|||
Assert.assertNotNull(conn2);
|
||||
Assert.assertFalse(conn2.isConnected());
|
||||
|
||||
Mockito.verify(conn).shutdown(ShutdownType.GRACEFUL);
|
||||
Mockito.verify(conn).close(CloseMode.GRACEFUL);
|
||||
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ public class TestBasicHttpClientConnectionManager {
|
|||
|
||||
mgr.close();
|
||||
|
||||
Mockito.verify(conn, Mockito.times(1)).shutdown(ShutdownType.GRACEFUL);
|
||||
Mockito.verify(conn, Mockito.times(1)).close(CloseMode.GRACEFUL);
|
||||
|
||||
try {
|
||||
final LeaseRequest connRequest2 = mgr.lease(route, null);
|
||||
|
@ -271,7 +271,7 @@ public class TestBasicHttpClientConnectionManager {
|
|||
mgr.closeIdle(0L, TimeUnit.MILLISECONDS);
|
||||
mgr.close();
|
||||
|
||||
Mockito.verify(conn, Mockito.times(1)).shutdown(ShutdownType.GRACEFUL);
|
||||
Mockito.verify(conn, Mockito.times(1)).close(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -298,7 +298,7 @@ public class TestBasicHttpClientConnectionManager {
|
|||
|
||||
mgr.closeExpired();
|
||||
|
||||
Mockito.verify(conn).shutdown(ShutdownType.GRACEFUL);
|
||||
Mockito.verify(conn).close(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -325,7 +325,7 @@ public class TestBasicHttpClientConnectionManager {
|
|||
|
||||
mgr.closeIdle(50, TimeUnit.MILLISECONDS);
|
||||
|
||||
Mockito.verify(conn).shutdown(ShutdownType.GRACEFUL);
|
||||
Mockito.verify(conn).close(CloseMode.GRACEFUL);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalStateException.class)
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
|
|||
import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.config.Lookup;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.BasicHttpContext;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
|
|||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.config.Lookup;
|
||||
import org.apache.hc.core5.http.config.SocketConfig;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.pool.PoolEntry;
|
||||
import org.apache.hc.core5.pool.StrictConnPool;
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -68,7 +68,7 @@
|
|||
<properties>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<httpcore.version>5.0-beta2</httpcore.version>
|
||||
<httpcore.version>5.0-beta3</httpcore.version>
|
||||
<log4j.version>2.9.1</log4j.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
<ehcache.version>3.4.0</ehcache.version>
|
||||
|
|
Loading…
Reference in New Issue