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 is closed and there are missing responses,
a PrematureChannelClosureException is thrown.
Without header validation, your system can become vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') .
This recommendation stands even when both peers in the HTTP exchange are trusted, as it helps with defence-in-depth.
HttpServerCodec
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| public static final boolean | |
| public static final boolean | |
| private boolean | done
If true, decoding stops (i.e. pass-through) |
| private final boolean | |
| private final boolean | |
| private final Queue | queue
A queue that is used for correlating a request and a response. |
| private final AtomicLong |
| Access | Constructor and Description |
|---|---|
| public | HttpClientCodec()
Creates a new instance with the default decoder options
( |
| public | HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize)
Creates a new instance with the specified decoder options. |
| public | HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse)
Creates a new instance with the specified decoder options. |
| public | HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders)
Deprecated
Prefer the
Creates a new instance with the specified decoder options.
HttpClientCodec(int, int, int, boolean) constructor,
to always enable header validation.
|
| public | HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, boolean parseHttpAfterConnectRequest)
Deprecated
Prefer the
Creates a new instance with the specified decoder options.
HttpClientCodec(HttpDecoderConfig, boolean, boolean) constructor,
to always enable header validation.
|
| public | HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize)
Deprecated
Prefer the
Creates a new instance with the specified decoder options.
HttpClientCodec(HttpDecoderConfig, boolean, boolean) constructor,
to always enable header validation.
|
| public | HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest)
Deprecated
Prefer the
Creates a new instance with the specified decoder options.
HttpClientCodec(HttpDecoderConfig, boolean, boolean) constructor,
to always enable header validation.
|
| public | HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest, boolean allowDuplicateContentLengths)
Deprecated
Prefer the
Creates a new instance with the specified decoder options.
HttpClientCodec(HttpDecoderConfig, boolean, boolean) constructor,
to always enable header validation.
|
| public | HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest, boolean allowDuplicateContentLengths, boolean allowPartialChunks)
Deprecated
Prefer the
Creates a new instance with the specified decoder options.
HttpClientCodec(HttpDecoderConfig, boolean, boolean)
constructor, to always enable header validation.
|
| public | HttpClientCodec(HttpDecoderConfig config, boolean parseHttpAfterConnectRequest, boolean failOnMissingResponse)
Creates a new instance with the specified decoder options. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public void | prepareUpgradeFrom(ChannelHandlerContext ctx)
Implements io. |
| public void | |
| public void | upgradeFrom(ChannelHandlerContext ctx)
Implements io. |
| DEFAULT_FAIL_ON_MISSING_RESPONSE | back to summary |
|---|---|
| public static final boolean DEFAULT_FAIL_ON_MISSING_RESPONSE | |
| DEFAULT_PARSE_HTTP_AFTER_CONNECT_REQUEST | back to summary |
|---|---|
| public static final boolean DEFAULT_PARSE_HTTP_AFTER_CONNECT_REQUEST | |
| done | back to summary |
|---|---|
| private boolean done If true, decoding stops (i.e. pass-through) | |
| failOnMissingResponse | back to summary |
|---|---|
| private final boolean failOnMissingResponse | |
| parseHttpAfterConnectRequest | back to summary |
|---|---|
| private final boolean parseHttpAfterConnectRequest | |
| queue | back to summary |
|---|---|
| private final Queue<HttpMethod> queue A queue that is used for correlating a request and a response. | |
| requestResponseCounter | back to summary |
|---|---|
| private final AtomicLong requestResponseCounter | |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec() Creates a new instance with the default decoder options
( | |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) Creates a new instance with the specified decoder options. | |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse) Creates a new instance with the specified decoder options. | |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders)
Deprecated Prefer the Creates a new instance with the specified decoder options.
| |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, boolean parseHttpAfterConnectRequest)
Deprecated Prefer the Creates a new instance with the specified decoder options.
| |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize)
Deprecated Prefer the Creates a new instance with the specified decoder options.
| |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest)
Deprecated Prefer the Creates a new instance with the specified decoder options.
| |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest, boolean allowDuplicateContentLengths)
Deprecated Prefer the Creates a new instance with the specified decoder options.
| |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest, boolean allowDuplicateContentLengths, boolean allowPartialChunks)
Deprecated Prefer the Creates a new instance with the specified decoder options.
| |
| HttpClientCodec | back to summary |
|---|---|
| public HttpClientCodec(HttpDecoderConfig config, boolean parseHttpAfterConnectRequest, boolean failOnMissingResponse) Creates a new instance with the specified decoder options. | |
| isSingleDecode | back to summary |
|---|---|
| public boolean isSingleDecode() | |
| prepareUpgradeFrom | back to summary |
|---|---|
| public void prepareUpgradeFrom(ChannelHandlerContext ctx) Implements io. Prepares to upgrade to another protocol from HTTP. Disables the
| |
| setSingleDecode | back to summary |
|---|---|
| public void setSingleDecode(boolean singleDecode) | |
| upgradeFrom | back to summary |
|---|---|
| public void upgradeFrom(ChannelHandlerContext ctx) Implements io. Upgrades to another protocol from HTTP. Removes the
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | channelInactive(ChannelHandlerContext ctx)
Overrides io. Implements io. ChannelHandlerContext#fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
|
| protected void | decode(ChannelHandlerContext
the ctx, ByteBuf ChannelHandlerContext which this ByteToMessageDecoder belongs tothe buffer, List<Object> ByteBuf from which to read datathe out)List to which decoded messages should be addedOverrides io. ByteBuf to an other.
|
| private void | |
| protected boolean |
| Decoder | back to summary |
|---|---|
| pack-priv Decoder(HttpDecoderConfig config) | |
| channelInactive | back to summary |
|---|---|
| public void channelInactive(ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Calls
| |
| decode | back to summary |
|---|---|
| protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception Overrides io. Doc from io. Decode the from one
| |
| decrement | back to summary |
|---|---|
| private void decrement(Object msg) | |
| isContentAlwaysEmpty | back to summary |
|---|---|
| protected boolean isContentAlwaysEmpty(HttpMessage msg) Overrides io.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| protected void | encode(ChannelHandlerContext
the ctx, Object ChannelHandlerContext which this MessageToMessageEncoder belongs tothe message to encode to an other one msg, List<Object> the out)List into which the encoded msg should be added
needs to do some kind of aggregationOverrides io. |
| upgraded | back to summary |
|---|---|
| pack-priv boolean upgraded | |
| Encoder | back to summary |
|---|---|
| private Encoder() | |
| encode | back to summary |
|---|---|
| protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception Overrides io. Doc from io. Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.
| |