public class HttpClientCodec extends java.lang.Object implements ChannelUpstreamHandler, ChannelDownstreamHandler
HttpRequestEncoder and HttpResponseDecoder
which enables easier client side HTTP implementation. HttpClientCodec
provides additional state management for HEAD and CONNECT
requests, which HttpResponseDecoder lacks. Please refer to
HttpResponseDecoder to learn what additional state management needs
to be done for HEAD and CONNECT and why
HttpResponseDecoder can not handle it by itself.
If the Channel gets closed and there are requests missing for a response
a PrematureChannelClosureException is thrown.HttpServerCodec| Modifier and Type | Class and Description |
|---|---|
private class |
HttpClientCodec.Decoder |
private class |
HttpClientCodec.Encoder |
ChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
private HttpResponseDecoder |
decoder |
(package private) boolean |
done
If true, decoding stops (i.e.
|
private HttpRequestEncoder |
encoder |
private boolean |
failOnMissingResponse |
(package private) java.util.Queue<HttpMethod> |
queue
A queue that is used for correlating a request and a response.
|
private java.util.concurrent.atomic.AtomicLong |
requestResponseCounter |
| Constructor and Description |
|---|
HttpClientCodec()
Creates a new instance with the default decoder options
(
maxInitialLineLength (4096}, maxHeaderSize (8192), and
maxChunkSize (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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
handleDownstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified downstream event.
|
void |
handleUpstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified upstream event.
|
final java.util.Queue<HttpMethod> queue
volatile boolean done
private final HttpRequestEncoder encoder
private final HttpResponseDecoder decoder
private final java.util.concurrent.atomic.AtomicLong requestResponseCounter
private final boolean failOnMissingResponse
public HttpClientCodec()
maxInitialLineLength (4096}, maxHeaderSize (8192), and
maxChunkSize (8192)).public HttpClientCodec(int maxInitialLineLength,
int maxHeaderSize,
int maxChunkSize)
public HttpClientCodec(int maxInitialLineLength,
int maxHeaderSize,
int maxChunkSize,
boolean failOnMissingResponse)
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws java.lang.Exception
ChannelUpstreamHandlerhandleUpstream in interface ChannelUpstreamHandlerctx - the context object for this handlere - the upstream event to process or interceptjava.lang.Exceptionpublic void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws java.lang.Exception
ChannelDownstreamHandlerhandleDownstream in interface ChannelDownstreamHandlerctx - the context object for this handlere - the downstream event to process or interceptjava.lang.Exception