public final class HttpDecoderConfig extends Object implements Cloneable
HttpObjectDecoder and its subclasses.
The HttpDecoderConfig objects are mutable to reduce allocation,
but also Cloneable in case a defensive copy is needed.
| Constructor and Description |
|---|
HttpDecoderConfig() |
| Modifier and Type | Method and Description |
|---|---|
HttpDecoderConfig |
clone() |
HttpHeadersFactory |
getHeadersFactory() |
int |
getInitialBufferSize() |
int |
getMaxChunkSize() |
int |
getMaxHeaderSize() |
int |
getMaxInitialLineLength() |
HttpHeadersFactory |
getTrailersFactory() |
boolean |
isAllowDuplicateContentLengths() |
boolean |
isAllowPartialChunks() |
boolean |
isChunkedSupported() |
boolean |
isStrictLineParsing() |
boolean |
isUseRfc9112TransferEncoding() |
HttpDecoderConfig |
setAllowDuplicateContentLengths(boolean allowDuplicateContentLengths)
Set whether more than one
Content-Length header is allowed. |
HttpDecoderConfig |
setAllowPartialChunks(boolean allowPartialChunks)
Set whether chunks can be split into multiple messages, if their chunk size exceeds the size of the input buffer.
|
HttpDecoderConfig |
setChunkedSupported(boolean chunkedSupported)
Set whether
Transfer-Encoding: Chunked should be supported. |
HttpDecoderConfig |
setHeadersFactory(HttpHeadersFactory headersFactory)
Set the
HttpHeadersFactory to use when creating new HTTP headers objects. |
HttpDecoderConfig |
setInitialBufferSize(int initialBufferSize)
Set the initial size of the temporary buffer used when parsing the lines of the HTTP headers.
|
HttpDecoderConfig |
setMaxChunkSize(int maxChunkSize)
Set the maximum chunk size.
|
HttpDecoderConfig |
setMaxHeaderSize(int maxHeaderSize)
Set the maximum line length of header lines.
|
HttpDecoderConfig |
setMaxInitialLineLength(int maxInitialLineLength)
Set the maximum length of the first line of the HTTP header.
|
HttpDecoderConfig |
setStrictLineParsing(boolean strictLineParsing)
The RFC 9112 specification for the HTTP protocol says that the initial start-line, and the following header
field-lines, must be separated by a Carriage Return (CR) and Line Feed (LF) octet pair, but also offers that
implementations "MAY" accept just a Line Feed octet as a separator.
|
HttpDecoderConfig |
setTrailersFactory(HttpHeadersFactory trailersFactory)
Set the
HttpHeadersFactory used to create HTTP trailers. |
HttpDecoderConfig |
setUseRfc9112TransferEncoding(boolean useRfc9112TransferEncoding)
The RFC 9112 specification is more strict than RFC 7230 with regards to having
Transfer-Encoding and
Content-Length headers in the same HTTP message. |
HttpDecoderConfig |
setValidateHeaders(boolean validateHeaders)
Set whether header validation should be enabled or not.
|
public int getInitialBufferSize()
public HttpDecoderConfig setInitialBufferSize(int initialBufferSize)
initialBufferSize - The buffer size in bytes.public int getMaxInitialLineLength()
public HttpDecoderConfig setMaxInitialLineLength(int maxInitialLineLength)
setMaxHeaderSize(int).maxInitialLineLength - The maximum length, in bytes.public int getMaxHeaderSize()
public HttpDecoderConfig setMaxHeaderSize(int maxHeaderSize)
You would typically set this to the same value as setMaxInitialLineLength(int).
maxHeaderSize - The maximum length, in bytes.public int getMaxChunkSize()
public HttpDecoderConfig setMaxChunkSize(int maxChunkSize)
maxChunkSize - The maximum chunk size, in bytes.public boolean isChunkedSupported()
public HttpDecoderConfig setChunkedSupported(boolean chunkedSupported)
Transfer-Encoding: Chunked should be supported.chunkedSupported - if false, then a Transfer-Encoding: Chunked header will produce an error,
instead of a stream of chunks.public boolean isAllowPartialChunks()
public HttpDecoderConfig setAllowPartialChunks(boolean allowPartialChunks)
allowPartialChunks - set to false to only allow sending whole chunks down the pipeline.public HttpHeadersFactory getHeadersFactory()
public HttpDecoderConfig setHeadersFactory(HttpHeadersFactory headersFactory)
HttpHeadersFactory to use when creating new HTTP headers objects.
The default headers factory is DefaultHttpHeadersFactory.headersFactory().
For the purpose of clone(), it is assumed that the factory is either immutable, or can otherwise be
shared across different decoders and decoder configs.
headersFactory - The header factory to use.public boolean isAllowDuplicateContentLengths()
public HttpDecoderConfig setAllowDuplicateContentLengths(boolean allowDuplicateContentLengths)
Content-Length header is allowed.
You usually want to disallow this (which is the default) as multiple Content-Length headers can indicate
a request- or response-splitting attack.allowDuplicateContentLengths - set to true to allow multiple content length headers.public HttpDecoderConfig setValidateHeaders(boolean validateHeaders)
You usually want header validation enabled (which is the default) in order to prevent request-/response-splitting attacks.
validateHeaders - set to false to disable header validation.public HttpHeadersFactory getTrailersFactory()
public HttpDecoderConfig setTrailersFactory(HttpHeadersFactory trailersFactory)
HttpHeadersFactory used to create HTTP trailers.
This differs from setHeadersFactory(HttpHeadersFactory) in that trailers have different validation
requirements.
The default trailer factory is DefaultHttpHeadersFactory.headersFactory().
For the purpose of clone(), it is assumed that the factory is either immutable, or can otherwise be
shared across different decoders and decoder configs.
trailersFactory - The headers factory to use for creating trailers.public boolean isStrictLineParsing()
public HttpDecoderConfig setStrictLineParsing(boolean strictLineParsing)
Parsing leniencies can increase compatibility with a wider range of implementations, but can also cause security vulnerabilities, when multiple systems disagree on the meaning of leniently parsed messages.
When strict line parsing is enabled (true), then Netty will enforce that start- and header
field-lines MUST be separated by a CR LF octet pair, and will produce messagas with failed
DecoderResults.
When strict line parsing is disabled (false), then Netty will accept lone LF octets as line
seperators for the start- and header field-lines.
See RFC 9112 Section 2.1.
strictLineParsing - Whether strict line parsing should be enabled (true),
or not (false).public boolean isUseRfc9112TransferEncoding()
public HttpDecoderConfig setUseRfc9112TransferEncoding(boolean useRfc9112TransferEncoding)
Transfer-Encoding and
Content-Length headers in the same HTTP message. Senders are now forbidden from including both headers
in the same message, while servers may reject such requests. When this setting is set to true, which
is the default, then such messages will be rejected.
When this setting is set to false, it restores the RFC 7230 behavior of instead removing any
Content-Length headers when Transfer-Encoding headers are present.
useRfc9112TransferEncoding - Whether to reject messages with both Transfer-Encoding and
Content-Length headers.HttpObjectDecoder.handleTransferEncodingChunkedWithContentLength(HttpMessage)public HttpDecoderConfig clone()
Copyright © 2008–2026 The Netty Project. All rights reserved.