Class Http2MultiplexChildInitializer
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
Http2MultiplexHandler
to build the pipeline for every HTTP/2 stream. Since issue #2669 the multiplex
pipeline is the only HTTP/2 server pipeline (h2 and h2c alike), so this initializer runs for all
HTTP/2 traffic — ordinary HTTP GET/POST/SSE, the dashboard, MCP, proxying, and gRPC — not just
when gRPC bidi streaming is enabled.
Per-stream routing. initChannel(io.netty.handler.codec.http2.Http2StreamChannel) installs GrpcBidiRouterHandler
as the first handler only when grpcBidiStreamingEnabled() is on AND the gRPC
descriptor store has services — the only configuration under which a stream can be a true gRPC
bidi method that needs a dedicated streaming handler. In that case the router inspects the first
HEADERS frame and either installs the bidi streaming handler (for a matched bidi method) or the
re-aggregating chain (for everything else). When bidi routing is not possible the router would
always fall through to the re-aggregating chain, so this initializer skips it entirely and
installs the re-aggregating chain directly — a pointless per-stream handler avoided on the common
path.
The re-aggregating chain (Http2StreamFrameToHttpObjectCodec +
HttpObjectAggregator + downstream handlers) is factored into the static
installReAggregatingChain(io.netty.channel.ChannelPipeline, org.mockserver.configuration.Configuration, org.mockserver.logging.MockServerLogger, boolean, java.security.cert.Certificate[], io.netty.channel.Channel, org.mockserver.netty.websocketregistry.CallbackWebSocketServerHandler, org.mockserver.dashboard.DashboardWebSocketHandler, org.mockserver.netty.mcp.McpStreamableHttpHandler, org.mockserver.netty.unification.TraceContextHandler, org.mockserver.netty.unification.AltSvcHeaderHandler, org.mockserver.netty.grpc.GrpcToHttpResponseHandler, org.mockserver.netty.grpc.GrpcToHttpRequestHandler, org.mockserver.netty.HttpRequestHandler) method so both this initializer and the router can install it.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionHttp2MultiplexChildInitializer(Configuration configuration, LifeCycle server, HttpState httpState, HttpActionHandler actionHandler, MockServerLogger mockServerLogger, McpSessionManager mcpSessionManager, boolean sslEnabled, Certificate[] clientCertificates) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidinitChannel(io.netty.handler.codec.http2.Http2StreamChannel ch) static voidinstallReAggregatingChain(io.netty.channel.ChannelPipeline pipeline, Configuration configuration, MockServerLogger mockServerLogger, boolean sslEnabled, Certificate[] clientCertificates, io.netty.channel.Channel channel, CallbackWebSocketServerHandler callbackWebSocketServerHandler, DashboardWebSocketHandler dashboardWebSocketHandler, McpStreamableHttpHandler mcpStreamableHttpHandler, TraceContextHandler traceContextHandler, AltSvcHeaderHandler altSvcHeaderHandler, GrpcToHttpResponseHandler grpcToHttpResponseHandler, GrpcToHttpRequestHandler grpcToHttpRequestHandler, HttpRequestHandler httpRequestHandler) Installs the re-aggregating chain into the given pipeline: converts HTTP/2 stream frames back intoFullHttpRequest/FullHttpResponseand adds the downstream handler chain (WebSocket, MCP, gRPC codec, request handler).Methods inherited from class io.netty.channel.ChannelInitializer
channelRegistered, exceptionCaught, handlerAdded, handlerRemovedMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Constructor Details
-
Http2MultiplexChildInitializer
public Http2MultiplexChildInitializer(Configuration configuration, LifeCycle server, HttpState httpState, HttpActionHandler actionHandler, MockServerLogger mockServerLogger, McpSessionManager mcpSessionManager, boolean sslEnabled, Certificate[] clientCertificates)
-
-
Method Details
-
initChannel
protected void initChannel(io.netty.handler.codec.http2.Http2StreamChannel ch) - Specified by:
initChannelin classio.netty.channel.ChannelInitializer<io.netty.handler.codec.http2.Http2StreamChannel>
-
installReAggregatingChain
public static void installReAggregatingChain(io.netty.channel.ChannelPipeline pipeline, Configuration configuration, MockServerLogger mockServerLogger, boolean sslEnabled, Certificate[] clientCertificates, io.netty.channel.Channel channel, CallbackWebSocketServerHandler callbackWebSocketServerHandler, DashboardWebSocketHandler dashboardWebSocketHandler, McpStreamableHttpHandler mcpStreamableHttpHandler, TraceContextHandler traceContextHandler, AltSvcHeaderHandler altSvcHeaderHandler, GrpcToHttpResponseHandler grpcToHttpResponseHandler, GrpcToHttpRequestHandler grpcToHttpRequestHandler, HttpRequestHandler httpRequestHandler) Installs the re-aggregating chain into the given pipeline: converts HTTP/2 stream frames back intoFullHttpRequest/FullHttpResponseand adds the downstream handler chain (WebSocket, MCP, gRPC codec, request handler). This is the pipeline every ordinary HTTP/2 stream uses.It is a static method so both
initChannel(io.netty.handler.codec.http2.Http2StreamChannel)(when no bidi routing is possible) andGrpcBidiRouterHandler(for non-bidi streams on a bidi-enabled connection) can install it.publicbecauseGrpcBidiRouterHandlerlives in a different package.- Parameters:
pipeline- the child channel's pipelineconfiguration- server configurationmockServerLogger- loggersslEnabled- whether TLS is enabledclientCertificates- client certificates (may be null)channel- the child channel (used for localAddress)callbackWebSocketServerHandler- sharable WebSocket callback handlerdashboardWebSocketHandler- sharable dashboard WebSocket handlermcpStreamableHttpHandler- sharable MCP handler (may be null)traceContextHandler- sharable trace context handleraltSvcHeaderHandler- sharable Alt-Svc header handler (may be null)grpcToHttpResponseHandler- sharable gRPC response handler (may be null)grpcToHttpRequestHandler- sharable gRPC request handler (may be null)httpRequestHandler- sharable HTTP request handler
-