Top Description Fields Constructors Methods
io.netty.handler.codec.http2

public Class Http2StreamFrameToHttpObjectCodec

extends MessageToMessageCodec<Http2StreamFrame, HttpObject>
Class Inheritance
Annotations
@UnstableApi
@Sharable
Imports
io.netty.buffer.ByteBufAllocator, .Unpooled, io.netty.channel.Channel, .ChannelHandler, .ChannelHandler.Sharable, .ChannelHandlerContext, io.netty.handler.codec.EncoderException, .MessageToMessageCodec, io.netty.handler.codec.http.DefaultHttpContent, .DefaultLastHttpContent, .FullHttpMessage, .FullHttpResponse, .HttpContent, .HttpHeaderNames, .HttpHeaderValues, .HttpMessage, .HttpObject, .HttpRequest, .HttpResponse, .HttpResponseStatus, .HttpScheme, .HttpStatusClass, .HttpUtil, .HttpVersion, .LastHttpContent, io.netty.handler.ssl.SslHandler, io.netty.util.Attribute, .AttributeKey, io.netty.util.internal.UnstableApi, java.util.List

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 ChannelHandlers expecting HttpObject For simplicity, it converts to chunked encoding unless the entire stream is a single header.

Field Summary

Modifier and TypeField and Description
private final boolean
private static final AttributeKey<HttpScheme>
private final boolean

Constructor Summary

AccessConstructor and Description
public
Http2StreamFrameToHttpObjectCodec(final boolean isServer, final boolean validateHeaders)

public
Http2StreamFrameToHttpObjectCodec(final boolean isServer)

Method Summary

Modifier and TypeMethod and Description
public boolean
acceptInboundMessage(Object
the message
msg
)

Overrides io.netty.handler.codec.MessageToMessageCodec.acceptInboundMessage.

Returns true 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
protected void
encode(ChannelHandlerContext
the ChannelHandlerContext which this handler belongs to
ctx
,
HttpObject
the HttpObject message to encode
obj
,
List<Object>
the List into which the encoded msg should be added needs to do some kind of aggregation
out
)

Implements abstract io.netty.handler.codec.MessageToMessageCodec.encode.

Encode from an HttpObject to an Http2StreamFrame.
private void
public void
handlerAdded(final ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
private static boolean
private static boolean
isInformationalResponseHeaderFrame(CharSequence status)

An informational response using a 1xx status code other than 101 is transmitted as a HEADERS frame

protected boolean
private FullHttpMessage
newFullMessage(final int id, final Http2Headers headers, final ByteBufAllocator alloc)

private HttpMessage
newMessage(final int id, final Http2Headers headers)

private Http2Headers
Inherited from io.netty.handler.codec.MessageToMessageCodec:
acceptOutboundMessagechannelReadwrite

Field Detail

isServerback to summary
private final boolean isServer
SCHEME_ATTR_KEYback to summary
private static final AttributeKey<HttpScheme> SCHEME_ATTR_KEY
validateHeadersback to summary
private final boolean validateHeaders

Constructor Detail

Http2StreamFrameToHttpObjectCodecback to summary
public Http2StreamFrameToHttpObjectCodec(final boolean isServer, final boolean validateHeaders)
Http2StreamFrameToHttpObjectCodecback to summary
public Http2StreamFrameToHttpObjectCodec(final boolean isServer)

Method Detail

acceptInboundMessageback to summary
public boolean acceptInboundMessage(Object msg) throws Exception

Overrides io.netty.handler.codec.MessageToMessageCodec.acceptInboundMessage.

Doc from io.netty.handler.codec.MessageToMessageCodec.acceptInboundMessage.

Returns true if and only if the specified message can be decoded by this codec.

Parameters
msg:Object

the message

Annotations
@Override
connectionChannelback to summary
private static Channel connectionChannel(ChannelHandlerContext ctx)
connectionSchemeback to summary
private static HttpScheme connectionScheme(ChannelHandlerContext ctx)
connectionSchemeAttributeback to summary
private static Attribute<HttpScheme> connectionSchemeAttribute(ChannelHandlerContext ctx)
decodeback to summary
protected void decode(ChannelHandlerContext ctx, Http2StreamFrame frame, List<Object> out) throws Exception

Implements abstract io.netty.handler.codec.MessageToMessageCodec.decode.

Annotations
@Override
encodeback to summary
protected void encode(ChannelHandlerContext ctx, HttpObject obj, List<Object> out) throws Exception

Implements abstract io.netty.handler.codec.MessageToMessageCodec.encode.

Encode from an HttpObject to an Http2StreamFrame. This method will be called for each written message that can be handled by this encoder.

Note

100-Continue responses that are NOT FullHttpResponse will be rejected.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this handler belongs to

obj:HttpObject

the HttpObject message to encode

out:List<Object>

the List into which the encoded msg should be added needs to do some kind of aggregation

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
encodeLastContentback to summary
private void encodeLastContent(LastHttpContent last, List<Object> out)
handlerAddedback to summary
public void handlerAdded(final ChannelHandlerContext ctx) throws Exception

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Doc from io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Annotations
@Override
isContentAlwaysEmptyback to summary
private static boolean isContentAlwaysEmpty(CharSequence status)
isInformationalResponseHeaderFrameback to summary
private static boolean isInformationalResponseHeaderFrame(CharSequence status)

An informational response using a 1xx status code other than 101 is transmitted as a HEADERS frame

isSslback to summary
protected boolean isSsl(final ChannelHandlerContext ctx)
newFullMessageback to summary
private FullHttpMessage newFullMessage(final int id, final Http2Headers headers, final ByteBufAllocator alloc) throws Http2Exception
newMessageback to summary
private HttpMessage newMessage(final int id, final Http2Headers headers) throws Http2Exception
toHttp2Headersback to summary
private Http2Headers toHttp2Headers(final ChannelHandlerContext ctx, final HttpMessage msg)