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

public Class Http2StreamFrameToHttpObjectCodec

extends MessageToMessageCodec<Http2StreamFrame, HttpObject>
Class Inheritance
Annotations
@UnstableApi
Imports
io.netty5.buffer.Buffer, .BufferAllocator, io.netty5.channel.Channel, .ChannelHandler, .ChannelHandlerContext, io.netty5.handler.codec.EncoderException, .MessageToMessageCodec, io.netty5.handler.codec.http.DefaultHttpContent, .DefaultLastHttpContent, .FullHttpMessage, .FullHttpResponse, .HttpContent, .HttpHeaderNames, .HttpHeaderValues, .HttpMessage, .HttpObject, .HttpRequest, .HttpResponse, .HttpResponseStatus, .HttpScheme, .HttpUtil, .HttpVersion, .LastHttpContent, io.netty5.handler.codec.http.headers.HeaderValidationException, io.netty5.handler.codec.http2.headers.Http2Headers, io.netty5.handler.ssl.SslHandler, io.netty5.util.Attribute, .AttributeKey, io.netty5.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 Http2MultiplexHandler 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.netty5.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
encodeAndClose(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
)

Overrides io.netty5.handler.codec.MessageToMessageCodec.encodeAndClose.

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

Overrides default io.netty5.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
public boolean
isSharable()

Overrides default io.netty5.channel.ChannelHandler.isSharable.

Returns true if this handler is sharable and thus can be added to more than one ChannelPipeline.
protected boolean
private FullHttpMessage<?>
newFullMessage(final int id, final Http2Headers headers, final BufferAllocator alloc)

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

private Http2Headers
Inherited from io.netty5.handler.codec.MessageToMessageCodec:
acceptOutboundMessagechannelReaddecodeencodewrite

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.netty5.handler.codec.MessageToMessageCodec.acceptInboundMessage.

Doc from io.netty5.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)
decodeAndCloseback to summary
protected void decodeAndClose(ChannelHandlerContext ctx, Http2StreamFrame frame) throws Exception

Overrides io.netty5.handler.codec.MessageToMessageCodec.decodeAndClose.

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

Overrides io.netty5.handler.codec.MessageToMessageCodec.encodeAndClose.

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 default io.netty5.channel.ChannelHandler.handlerAdded.

Doc from io.netty5.channel.ChannelHandler.handlerAdded.

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

Annotations
@Override
isSharableback to summary
public boolean isSharable()

Overrides default io.netty5.channel.ChannelHandler.isSharable.

Doc from io.netty5.channel.ChannelHandler.isSharable.

Returns true if this handler is sharable and thus can be added to more than one ChannelPipeline. By default, this method returns false. If this method returns false, 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.

Annotations
@Override
isSslback to summary
protected boolean isSsl(final ChannelHandlerContext ctx)
newFullMessageback to summary
private FullHttpMessage<?> newFullMessage(final int id, final Http2Headers headers, final BufferAllocator 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) throws Exception