Top Description Fields Constructors Methods
io.netty.handler.codec.http

public final Class HttpDecoderConfig

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Static Imports
io.netty.util.internal.ObjectUtil.checkNotNull, .ObjectUtil.checkPositive

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

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private HttpHeadersFactory
private int
private int
private int
private int
private HttpHeadersFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public HttpDecoderConfig
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public HttpHeadersFactory
public int
public int
public int
public int
public HttpHeadersFactory
public boolean
public boolean
public boolean
public HttpDecoderConfig

Returns:

This decoder config.
setAllowDuplicateContentLengths
(boolean
set to true to allow multiple content length headers.
allowDuplicateContentLengths
)

Set whether more than one Content-Length header is allowed.

public HttpDecoderConfig

Returns:

This decoder config.
setAllowPartialChunks
(boolean
set to false to only allow sending whole chunks down the pipeline.
allowPartialChunks
)

Set whether chunks can be split into multiple messages, if their chunk size exceeds the size of the input buffer.

public HttpDecoderConfig

Returns:

This decoder config.
setChunkedSupported
(boolean
if false, then a Transfer-Encoding: Chunked header will produce an error, instead of a stream of chunks.
chunkedSupported
)

Set whether Transfer-Encoding: Chunked should be supported.

public HttpDecoderConfig

Returns:

This decoder config.
setHeadersFactory
(HttpHeadersFactory
The header factory to use.
headersFactory
)

Set the HttpHeadersFactory to use when creating new HTTP headers objects.

public HttpDecoderConfig

Returns:

This decoder config.
setInitialBufferSize
(int
The buffer size in bytes.
initialBufferSize
)

Set the initial size of the temporary buffer used when parsing the lines of the HTTP headers.

public HttpDecoderConfig

Returns:

This decoder config.
setMaxChunkSize
(int
The maximum chunk size, in bytes.
maxChunkSize
)

Set the maximum chunk size.

public HttpDecoderConfig

Returns:

This decoder config.
setMaxHeaderSize
(int
The maximum length, in bytes.
maxHeaderSize
)

Set the maximum line length of header lines.

public HttpDecoderConfig

Returns:

This decoder config.
setMaxInitialLineLength
(int
The maximum length, in bytes.
maxInitialLineLength
)

Set the maximum length of the first line of the HTTP header.

public HttpDecoderConfig

Returns:

This decoder config.
setTrailersFactory
(HttpHeadersFactory
The headers factory to use for creating trailers.
trailersFactory
)

Set the HttpHeadersFactory used to create HTTP trailers.

public HttpDecoderConfig

Returns:

This decoder config.
setValidateHeaders
(boolean
set to false to disable header validation.
validateHeaders
)

Set whether header validation should be enabled or not.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowDuplicateContentLengthsback to summary
private boolean allowDuplicateContentLengths
allowPartialChunksback to summary
private boolean allowPartialChunks
chunkedSupportedback to summary
private boolean chunkedSupported
headersFactoryback to summary
private HttpHeadersFactory headersFactory
initialBufferSizeback to summary
private int initialBufferSize
maxChunkSizeback to summary
private int maxChunkSize
maxHeaderSizeback to summary
private int maxHeaderSize
maxInitialLineLengthback to summary
private int maxInitialLineLength
trailersFactoryback to summary
private HttpHeadersFactory trailersFactory

Constructor Detail

HttpDecoderConfigback to summary
public HttpDecoderConfig()

Method Detail

cloneback to summary
public HttpDecoderConfig clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:HttpDecoderConfig

a clone of this instance.

Annotations
@Override
getHeadersFactoryback to summary
public HttpHeadersFactory getHeadersFactory()
getInitialBufferSizeback to summary
public int getInitialBufferSize()
getMaxChunkSizeback to summary
public int getMaxChunkSize()
getMaxHeaderSizeback to summary
public int getMaxHeaderSize()
getMaxInitialLineLengthback to summary
public int getMaxInitialLineLength()
getTrailersFactoryback to summary
public HttpHeadersFactory getTrailersFactory()
isAllowDuplicateContentLengthsback to summary
public boolean isAllowDuplicateContentLengths()
isAllowPartialChunksback to summary
public boolean isAllowPartialChunks()
isChunkedSupportedback to summary
public boolean isChunkedSupported()
setAllowDuplicateContentLengthsback to summary
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:boolean

set to true to allow multiple content length headers.

Returns:HttpDecoderConfig

This decoder config.

setAllowPartialChunksback to summary
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:boolean

set to false to only allow sending whole chunks down the pipeline.

Returns:HttpDecoderConfig

This decoder config.

setChunkedSupportedback to summary
public HttpDecoderConfig setChunkedSupported(boolean chunkedSupported)

Set whether Transfer-Encoding: Chunked should be supported.

Parameters
chunkedSupported:boolean

if false, then a Transfer-Encoding: Chunked header will produce an error, instead of a stream of chunks.

Returns:HttpDecoderConfig

This decoder config.

setHeadersFactoryback to summary
public HttpDecoderConfig setHeadersFactory(HttpHeadersFactory headersFactory)

Set the 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.

Parameters
headersFactory:HttpHeadersFactory

The header factory to use.

Returns:HttpDecoderConfig

This decoder config.

setInitialBufferSizeback to summary
public HttpDecoderConfig setInitialBufferSize(int initialBufferSize)

Set the initial size of the temporary buffer used when parsing the lines of the HTTP headers.

Parameters
initialBufferSize:int

The buffer size in bytes.

Returns:HttpDecoderConfig

This decoder config.

setMaxChunkSizeback to summary
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:int

The maximum chunk size, in bytes.

Returns:HttpDecoderConfig

This decoder config.

setMaxHeaderSizeback to summary
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. You would typically set this to the same value as setMaxInitialLineLength(int).

Parameters
maxHeaderSize:int

The maximum length, in bytes.

Returns:HttpDecoderConfig

This decoder config.

setMaxInitialLineLengthback to summary
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 as setMaxHeaderSize(int).

Parameters
maxInitialLineLength:int

The maximum length, in bytes.

Returns:HttpDecoderConfig

This decoder config.

setTrailersFactoryback to summary
public HttpDecoderConfig setTrailersFactory(HttpHeadersFactory trailersFactory)

Set the 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.

Parameters
trailersFactory:HttpHeadersFactory

The headers factory to use for creating trailers.

Returns:HttpDecoderConfig

This decoder config.

setValidateHeadersback to summary
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:boolean

set to false to disable header validation.

Returns:HttpDecoderConfig

This decoder config.