Top Description Inners Fields Constructors Methods
io.netty5.handler.codec.http

public final Class HttpServerCodec

extends CombinedChannelDuplexHandler<HttpRequestDecoder, HttpResponseEncoder>
implements SourceCodec
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.http.HttpServerUpgradeHandler.SourceCodec
Imports
io.netty5.buffer.Buffer, io.netty5.channel.ChannelHandlerContext, .CombinedChannelDuplexHandler, io.netty5.channel.internal.DelegatingChannelHandlerContext, java.util.ArrayDeque, .Queue

A combination of HttpRequestDecoder and HttpResponseEncoder which enables easier server side HTTP implementation.
See Also
HttpClientCodec

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class

Field Summary

Modifier and TypeField and Description
private final Queue<HttpMethod>
queue

A queue that is used for correlating a request and a response.

Constructor Summary

AccessConstructor and Description
public
HttpServerCodec()

Creates a new instance with the default decoder options (maxInitialLineLength (4096}, maxHeaderSize (8192), and maxChunkSize (8192)).

public
HttpServerCodec(int maxInitialLineLength, int maxHeaderSize)

Creates a new instance with the specified decoder options.

public
HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders)

Creates a new instance with the specified decoder options.

public
HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders, int initialBufferSize)

Creates a new instance with the specified decoder options.

public
HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders, int initialBufferSize, boolean allowDuplicateContentLengths)

Creates a new instance with the specified decoder options.

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from io.netty5.channel.CombinedChannelDuplexHandler:
bindchannelActivechannelExceptionCaughtchannelInactivechannelInboundEventchannelReadchannelReadCompletechannelRegisteredchannelShutdownchannelUnregisteredchannelWritabilityChangedcloseconnectderegisterdisconnectflushhandlerAddedhandlerRemovedinboundHandlerinitisSharableoutboundHandlerpendingOutboundBytesreadregisterremoveInboundHandlerremoveOutboundHandlersendOutboundEventshutdownwrite

Field Detail

queueback to summary
private final Queue<HttpMethod> queue

A queue that is used for correlating a request and a response.

Constructor Detail

HttpServerCodecback to summary
public HttpServerCodec()

Creates a new instance with the default decoder options (maxInitialLineLength (4096}, maxHeaderSize (8192), and maxChunkSize (8192)).

HttpServerCodecback to summary
public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize)

Creates a new instance with the specified decoder options.

HttpServerCodecback to summary
public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders)

Creates a new instance with the specified decoder options.

HttpServerCodecback to summary
public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders, int initialBufferSize)

Creates a new instance with the specified decoder options.

HttpServerCodecback to summary
public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders, int initialBufferSize, boolean allowDuplicateContentLengths)

Creates a new instance with the specified decoder options.

Method Detail

upgradeFromback to summary
public void upgradeFrom(ChannelHandlerContext ctx)

Implements io.netty5.handler.codec.http.HttpServerUpgradeHandler.SourceCodec.upgradeFrom.

Upgrades to another protocol from HTTP. Removes the HttpRequestDecoder and HttpResponseEncoder from the pipeline.

Annotations
@Override
io.netty5.handler.codec.http back to summary

private final Class HttpServerCodec.HttpServerRequestDecoder

extends HttpRequestDecoder
Class Inheritance

Field Summary

Modifier and TypeField and Description
private ChannelHandlerContext

Constructor Summary

AccessConstructor and Description
pack-priv
HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize)

pack-priv
HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders)

pack-priv
HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders, int initialBufferSize)

pack-priv
HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders, int initialBufferSize, boolean allowDuplicateContentLengths)

Method Summary

Modifier and TypeMethod and Description
protected void
decode(final ChannelHandlerContext ctx, Buffer
the Buffer from which to read data
buffer
)

Overrides io.netty5.handler.codec.http.HttpObjectDecoder.decode.

Decode the from one Buffer to another.
protected void
Inherited from io.netty5.handler.codec.http.HttpRequestDecoder:
createInvalidMessagecreateMessageisDecodingRequest

Field Detail

contextback to summary
private ChannelHandlerContext context

Hides io.netty5.handler.codec.ByteToMessageDecoder.context.

Constructor Detail

HttpServerRequestDecoderback to summary
pack-priv HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize)
HttpServerRequestDecoderback to summary
pack-priv HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders)
HttpServerRequestDecoderback to summary
pack-priv HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders, int initialBufferSize)
HttpServerRequestDecoderback to summary
pack-priv HttpServerRequestDecoder(int maxInitialLineLength, int maxHeaderSize, boolean validateHeaders, int initialBufferSize, boolean allowDuplicateContentLengths)

Method Detail

decodeback to summary
protected void decode(final ChannelHandlerContext ctx, Buffer buffer) throws Exception

Overrides io.netty5.handler.codec.http.HttpObjectDecoder.decode.

Doc from io.netty5.handler.codec.ByteToMessageDecoder.decode.

Decode the from one Buffer to another. This method will be called till either the input Buffer has nothing to read when return from this method or till nothing was read from the input Buffer.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

buffer:Buffer

the Buffer from which to read data

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
handlerAdded0back to summary
protected void handlerAdded0(final ChannelHandlerContext ctx)

Overrides io.netty5.handler.codec.ByteToMessageDecoder.handlerAdded0.

Annotations
@Override
io.netty5.handler.codec.http back to summary

private final Class HttpServerCodec.HttpServerResponseEncoder

extends HttpResponseEncoder
Class Inheritance

Field Summary

Modifier and TypeField and Description
private HttpMethod

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected boolean
isContentAlwaysEmpty(HttpResponse
the message to test
msg
)

Overrides io.netty5.handler.codec.http.HttpResponseEncoder.isContentAlwaysEmpty.

Determine whether a message has a content or not.
protected void
sanitizeHeadersBeforeEncode(HttpResponse msg, boolean isAlwaysEmpty)

Overrides io.netty5.handler.codec.http.HttpResponseEncoder.sanitizeHeadersBeforeEncode.

Allows to sanitize headers of the message before encoding these.
Inherited from io.netty5.handler.codec.http.HttpResponseEncoder:
acceptOutboundMessageencodeInitialLine

Field Detail

methodback to summary
private HttpMethod method

Constructor Detail

HttpServerResponseEncoderback to summary
private HttpServerResponseEncoder()

Method Detail

isContentAlwaysEmptyback to summary
protected boolean isContentAlwaysEmpty(HttpResponse msg)

Overrides io.netty5.handler.codec.http.HttpResponseEncoder.isContentAlwaysEmpty.

Doc from io.netty5.handler.codec.http.HttpObjectEncoder.isContentAlwaysEmpty.

Determine whether a message has a content or not. Some message may have headers indicating a content without having an actual content, e.g the response to an HEAD or CONNECT request.

Parameters
msg:HttpResponse

the message to test

Returns:boolean

true to signal the message has no content

Annotations
@Override
sanitizeHeadersBeforeEncodeback to summary
protected void sanitizeHeadersBeforeEncode(HttpResponse msg, boolean isAlwaysEmpty)

Overrides io.netty5.handler.codec.http.HttpResponseEncoder.sanitizeHeadersBeforeEncode.

Doc from io.netty5.handler.codec.http.HttpObjectEncoder.sanitizeHeadersBeforeEncode.

Allows to sanitize headers of the message before encoding these.

Annotations
@Override