Make IOReactor IO session decorator configurable.
This commit is contained in:
parent
eb22ef30fc
commit
fff097615b
|
@ -83,6 +83,7 @@ import org.apache.hc.client5.http.routing.HttpRoutePlanner;
|
|||
import org.apache.hc.core5.annotation.Internal;
|
||||
import org.apache.hc.core5.concurrent.DefaultThreadFactory;
|
||||
import org.apache.hc.core5.function.Callback;
|
||||
import org.apache.hc.core5.function.Decorator;
|
||||
import org.apache.hc.core5.http.ConnectionReuseStrategy;
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
|
@ -110,6 +111,7 @@ 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;
|
||||
import org.apache.hc.core5.reactor.IOSession;
|
||||
import org.apache.hc.core5.util.Args;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.apache.hc.core5.util.VersionInfo;
|
||||
|
@ -214,6 +216,7 @@ public class HttpAsyncClientBuilder {
|
|||
private UserTokenHandler userTokenHandler;
|
||||
private AuthenticationStrategy targetAuthStrategy;
|
||||
private AuthenticationStrategy proxyAuthStrategy;
|
||||
private Decorator<IOSession> ioSessionDecorator;
|
||||
|
||||
private LinkedList<RequestInterceptorEntry> requestInterceptors;
|
||||
private LinkedList<ResponseInterceptorEntry> responseInterceptors;
|
||||
|
@ -384,6 +387,16 @@ public class HttpAsyncClientBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link IOSession} {@link Decorator} that will be use with the client's IOReactor.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public final HttpAsyncClientBuilder setIoSessionDecorator(final Decorator<IOSession> ioSessionDecorator) {
|
||||
this.ioSessionDecorator = ioSessionDecorator;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds this protocol interceptor to the head of the protocol processing list.
|
||||
*/
|
||||
|
@ -919,7 +932,7 @@ public class HttpAsyncClientBuilder {
|
|||
ioEventHandlerFactory,
|
||||
ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT,
|
||||
threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
|
||||
LoggingIOSessionDecorator.INSTANCE,
|
||||
ioSessionDecorator != null ? ioSessionDecorator : LoggingIOSessionDecorator.INSTANCE,
|
||||
ioReactorExceptionCallback != null ? ioReactorExceptionCallback : LoggingExceptionCallback.INSTANCE,
|
||||
null,
|
||||
ioSession -> ioSession.enqueue(new ShutdownCommand(CloseMode.GRACEFUL), Command.Priority.IMMEDIATE));
|
||||
|
|
Loading…
Reference in New Issue