Class BasicHttpClientCodec
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.channel.CombinedChannelDuplexHandler<BasicHttpResponseDecoder,io.netty.handler.codec.http.HttpRequestEncoder>
com.linkedin.alpini.netty4.handlers.BasicHttpClientCodec
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
,io.netty.handler.codec.http.HttpClientUpgradeHandler.SourceCodec
public final class BasicHttpClientCodec
extends io.netty.channel.CombinedChannelDuplexHandler<BasicHttpResponseDecoder,io.netty.handler.codec.http.HttpRequestEncoder>
implements io.netty.handler.codec.http.HttpClientUpgradeHandler.SourceCodec
A combination of
HttpRequestEncoder
and BasicHttpResponseDecoder
which enables easier client side HTTP implementation. HttpClientCodec
provides additional state management for HEAD and CONNECT
requests, which BasicHttpResponseDecoder
lacks. Please refer to
BasicHttpResponseDecoder
to learn what additional state management needs
to be done for HEAD and CONNECT and why
BasicHttpResponseDecoder
can not handle it by itself.
If the Channel
is closed and there are missing responses,
a PrematureChannelClosureException
is thrown.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Constructor Summary
ConstructorDescriptionCreates a new instance with the default decoder options (maxInitialLineLength (4096
},maxHeaderSize (8192)
, andmaxChunkSize (8192)
).BasicHttpClientCodec
(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) Creates a new instance with the specified decoder options.BasicHttpClientCodec
(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse) Creates a new instance with the specified decoder options.BasicHttpClientCodec
(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders) Creates a new instance with the specified decoder options.BasicHttpClientCodec
(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, boolean parseHttpAfterConnectRequest) Creates a new instance with the specified decoder options.BasicHttpClientCodec
(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize) Creates a new instance with the specified decoder options.BasicHttpClientCodec
(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest) Creates a new instance with the specified decoder options. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
prepareUpgradeFrom
(io.netty.channel.ChannelHandlerContext ctx) Prepares to upgrade to another protocol from HTTP.void
setSingleDecode
(boolean singleDecode) void
upgradeFrom
(io.netty.channel.ChannelHandlerContext ctx) Upgrades to another protocol from HTTP.Methods inherited from class io.netty.channel.CombinedChannelDuplexHandler
bind, channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, handlerAdded, handlerRemoved, inboundHandler, init, outboundHandler, read, removeInboundHandler, removeOutboundHandler, userEventTriggered, write
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Constructor Details
-
BasicHttpClientCodec
public BasicHttpClientCodec()Creates a new instance with the default decoder options (maxInitialLineLength (4096
},maxHeaderSize (8192)
, andmaxChunkSize (8192)
). -
BasicHttpClientCodec
public BasicHttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) Creates a new instance with the specified decoder options. -
BasicHttpClientCodec
public BasicHttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse) Creates a new instance with the specified decoder options. -
BasicHttpClientCodec
public BasicHttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders) Creates a new instance with the specified decoder options. -
BasicHttpClientCodec
public BasicHttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, boolean parseHttpAfterConnectRequest) Creates a new instance with the specified decoder options. -
BasicHttpClientCodec
public BasicHttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize) Creates a new instance with the specified decoder options. -
BasicHttpClientCodec
public BasicHttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest) Creates a new instance with the specified decoder options.
-
-
Method Details
-
prepareUpgradeFrom
public void prepareUpgradeFrom(io.netty.channel.ChannelHandlerContext ctx) Prepares to upgrade to another protocol from HTTP. Disables theHttpRequestEncoder
.- Specified by:
prepareUpgradeFrom
in interfaceio.netty.handler.codec.http.HttpClientUpgradeHandler.SourceCodec
-
upgradeFrom
public void upgradeFrom(io.netty.channel.ChannelHandlerContext ctx) Upgrades to another protocol from HTTP. Removes the BasicHttpResponseDecoder andHttpRequestEncoder
from the pipeline.- Specified by:
upgradeFrom
in interfaceio.netty.handler.codec.http.HttpClientUpgradeHandler.SourceCodec
-
setSingleDecode
public void setSingleDecode(boolean singleDecode) -
isSingleDecode
public boolean isSingleDecode()
-