Package io.netty.handler.codec.http2
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 io.netty.handler.codec.ByteToMessageDecoder
ByteToMessageDecoder.Cumulator
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsFields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
HttpToHttp2ConnectionHandler
(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders) protected
HttpToHttp2ConnectionHandler
(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway) protected
HttpToHttp2ConnectionHandler
(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway, boolean flushPreface, HttpScheme httpScheme) protected
HttpToHttp2ConnectionHandler
(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, boolean validateHeaders, boolean decoupleCloseAndGoAway, HttpScheme httpScheme) -
Method Summary
Modifier and TypeMethodDescriptionprivate int
getStreamId
(HttpHeaders httpHeaders) Get the next stream id either from theHttpHeaders
object or HTTP/2 codecvoid
write
(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) Handles conversion ofHttpMessage
andHttpContent
to HTTP/2 frames.private static void
writeHeaders
(ChannelHandlerContext ctx, Http2ConnectionEncoder encoder, int streamId, HttpHeaders headers, Http2Headers http2Headers, boolean endStream, Http2CodecUtil.SimpleChannelPromiseAggregator promiseAggregator) Methods inherited from class io.netty.handler.codec.http2.Http2ConnectionHandler
bind, channelActive, channelInactive, channelReadComplete, channelReadComplete0, 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, resetStream
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelRead, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerRemoved
-
Field Details
-
validateHeaders
private final boolean validateHeaders -
currentStreamId
private int currentStreamId -
httpScheme
-
-
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
-
getStreamId
Get the next stream id either from theHttpHeaders
object or HTTP/2 codec- Parameters:
httpHeaders
- The HTTP/1.x headers object to look for the stream id- Returns:
- The stream id to use with this
HttpHeaders
object - Throws:
Exception
- If thehttpHeaders
object specifies an invalid stream id
-
write
Handles conversion ofHttpMessage
andHttpContent
to HTTP/2 frames.- Specified by:
write
in interfaceChannelOutboundHandler
- Overrides:
write
in classHttp2ConnectionHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- theChannelPromise
to notify once the operation completes
-
writeHeaders
private static void writeHeaders(ChannelHandlerContext ctx, Http2ConnectionEncoder encoder, int streamId, HttpHeaders headers, Http2Headers http2Headers, boolean endStream, Http2CodecUtil.SimpleChannelPromiseAggregator promiseAggregator)
-