GeezerVison is showing netty.io — HttpDecoderConfig (Netty API Reference (4.1.141.Final))
Class HttpDecoderConfig
-
Constructor Summary
Constructors
-
Method Summary
Modifier and Type
Method
Description
int
int
int
int
boolean
boolean
boolean
boolean
boolean
Set whether more than one Content-Length header is allowed.
Set whether chunks can be split into multiple messages, if their chunk size exceeds the size of the input buffer.
Set whether Transfer-Encoding: Chunked should be supported.
Set the initial size of the temporary buffer used when parsing the lines of the HTTP headers.
Set the maximum chunk size.
Set the maximum line length of header lines.
Set the maximum length of the first line of the HTTP header.
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.
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.
Set whether header validation should be enabled or not.
-
Constructor Details
-
HttpDecoderConfig
public HttpDecoderConfig()
-
Method Details
-
getInitialBufferSize
public int getInitialBufferSize()
-
setInitialBufferSize
Set the initial size of the temporary buffer used when parsing the lines of the HTTP headers.
- Parameters:
initialBufferSize - The buffer size in bytes.
- Returns:
- This decoder config.
-
getMaxInitialLineLength
public int getMaxInitialLineLength()
-
setMaxInitialLineLength
Set the maximum length of the first line of the HTTP header.
This limits how much memory Netty will use when parsed the initial HTTP header line.
You would typically set this to the same value as setMaxHeaderSize(int).
- Parameters:
maxInitialLineLength - The maximum length, in bytes.
- Returns:
- This decoder config.
-
getMaxHeaderSize
public int getMaxHeaderSize()
-
setMaxHeaderSize
Set the maximum line length of header lines.
This limits how much memory Netty will use when parsing HTTP header key-value pairs.
The limit applies to the sum of all the headers, so it applies equally to many short header-lines,
or fewer but longer header lines.
You would typically set this to the same value as setMaxInitialLineLength(int).
- Parameters:
maxHeaderSize - The maximum length, in bytes.
- Returns:
- This decoder config.
-
getMaxChunkSize
public int getMaxChunkSize()
-
setMaxChunkSize
Set the maximum chunk size.
HTTP requests and responses can be quite large, in which case it's better to process the data as a stream of
chunks.
This sets the limit, in bytes, at which Netty will send a chunk down the pipeline.
- Parameters:
maxChunkSize - The maximum chunk size, in bytes.
- Returns:
- This decoder config.
-
isChunkedSupported
public boolean isChunkedSupported()
-
setChunkedSupported
Set whether Transfer-Encoding: Chunked should be supported.
- Parameters:
chunkedSupported - if false, then a Transfer-Encoding: Chunked header will produce an error,
instead of a stream of chunks.
- Returns:
- This decoder config.
-
isAllowPartialChunks
public boolean isAllowPartialChunks()
-
setAllowPartialChunks
Set whether chunks can be split into multiple messages, if their chunk size exceeds the size of the input buffer.
- Parameters:
allowPartialChunks - set to false to only allow sending whole chunks down the pipeline.
- Returns:
- This decoder config.
-
-
setHeadersFactory
- Parameters:
headersFactory - The header factory to use.
- Returns:
- This decoder config.
-
isAllowDuplicateContentLengths
public boolean isAllowDuplicateContentLengths()
-
setAllowDuplicateContentLengths
public HttpDecoderConfig setAllowDuplicateContentLengths(boolean allowDuplicateContentLengths)
Set whether more than one 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.
- Parameters:
allowDuplicateContentLengths - set to true to allow multiple content length headers.
- Returns:
- This decoder config.
-
setValidateHeaders
Set whether header validation should be enabled or not.
This works by changing the configured header factory
and trailer factory.
You usually want header validation enabled (which is the default) in order to prevent request-/response-splitting
attacks.
- Parameters:
validateHeaders - set to false to disable header validation.
- Returns:
- This decoder config.
-
-
setTrailersFactory
- Parameters:
trailersFactory - The headers factory to use for creating trailers.
- Returns:
- This decoder config.
-
isStrictLineParsing
public boolean isStrictLineParsing()
-
setStrictLineParsing
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.
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 messages with failed
DecoderResults.
Additionally, Netty will enforce that only CR LF characters precede the initial line, if any.
When strict line parsing is disabled (false), then Netty will accept lone LF octets as line
separators for the start- and header field-lines.
Additionally, Netty will ignore any ISO control and line separator characters prior to the initial line.
See RFC 9112 Section 2.1 and
RFC 9112 Section 2.2.
- Parameters:
strictLineParsing - Whether strict line parsing should be enabled (true),
or not (false).
- Returns:
- This decoder config.
-
isUseRfc9112TransferEncoding
public boolean isUseRfc9112TransferEncoding()
-
setUseRfc9112TransferEncoding
public 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. 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.
- Parameters:
useRfc9112TransferEncoding - Whether to reject messages with both Transfer-Encoding and
Content-Length headers.
- Returns:
- This decoder config.
- See Also:
-
-
|