- java.lang.Object
-
- io.netty5.channel.ChannelHandlerAdapter
-
- io.netty5.channel.CombinedChannelDuplexHandler<HttpResponseDecoder,HttpRequestEncoder>
-
- io.netty5.handler.codec.http.HttpClientCodec
-
- All Implemented Interfaces:
ChannelHandler,HttpClientUpgradeHandler.SourceCodec
public final class HttpClientCodec extends CombinedChannelDuplexHandler<HttpResponseDecoder,HttpRequestEncoder> implements HttpClientUpgradeHandler.SourceCodec
A combination ofHttpRequestEncoderandHttpResponseDecoderwhich enables easier client side HTTP implementation.HttpClientCodecprovides additional state management for HEAD and CONNECT requests, whichHttpResponseDecoderlacks. Please refer toHttpResponseDecoderto learn what additional state management needs to be done for HEAD and CONNECT and whyHttpResponseDecodercan not handle it by itself. If theChannelis closed and there are missing responses, aPrematureChannelClosureExceptionis thrown.- See Also:
HttpServerCodec
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_FAIL_ON_MISSING_RESPONSEstatic booleanDEFAULT_PARSE_HTTP_AFTER_CONNECT_REQUEST
-
Constructor Summary
Constructors Constructor Description HttpClientCodec()Creates a new instance with the default decoder options (maxInitialLineLength (4096},maxHeaderSize (8192), andmaxChunkSize (8192)).HttpClientCodec(int maxInitialLineLength, int maxHeaderSize)Creates a new instance with the specified decoder options.HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse)Creates a new instance with the specified decoder options.HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders)Creates a new instance with the specified decoder options.HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders, boolean parseHttpAfterConnectRequest)Creates a new instance with the specified decoder options.HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize)Creates a new instance with the specified decoder options.HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest)Creates a new instance with the specified decoder options.HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest, boolean allowDuplicateContentLengths)Creates a new instance with the specified decoder options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisSingleDecode()voidprepareUpgradeFrom(ChannelHandlerContext ctx)Prepares to upgrade to another protocol from HTTP.voidsetSingleDecode(boolean singleDecode)voidupgradeFrom(ChannelHandlerContext ctx)Upgrades to another protocol from HTTP.-
Methods inherited from class io.netty5.channel.CombinedChannelDuplexHandler
bind, channelActive, channelExceptionCaught, channelInactive, channelInboundEvent, channelRead, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, inboundHandler, init, isSharable, outboundHandler, pendingOutboundBytes, read, register, removeInboundHandler, removeOutboundHandler, sendOutboundEvent, shutdown, write
-
-
-
-
Field Detail
-
DEFAULT_FAIL_ON_MISSING_RESPONSE
public static final boolean DEFAULT_FAIL_ON_MISSING_RESPONSE
- See Also:
- Constant Field Values
-
DEFAULT_PARSE_HTTP_AFTER_CONNECT_REQUEST
public static final boolean DEFAULT_PARSE_HTTP_AFTER_CONNECT_REQUEST
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpClientCodec
public HttpClientCodec()
Creates a new instance with the default decoder options (maxInitialLineLength (4096},maxHeaderSize (8192), andmaxChunkSize (8192)).
-
HttpClientCodec
public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize)Creates a new instance with the specified decoder options.
-
HttpClientCodec
public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse)Creates a new instance with the specified decoder options.
-
HttpClientCodec
public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders)Creates a new instance with the specified decoder options.
-
HttpClientCodec
public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders, boolean parseHttpAfterConnectRequest)Creates a new instance with the specified decoder options.
-
HttpClientCodec
public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize)Creates a new instance with the specified decoder options.
-
HttpClientCodec
public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest)Creates a new instance with the specified decoder options.
-
HttpClientCodec
public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest, boolean allowDuplicateContentLengths)Creates a new instance with the specified decoder options.
-
-
Method Detail
-
prepareUpgradeFrom
public void prepareUpgradeFrom(ChannelHandlerContext ctx)
Prepares to upgrade to another protocol from HTTP. Disables theHttpClientCodec.Encoder.- Specified by:
prepareUpgradeFromin interfaceHttpClientUpgradeHandler.SourceCodec
-
upgradeFrom
public void upgradeFrom(ChannelHandlerContext ctx)
Upgrades to another protocol from HTTP. Removes theHttpClientCodec.DecoderandHttpClientCodec.Encoderfrom the pipeline.- Specified by:
upgradeFromin interfaceHttpClientUpgradeHandler.SourceCodec
-
setSingleDecode
public void setSingleDecode(boolean singleDecode)
-
isSingleDecode
public boolean isSingleDecode()
-
-