Class HttpClientCodec
- java.lang.Object
-
- org.jboss.netty.handler.codec.http.HttpClientCodec
-
- All Implemented Interfaces:
ChannelDownstreamHandler,ChannelHandler,ChannelUpstreamHandler
public class HttpClientCodec extends java.lang.Object implements ChannelUpstreamHandler, ChannelDownstreamHandler
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 theChannelgets closed and there are requests missing for a response aPrematureChannelClosureExceptionis thrown.- See Also:
HttpServerCodec
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classHttpClientCodec.Decoderprivate classHttpClientCodec.Encoder-
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private HttpResponseDecoderdecoder(package private) booleandoneIf true, decoding stops (i.e.private HttpRequestEncoderencoderprivate booleanfailOnMissingResponse(package private) java.util.Queue<HttpMethod>queueA queue that is used for correlating a request and a response.private java.util.concurrent.atomic.AtomicLongrequestResponseCounter
-
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, int maxChunkSize)Creates a new instance with the specified decoder options.HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse)Creates a new instance with the specified decoder options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandleDownstream(ChannelHandlerContext ctx, ChannelEvent e)Handles the specified downstream event.voidhandleUpstream(ChannelHandlerContext ctx, ChannelEvent e)Handles the specified upstream event.
-
-
-
Field Detail
-
queue
final java.util.Queue<HttpMethod> queue
A queue that is used for correlating a request and a response.
-
done
volatile boolean done
If true, decoding stops (i.e. pass-through)
-
encoder
private final HttpRequestEncoder encoder
-
decoder
private final HttpResponseDecoder decoder
-
requestResponseCounter
private final java.util.concurrent.atomic.AtomicLong requestResponseCounter
-
failOnMissingResponse
private final boolean failOnMissingResponse
-
-
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, int maxChunkSize)Creates a new instance with the specified decoder options.
-
HttpClientCodec
public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse)Creates a new instance with the specified decoder options.
-
-
Method Detail
-
handleUpstream
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws java.lang.Exception
Description copied from interface:ChannelUpstreamHandlerHandles the specified upstream event.- Specified by:
handleUpstreamin interfaceChannelUpstreamHandler- Parameters:
ctx- the context object for this handlere- the upstream event to process or intercept- Throws:
java.lang.Exception
-
handleDownstream
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws java.lang.Exception
Description copied from interface:ChannelDownstreamHandlerHandles the specified downstream event.- Specified by:
handleDownstreamin interfaceChannelDownstreamHandler- Parameters:
ctx- the context object for this handlere- the downstream event to process or intercept- Throws:
java.lang.Exception
-
-