Package io.netty.handler.codec.http2
Class Http2StreamFrameToHttpObjectCodec
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.MessageToMessageCodec<Http2StreamFrame,HttpObject>
io.netty.handler.codec.http2.Http2StreamFrameToHttpObjectCodec
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
,ChannelOutboundHandler
@Sharable
public class Http2StreamFrameToHttpObjectCodec
extends MessageToMessageCodec<Http2StreamFrame,HttpObject>
This handler converts from
Http2StreamFrame
to HttpObject
,
and back. It can be used as an adapter in conjunction with Http2MultiplexCodec
to make http/2 connections backward-compatible with
ChannelHandler
s expecting HttpObject
For simplicity, it converts to chunked encoding unless the entire stream
is a single header.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private static final AttributeKey
<HttpScheme> private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionHttp2StreamFrameToHttpObjectCodec
(boolean isServer) Http2StreamFrameToHttpObjectCodec
(boolean isServer, boolean validateHeaders) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if and only if the specified message can be decoded by this codec.private static Channel
private static HttpScheme
private static Attribute
<HttpScheme> protected void
decode
(ChannelHandlerContext ctx, Http2StreamFrame frame, List<Object> out) protected void
encode
(ChannelHandlerContext ctx, HttpObject obj, List<Object> out) Encode from anHttpObject
to anHttp2StreamFrame
.private void
encodeLastContent
(LastHttpContent last, List<Object> out) void
Do nothing by default, sub-classes may override this method.private static boolean
isContentAlwaysEmpty
(CharSequence status) private static boolean
An informational response using a 1xx status code other than 101 is transmitted as a HEADERS frameprotected boolean
private FullHttpMessage
newFullMessage
(int id, Http2Headers headers, ByteBufAllocator alloc) private HttpMessage
newMessage
(int id, Http2Headers headers) private Http2Headers
toHttp2Headers
(ChannelHandlerContext ctx, HttpMessage msg) Methods inherited from class io.netty.handler.codec.MessageToMessageCodec
acceptOutboundMessage, channelRead, write
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, 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
-
SCHEME_ATTR_KEY
-
isServer
private final boolean isServer -
validateHeaders
private final boolean validateHeaders
-
-
Constructor Details
-
Http2StreamFrameToHttpObjectCodec
public Http2StreamFrameToHttpObjectCodec(boolean isServer, boolean validateHeaders) -
Http2StreamFrameToHttpObjectCodec
public Http2StreamFrameToHttpObjectCodec(boolean isServer)
-
-
Method Details
-
acceptInboundMessage
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
-
decode
protected void decode(ChannelHandlerContext ctx, Http2StreamFrame frame, List<Object> out) throws Exception - Specified by:
decode
in classMessageToMessageCodec<Http2StreamFrame,
HttpObject> - Throws:
Exception
- See Also:
-
encodeLastContent
-
encode
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.- Specified by:
encode
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:
-
toHttp2Headers
-
newMessage
- Throws:
Http2Exception
-
newFullMessage
private FullHttpMessage newFullMessage(int id, Http2Headers headers, ByteBufAllocator alloc) throws Http2Exception - Throws:
Http2Exception
-
handlerAdded
Description copied from class:ChannelHandlerAdapter
Do nothing by default, sub-classes may override this method.- Specified by:
handlerAdded
in interfaceChannelHandler
- Overrides:
handlerAdded
in classChannelHandlerAdapter
- Throws:
Exception
-
isSsl
-
connectionScheme
-
connectionSchemeAttribute
-
connectionChannel
-
isInformationalResponseHeaderFrame
An informational response using a 1xx status code other than 101 is transmitted as a HEADERS frame -
isContentAlwaysEmpty
-