Class HttpToHttp2ConnectionHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.http2.Http2ConnectionHandler
io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler, Http2LifecycleManager
Translates HTTP/1.x object writes into HTTP/2 frames.
See InboundHttp2ToHttpAdapter to get translation from HTTP/2 frames to HTTP/1.x objects.
-
Nested Class Summary
Nested classes/interfaces inherited from class ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.SharableModifier and TypeInterfaceDescriptionstatic @interfaceIndicates that the same instance of the annotatedChannelHandlercan be added to one or moreChannelPipelines multiple times without a race condition. -
Field Summary
Fields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATORModifier and TypeFieldDescriptionstatic final ByteToMessageDecoder.CumulatorCumulateByteBufs by add them to aCompositeByteBufand so do no memory copy whenever possible.static final ByteToMessageDecoder.Cumulator -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttpToHttp2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders) protectedHttpToHttp2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway) protectedHttpToHttp2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway, boolean flushPreface, HttpScheme httpScheme) protectedHttpToHttp2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway, HttpScheme httpScheme) -
Method Summary
Modifier and TypeMethodDescriptionvoidwrite(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) Handles conversion ofHttpMessageandHttpContentto HTTP/2 frames.Methods inherited from class Http2ConnectionHandler
bind, channelActive, channelInactive, channelReadComplete, channelWritabilityChanged, close, closeStream, closeStreamLocal, closeStreamRemote, connect, connection, decode, decoder, deregister, disconnect, encoder, exceptionCaught, flush, frameWriter, goAway, gracefulShutdownTimeoutMillis, gracefulShutdownTimeoutMillis, handlerAdded, handlerRemoved0, handleServerHeaderDecodeSizeError, isGracefulShutdownComplete, onConnectionError, onError, onHttpClientUpgrade, onHttpServerUpgrade, onStreamError, read, resetStreamModifier and TypeMethodDescriptionvoidbind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) Called once a bind operation is made.voidCallsChannelHandlerContext.fireChannelActive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelWritabilityChanged()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidclose(ChannelHandlerContext ctx, ChannelPromise promise) Called once a close operation is made.voidcloseStream(Http2Stream stream, ChannelFuture future) Closes and deactivates the givenstream.voidcloseStreamLocal(Http2Stream stream, ChannelFuture future) Closes the local side of the given stream.voidcloseStreamRemote(Http2Stream stream, ChannelFuture future) Closes the remote side of the given stream.voidconnect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Called once a connect operation is made.protected voiddecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Decode the from oneByteBufto an other.decoder()voidderegister(ChannelHandlerContext ctx, ChannelPromise promise) Called once a deregister operation is made from the current registeredEventLoop.voiddisconnect(ChannelHandlerContext ctx, ChannelPromise promise) Called once a disconnect operation is made.encoder()voidexceptionCaught(ChannelHandlerContext ctx, Throwable cause) HandlesHttp2Exceptionobjects that were thrown from other handlers.voidCalled once a flush operation is made.protected Http2FrameWritergoAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData, ChannelPromise promise) Prevents the peer from creating streams and close the connection iferrorCodeis notHttp2Error.NO_ERROR.longGet the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.voidgracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis) Set the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.voidDo nothing by default, sub-classes may override this method.protected voidGets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.protected voidNotifies client that this server has received headers that are larger than what it is willing to accept.protected booleanCalled by the graceful shutdown logic to determine when it is safe to close the connection.protected voidonConnectionError(ChannelHandlerContext ctx, boolean outbound, Throwable cause, Http2Exception http2Ex) Handler for a connection error.voidonError(ChannelHandlerContext ctx, boolean outbound, Throwable cause) Central handler for all exceptions caught during HTTP/2 processing.voidHandles the client-side (cleartext) upgrade from HTTP to HTTP/2.voidonHttpServerUpgrade(Http2Settings settings) Handles the server-side (cleartext) upgrade from HTTP to HTTP/2.protected voidonStreamError(ChannelHandlerContext ctx, boolean outbound, Throwable cause, Http2Exception.StreamException http2Ex) Handler for a stream error.voidInterceptsChannelHandlerContext.read().resetStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise) Ensure the stream identified bystreamIdis reset.Methods inherited from class ByteToMessageDecoder
actualReadableBytes, callDecode, channelRead, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredModifier and TypeMethodDescriptionprotected intReturns the actual number of readable bytes in the internal cumulative buffer of this decoder.protected voidcallDecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Called once data should be decoded from the givenByteBuf.voidchannelRead(ChannelHandlerContext ctx, Object input) CallsChannelHandlerContext.fireChannelRead(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.protected voiddecodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Is called one last time when theChannelHandlerContextgoes in-active.protected final voidfinal voidDo nothing by default, sub-classes may override this method.protected ByteBufReturns the internal cumulative buffer of this decoder.booleanIftruethen only one message is decoded on eachByteToMessageDecoder.channelRead(ChannelHandlerContext, Object)call.voidsetCumulator(ByteToMessageDecoder.Cumulator cumulator) Set theByteToMessageDecoder.Cumulatorto use for cumulate the receivedByteBufs.voidsetDiscardAfterReads(int discardAfterReads) Set the number of reads after whichByteBuf.discardSomeReadBytes()are called and so free up memory.voidsetSingleDecode(boolean singleDecode) If set then only one message is decoded on eachByteToMessageDecoder.channelRead(ChannelHandlerContext, Object)call.voiduserEventTriggered(ChannelHandlerContext ctx, Object evt) CallsChannelHandlerContext.fireUserEventTriggered(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.Methods inherited from class ChannelInboundHandlerAdapter
channelRegistered, channelUnregisteredModifier and TypeMethodDescriptionvoidCallsChannelHandlerContext.fireChannelRegistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelUnregistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.Methods inherited from class ChannelHandlerAdapter
ensureNotSharable, isSharableModifier and TypeMethodDescriptionprotected voidbooleanReturntrueif the implementation isChannelHandler.Sharableand so can be added to differentChannelPipelines.
-
Constructor Details
-
HttpToHttp2ConnectionHandler
protected HttpToHttp2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders) -
HttpToHttp2ConnectionHandler
protected HttpToHttp2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway) -
HttpToHttp2ConnectionHandler
protected HttpToHttp2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway, HttpScheme httpScheme) -
HttpToHttp2ConnectionHandler
protected HttpToHttp2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway, boolean flushPreface, HttpScheme httpScheme)
-
-
Method Details
-
write
Handles conversion ofHttpMessageandHttpContentto HTTP/2 frames.- Specified by:
writein interfaceChannelOutboundHandler- Overrides:
writein classHttp2ConnectionHandler- Parameters:
ctx- theChannelHandlerContextfor which the write operation is mademsg- the message to writepromise- theChannelPromiseto notify once the operation completes
-