Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.http2.frame.DefaultFrameFactory;
import org.apache.hc.core5.http2.frame.FrameFactory;
import org.apache.hc.core5.reactor.ProtocolIOSession;
import org.apache.hc.core5.util.Args;

Expand All @@ -53,25 +54,38 @@ public final class ClientH2StreamMultiplexerFactory {
private final H2Config h2Config;
private final CharCodingConfig charCodingConfig;
private final H2StreamListener streamListener;
private final FrameFactory frameFactory;

public ClientH2StreamMultiplexerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
final H2Config h2Config,
final CharCodingConfig charCodingConfig,
final H2StreamListener streamListener) {
final H2StreamListener streamListener,
final FrameFactory frameFactory) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.pushHandlerFactory = pushHandlerFactory;
this.h2Config = h2Config != null ? h2Config : H2Config.DEFAULT;
this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
this.streamListener = streamListener;
this.frameFactory = frameFactory != null ? frameFactory : DefaultFrameFactory.INSTANCE;
}

public ClientH2StreamMultiplexerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
final H2Config h2Config,
final CharCodingConfig charCodingConfig,
final H2StreamListener streamListener
) {
this(httpProcessor, pushHandlerFactory, h2Config, charCodingConfig, streamListener, null);
}

public ClientH2StreamMultiplexerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
final H2StreamListener streamListener) {
this(httpProcessor, pushHandlerFactory, null, null, streamListener);
this(httpProcessor, pushHandlerFactory, null, null, streamListener, null);
}

public ClientH2StreamMultiplexerFactory(
Expand All @@ -81,7 +95,7 @@ public ClientH2StreamMultiplexerFactory(
}

public ClientH2StreamMultiplexer create(final ProtocolIOSession ioSession) {
return new ClientH2StreamMultiplexer(ioSession, DefaultFrameFactory.INSTANCE, httpProcessor,
return new ClientH2StreamMultiplexer(ioSession, frameFactory, httpProcessor,
pushHandlerFactory, h2Config, charCodingConfig, streamListener);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.http2.frame.DefaultFrameFactory;
import org.apache.hc.core5.http2.frame.FrameFactory;
import org.apache.hc.core5.reactor.ProtocolIOSession;
import org.apache.hc.core5.util.Args;

Expand All @@ -53,24 +54,36 @@ public final class ServerH2StreamMultiplexerFactory {
private final H2Config h2Config;
private final CharCodingConfig charCodingConfig;
private final H2StreamListener streamListener;
private final FrameFactory frameFactory;

public ServerH2StreamMultiplexerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
final H2Config h2Config,
final CharCodingConfig charCodingConfig,
final H2StreamListener streamListener) {
final H2StreamListener streamListener,
final FrameFactory frameFactory) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
this.h2Config = h2Config != null ? h2Config : H2Config.DEFAULT;
this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
this.streamListener = streamListener;
this.frameFactory = frameFactory != null ? frameFactory : DefaultFrameFactory.INSTANCE;
}

public ServerH2StreamMultiplexerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
final H2Config h2Config,
final CharCodingConfig charCodingConfig,
final H2StreamListener streamListener) {
this(httpProcessor, exchangeHandlerFactory, h2Config, charCodingConfig, streamListener, null);
}

public ServerH2StreamMultiplexer create(final ProtocolIOSession ioSession) {
return new ServerH2StreamMultiplexer(
ioSession,
DefaultFrameFactory.INSTANCE,
frameFactory,
httpProcessor,
exchangeHandlerFactory,
charCodingConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http.protocol.UriPatternType;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.http2.frame.FrameFactory;
import org.apache.hc.core5.http2.impl.H2Processors;
import org.apache.hc.core5.http2.impl.nio.ClientH2PrefaceHandler;
import org.apache.hc.core5.http2.impl.nio.ClientH2StreamMultiplexerFactory;
Expand Down Expand Up @@ -71,6 +72,7 @@ public class H2MultiplexingRequesterBootstrap {
private Callback<Exception> exceptionCallback;
private IOSessionListener sessionListener;
private H2StreamListener streamListener;
private FrameFactory frameFactory;

private IOReactorMetricsListener threadPoolListener;

Expand Down Expand Up @@ -188,6 +190,17 @@ public final H2MultiplexingRequesterBootstrap setStreamListener(final H2StreamLi
return this;
}

/**
* Sets {@link FrameFactory} instance.
*
* @since 5.4
* @return this instance.
*/
public final H2MultiplexingRequesterBootstrap setStreamListener(final FrameFactory frameFactory) {
this.frameFactory = frameFactory;
return this;
}

/**
* Sets {@link UriPatternType} for handler registration.
*
Expand Down Expand Up @@ -249,7 +262,8 @@ public H2MultiplexingRequester create() {
new DefaultAsyncPushConsumerFactory(requestRouter),
h2Config != null ? h2Config : H2Config.DEFAULT,
charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT,
streamListener);
streamListener,
frameFactory);
return new H2MultiplexingRequester(
ioReactorConfig,
(ioSession, attachment) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.apache.hc.core5.http.protocol.UriPatternType;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.http2.frame.FrameFactory;
import org.apache.hc.core5.http2.impl.H2Processors;
import org.apache.hc.core5.http2.impl.nio.ClientH2StreamMultiplexerFactory;
import org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiationStarter;
Expand Down Expand Up @@ -101,6 +102,7 @@ public class H2RequesterBootstrap {
private Http1StreamListener http1StreamListener;
private ConnPoolListener<HttpHost> connPoolListener;
private IOReactorMetricsListener threadPoolListener;
private FrameFactory frameFactory;


private H2RequesterBootstrap() {
Expand Down Expand Up @@ -303,6 +305,17 @@ public final H2RequesterBootstrap setUriPatternType(final UriPatternType uriPatt
return this;
}

/**
* Sets {@link FrameFactory} instance.
*
* @since 5.4
* @return this instance.
*/
public final H2RequesterBootstrap setFrameFactory(final FrameFactory frameFactory) {
this.frameFactory = frameFactory;
return this;
}

/**
* Registers the given {@link AsyncPushConsumer} {@link Supplier} as a default handler for URIs
* matching the given pattern.
Expand Down Expand Up @@ -376,7 +389,8 @@ public H2AsyncRequester create() {
new DefaultAsyncPushConsumerFactory(requestRouter),
h2Config != null ? h2Config : H2Config.DEFAULT,
charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT,
streamListener);
streamListener,
frameFactory);

final TlsStrategy actualTlsStrategy = tlsStrategy != null ? tlsStrategy : new H2ClientTlsStrategy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.apache.hc.core5.http.protocol.UriPatternType;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.http2.frame.FrameFactory;
import org.apache.hc.core5.http2.impl.H2Processors;
import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
import org.apache.hc.core5.http2.impl.nio.ServerH2StreamMultiplexerFactory;
Expand Down Expand Up @@ -104,6 +105,7 @@ public class H2ServerBootstrap {
private H2StreamListener h2StreamListener;
private Http1StreamListener http1StreamListener;
private IOReactorMetricsListener threadPoolListener;
private FrameFactory frameFactory;

private H2ServerBootstrap() {
this.routeEntries = new ArrayList<>();
Expand Down Expand Up @@ -252,6 +254,17 @@ public final H2ServerBootstrap setStreamListener(final H2StreamListener h2Stream
return this;
}

/**
* Sets {@link FrameFactory} instance.
*
* @since 5.4
* @return this instance.
*/
public final H2ServerBootstrap setFrameFactory(final FrameFactory frameFactory) {
this.frameFactory = frameFactory;
return this;
}

/**
* Sets {@link Http1StreamListener} instance.
*
Expand Down Expand Up @@ -511,7 +524,8 @@ public HttpAsyncServer create() {
handlerFactory,
h2Config != null ? h2Config : H2Config.DEFAULT,
charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT,
h2StreamListener);
h2StreamListener,
frameFactory);

final TlsStrategy actualTlsStrategy = tlsStrategy != null ? tlsStrategy : new H2ServerTlsStrategy();

Expand Down