Module io.netty.codec.http2
Package io.netty5.handler.codec.http2
Class Http2StreamFrameToHttpObjectCodec
- java.lang.Object
-
- io.netty5.channel.ChannelHandlerAdapter
-
- io.netty5.handler.codec.MessageToMessageCodec<Http2StreamFrame,HttpObject>
-
- io.netty5.handler.codec.http2.Http2StreamFrameToHttpObjectCodec
-
- All Implemented Interfaces:
ChannelHandler
@UnstableApi public class Http2StreamFrameToHttpObjectCodec extends MessageToMessageCodec<Http2StreamFrame,HttpObject>
This handler converts fromHttp2StreamFrame
toHttpObject
, and back. It can be used as an adapter in conjunction withHttp2MultiplexHandler
to make http/2 connections backward-compatible withChannelHandler
s expectingHttpObject
For simplicity, it converts to chunked encoding unless the entire stream is a single header.
-
-
Constructor Summary
Constructors Constructor Description Http2StreamFrameToHttpObjectCodec(boolean isServer)
Http2StreamFrameToHttpObjectCodec(boolean isServer, boolean validateHeaders)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptInboundMessage(Object msg)
Returnstrue
if and only if the specified message can be decoded by this codec.protected void
decodeAndClose(ChannelHandlerContext ctx, Http2StreamFrame frame)
protected void
encodeAndClose(ChannelHandlerContext ctx, HttpObject obj, List<Object> out)
Encode from anHttpObject
to anHttp2StreamFrame
.void
handlerAdded(ChannelHandlerContext ctx)
Gets called after theChannelHandler
was added to the actual context and it's ready to handle events.boolean
isSharable()
Returnstrue
if this handler is sharable and thus can be added to more than oneChannelPipeline
.protected boolean
isSsl(ChannelHandlerContext ctx)
-
Methods inherited from class io.netty5.handler.codec.MessageToMessageCodec
acceptOutboundMessage, channelRead, decode, encode, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelExceptionCaught, channelInactive, channelInboundEvent, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerRemoved, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown
-
-
-
-
Method Detail
-
isSharable
public boolean isSharable()
Description copied from interface:ChannelHandler
Returnstrue
if this handler is sharable and thus can be added to more than oneChannelPipeline
. By default, this method returnsfalse
. If this method returnsfalse
, you have to create a new handler instance every time you add it to a pipeline because it has unshared state such as member variables.
-
acceptInboundMessage
public boolean acceptInboundMessage(Object msg) throws Exception
Description copied from class:MessageToMessageCodec
Returnstrue
if and only if the specified message can be decoded by this codec.- Overrides:
acceptInboundMessage
in classMessageToMessageCodec<Http2StreamFrame,HttpObject>
- Parameters:
msg
- the message- Throws:
Exception
-
decodeAndClose
protected void decodeAndClose(ChannelHandlerContext ctx, Http2StreamFrame frame) throws Exception
- Overrides:
decodeAndClose
in classMessageToMessageCodec<Http2StreamFrame,HttpObject>
- Throws:
Exception
- See Also:
MessageToMessageDecoder.decodeAndClose(ChannelHandlerContext, Object)
-
encodeAndClose
protected void encodeAndClose(ChannelHandlerContext ctx, HttpObject obj, List<Object> out) throws Exception
Encode from anHttpObject
to anHttp2StreamFrame
. This method will be called for each written message that can be handled by this encoder. NOTE: 100-Continue responses that are NOTFullHttpResponse
will be rejected.- Overrides:
encodeAndClose
in classMessageToMessageCodec<Http2StreamFrame,HttpObject>
- Parameters:
ctx
- theChannelHandlerContext
which this handler belongs toobj
- theHttpObject
message to encodeout
- theList
into which the encoded msg should be added needs to do some kind of aggregation- Throws:
Exception
- is thrown if an error occurs- See Also:
MessageToMessageEncoder.encodeAndClose(ChannelHandlerContext, Object, List)
-
handlerAdded
public void handlerAdded(ChannelHandlerContext ctx) throws Exception
Description copied from interface:ChannelHandler
Gets called after theChannelHandler
was added to the actual context and it's ready to handle events.- Throws:
Exception
-
isSsl
protected boolean isSsl(ChannelHandlerContext ctx)
-
-