Package io.netty.handler.codec.http
Class HttpDecoderConfig
- java.lang.Object
-
- io.netty.handler.codec.http.HttpDecoderConfig
-
- All Implemented Interfaces:
java.lang.Cloneable
public final class HttpDecoderConfig extends java.lang.Object implements java.lang.Cloneable
A configuration object for specifying the behaviour ofHttpObjectDecoder
and its subclasses.The
HttpDecoderConfig
objects are mutable to reduce allocation, but alsoCloneable
in case a defensive copy is needed.
-
-
Constructor Summary
Constructors Constructor Description HttpDecoderConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpDecoderConfig
clone()
HttpHeadersFactory
getHeadersFactory()
int
getInitialBufferSize()
int
getMaxChunkSize()
int
getMaxHeaderSize()
int
getMaxInitialLineLength()
HttpHeadersFactory
getTrailersFactory()
boolean
isAllowDuplicateContentLengths()
boolean
isAllowPartialChunks()
boolean
isChunkedSupported()
HttpDecoderConfig
setAllowDuplicateContentLengths(boolean allowDuplicateContentLengths)
Set whether more than oneContent-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 whetherTransfer-Encoding: Chunked
should be supported.HttpDecoderConfig
setHeadersFactory(HttpHeadersFactory headersFactory)
Set theHttpHeadersFactory
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
setTrailersFactory(HttpHeadersFactory trailersFactory)
Set theHttpHeadersFactory
used to create HTTP trailers.HttpDecoderConfig
setValidateHeaders(boolean validateHeaders)
Set whether header validation should be enabled or not.
-
-
-
Method Detail
-
getInitialBufferSize
public int getInitialBufferSize()
-
setInitialBufferSize
public HttpDecoderConfig setInitialBufferSize(int initialBufferSize)
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
public HttpDecoderConfig setMaxInitialLineLength(int maxInitialLineLength)
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
public HttpDecoderConfig setMaxHeaderSize(int maxHeaderSize)
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
public HttpDecoderConfig setMaxChunkSize(int maxChunkSize)
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
public HttpDecoderConfig setChunkedSupported(boolean chunkedSupported)
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
public HttpDecoderConfig setAllowPartialChunks(boolean allowPartialChunks)
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
public HttpHeadersFactory getHeadersFactory()
-
setHeadersFactory
public HttpDecoderConfig setHeadersFactory(HttpHeadersFactory headersFactory)
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
public HttpDecoderConfig setAllowDuplicateContentLengths(boolean allowDuplicateContentLengths)
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
public HttpDecoderConfig setValidateHeaders(boolean validateHeaders)
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
public HttpHeadersFactory getTrailersFactory()
-
setTrailersFactory
public HttpDecoderConfig setTrailersFactory(HttpHeadersFactory trailersFactory)
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
public HttpDecoderConfig clone()
- Overrides:
clone
in classjava.lang.Object
-
-