Package io.netty.handler.codec.http
Class HttpDecoderConfig
java.lang.Object
io.netty.handler.codec.http.HttpDecoderConfig
- All Implemented Interfaces:
Cloneable
A configuration object for specifying the behaviour of
HttpObjectDecoder
and its subclasses.
The HttpDecoderConfig
objects are mutable to reduce allocation,
but also Cloneable
in case a defensive copy is needed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private boolean
private HttpHeadersFactory
private int
private int
private int
private int
private HttpHeadersFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
int
int
int
int
boolean
boolean
boolean
setAllowDuplicateContentLengths
(boolean allowDuplicateContentLengths) Set whether more than oneContent-Length
header is allowed.setAllowPartialChunks
(boolean allowPartialChunks) Set whether chunks can be split into multiple messages, if their chunk size exceeds the size of the input buffer.setChunkedSupported
(boolean chunkedSupported) Set whetherTransfer-Encoding: Chunked
should be supported.setHeadersFactory
(HttpHeadersFactory headersFactory) Set theHttpHeadersFactory
to use when creating new HTTP headers objects.setInitialBufferSize
(int initialBufferSize) Set the initial size of the temporary buffer used when parsing the lines of the HTTP headers.setMaxChunkSize
(int maxChunkSize) Set the maximum chunk size.setMaxHeaderSize
(int maxHeaderSize) Set the maximum line length of header lines.setMaxInitialLineLength
(int maxInitialLineLength) Set the maximum length of the first line of the HTTP header.setTrailersFactory
(HttpHeadersFactory trailersFactory) Set theHttpHeadersFactory
used to create HTTP trailers.setValidateHeaders
(boolean validateHeaders) Set whether header validation should be enabled or not.
-
Field Details
-
maxChunkSize
private int maxChunkSize -
chunkedSupported
private boolean chunkedSupported -
allowPartialChunks
private boolean allowPartialChunks -
headersFactory
-
trailersFactory
-
allowDuplicateContentLengths
private boolean allowDuplicateContentLengths -
maxInitialLineLength
private int maxInitialLineLength -
maxHeaderSize
private int maxHeaderSize -
initialBufferSize
private int initialBufferSize
-
-
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 assetMaxHeaderSize(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 whetherTransfer-Encoding: Chunked
should be supported.- Parameters:
chunkedSupported
- iffalse
, then aTransfer-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 tofalse
to only allow sending whole chunks down the pipeline.- Returns:
- This decoder config.
-
getHeadersFactory
-
setHeadersFactory
Set theHttpHeadersFactory
to use when creating new HTTP headers objects. The default headers factory isDefaultHttpHeadersFactory.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.- Parameters:
headersFactory
- The header factory to use.- Returns:
- This decoder config.
-
isAllowDuplicateContentLengths
public boolean isAllowDuplicateContentLengths() -
setAllowDuplicateContentLengths
Set whether more than oneContent-Length
header is allowed. You usually want to disallow this (which is the default) as multipleContent-Length
headers can indicate a request- or response-splitting attack.- Parameters:
allowDuplicateContentLengths
- set totrue
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 tofalse
to disable header validation.- Returns:
- This decoder config.
-
getTrailersFactory
-
setTrailersFactory
Set theHttpHeadersFactory
used to create HTTP trailers. This differs fromsetHeadersFactory(HttpHeadersFactory)
in that trailers have different validation requirements. The default trailer factory isDefaultHttpHeadersFactory.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.- Parameters:
trailersFactory
- The headers factory to use for creating trailers.- Returns:
- This decoder config.
-
clone
-