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

public final Class DefaultHttpHeadersFactory

extends Object
implements HttpHeadersFactory
Class Inheritance
All Implemented Interfaces
io.netty.handler.codec.http.HttpHeadersFactory
Imports
io.netty.handler.codec.DefaultHeaders.NameValidator, .DefaultHeaders.ValueValidator

A builder of HttpHeadersFactory instances, that itself implements HttpHeadersFactory. The builder is immutable, and every with- method produce a new, modified instance.

The default builder you most likely want to start with is DefaultHttpHeadersFactory#headersFactory().

Field Summary

Modifier and TypeField and Description
private final boolean
private static final DefaultHttpHeadersFactory
private static final DefaultHttpHeadersFactory
private static final DefaultHeaders.NameValidator<CharSequence>
private static final DefaultHttpHeadersFactory
private static final DefaultHttpHeadersFactory
private static final DefaultHeaders.NameValidator<CharSequence>
private static final DefaultHeaders.ValueValidator<CharSequence>
private final DefaultHeaders.NameValidator<CharSequence>
private static final DefaultHeaders.NameValidator<CharSequence>
private static final DefaultHeaders.ValueValidator<CharSequence>
private final DefaultHeaders.ValueValidator<CharSequence>

Constructor Summary

AccessConstructor and Description
private
DefaultHttpHeadersFactory(DefaultHeaders.NameValidator<CharSequence>
The name validator to use, not null.
nameValidator
,
DefaultHeaders.ValueValidator<CharSequence>
The value validator to use, not null.
valueValidator
,
boolean
true if multi-valued headers should be combined into single lines.
combiningHeaders
)

Create a header builder with the given settings.

Method Summary

Modifier and TypeMethod and Description
public DefaultHeaders.NameValidator<CharSequence>

Returns:

The configured name validator.
getNameValidator
()

Get the currently configured NameValidator.

public DefaultHeaders.ValueValidator<CharSequence>

Returns:

The configured value validator.
getValueValidator
()

Get the currently configured ValueValidator.

public static DefaultHttpHeadersFactory
headersFactory()

Get the default implementation of HttpHeadersFactory for creating headers.

public boolean

Returns:

true if header value combining is enabled, otherwise false.
isCombiningHeaders
()

Check whether header combining is enabled or not.

public boolean

Returns:

true if header name validation is enabled, otherwise false.
isValidatingHeaderNames
()

Check whether header name validation is enabled.

public boolean

Returns:

true if header value validation is enabled, otherwise false.
isValidatingHeaderValues
()

Check whether header value validation is enabled.

public HttpHeaders
newEmptyHeaders()

Implements io.netty.handler.codec.http.HttpHeadersFactory.newEmptyHeaders.

Create a new HttpHeaders instance, but sized to be as small an object as possible.
public HttpHeaders
public static DefaultHttpHeadersFactory
trailersFactory()

Get the default implementation of HttpHeadersFactory for creating trailers.

public DefaultHttpHeadersFactory

Returns:

The new builder.
withCombiningHeaders
(boolean
true if multi-valued headers should be combined, otherwise false.
combiningHeaders
)

Create a new builder that will build HttpHeaders objects that either combine multi-valued headers, or not.

public DefaultHttpHeadersFactory

Returns:

The new builder.
withNameValidation
(boolean
If validation should be enabled or disabled.
validation
)

Create a new builder that has HTTP header name validation enabled or disabled.

public DefaultHttpHeadersFactory

Returns:

The new builder.
withNameValidator
(DefaultHeaders.NameValidator<CharSequence>
The HTTP header name validator to use.
validator
)

Create a new builder that with the given NameValidator.

public DefaultHttpHeadersFactory

Returns:

The new builder.
withValidation
(boolean
If validation should be enabled or disabled.
validation
)

Create a new builder that has HTTP header validation enabled or disabled.

public DefaultHttpHeadersFactory

Returns:

The new builder.
withValueValidation
(boolean
If validation should be enabled or disabled.
validation
)

Create a new builder that has HTTP header value validation enabled or disabled.

public DefaultHttpHeadersFactory

Returns:

The new builder.
withValueValidator
(DefaultHeaders.ValueValidator<CharSequence>
The HTTP header name validator to use.
validator
)

Create a new builder that with the given ValueValidator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

combiningHeadersback to summary
private final boolean combiningHeaders
DEFAULTback to summary
private static final DefaultHttpHeadersFactory DEFAULT
DEFAULT_COMBININGback to summary
private static final DefaultHttpHeadersFactory DEFAULT_COMBINING
DEFAULT_NAME_VALIDATORback to summary
private static final DefaultHeaders.NameValidator<CharSequence> DEFAULT_NAME_VALIDATOR
DEFAULT_NO_VALIDATIONback to summary
private static final DefaultHttpHeadersFactory DEFAULT_NO_VALIDATION
DEFAULT_TRAILERback to summary
private static final DefaultHttpHeadersFactory DEFAULT_TRAILER
DEFAULT_TRAILER_NAME_VALIDATORback to summary
private static final DefaultHeaders.NameValidator<CharSequence> DEFAULT_TRAILER_NAME_VALIDATOR
DEFAULT_VALUE_VALIDATORback to summary
private static final DefaultHeaders.ValueValidator<CharSequence> DEFAULT_VALUE_VALIDATOR
nameValidatorback to summary
private final DefaultHeaders.NameValidator<CharSequence> nameValidator
NO_NAME_VALIDATORback to summary
private static final DefaultHeaders.NameValidator<CharSequence> NO_NAME_VALIDATOR
Annotations
@SuppressWarnings:unchecked
NO_VALUE_VALIDATORback to summary
private static final DefaultHeaders.ValueValidator<CharSequence> NO_VALUE_VALIDATOR
Annotations
@SuppressWarnings:unchecked
valueValidatorback to summary
private final DefaultHeaders.ValueValidator<CharSequence> valueValidator

Constructor Detail

DefaultHttpHeadersFactoryback to summary
private DefaultHttpHeadersFactory(DefaultHeaders.NameValidator<CharSequence> nameValidator, DefaultHeaders.ValueValidator<CharSequence> valueValidator, boolean combiningHeaders)

Create a header builder with the given settings.

Parameters
nameValidator:DefaultHeaders.NameValidator<CharSequence>

The name validator to use, not null.

valueValidator:DefaultHeaders.ValueValidator<CharSequence>

The value validator to use, not null.

combiningHeaders:boolean

true if multi-valued headers should be combined into single lines.

Method Detail

getNameValidatorback to summary
public DefaultHeaders.NameValidator<CharSequence> getNameValidator()

Get the currently configured NameValidator.

This method will be used by the newHeaders() method.

Returns:DefaultHeaders.NameValidator<CharSequence>

The configured name validator.

getValueValidatorback to summary
public DefaultHeaders.ValueValidator<CharSequence> getValueValidator()

Get the currently configured ValueValidator.

This method will be used by the newHeaders() method.

Returns:DefaultHeaders.ValueValidator<CharSequence>

The configured value validator.

headersFactoryback to summary
public static DefaultHttpHeadersFactory headersFactory()

Get the default implementation of HttpHeadersFactory for creating headers.

This DefaultHttpHeadersFactory creates HttpHeaders instances that has the recommended header validation enabled.

isCombiningHeadersback to summary
public boolean isCombiningHeaders()

Check whether header combining is enabled or not.

Returns:boolean

true if header value combining is enabled, otherwise false.

isValidatingHeaderNamesback to summary
public boolean isValidatingHeaderNames()

Check whether header name validation is enabled.

Returns:boolean

true if header name validation is enabled, otherwise false.

isValidatingHeaderValuesback to summary
public boolean isValidatingHeaderValues()

Check whether header value validation is enabled.

Returns:boolean

true if header value validation is enabled, otherwise false.

newEmptyHeadersback to summary
public HttpHeaders newEmptyHeaders()

Implements io.netty.handler.codec.http.HttpHeadersFactory.newEmptyHeaders.

Doc from io.netty.handler.codec.http.HttpHeadersFactory.newEmptyHeaders.

Create a new HttpHeaders instance, but sized to be as small an object as possible.

Annotations
@Override
newHeadersback to summary
public HttpHeaders newHeaders()

Implements io.netty.handler.codec.http.HttpHeadersFactory.newHeaders.

Doc from io.netty.handler.codec.http.HttpHeadersFactory.newHeaders.

Create a new HttpHeaders instance.

Annotations
@Override
trailersFactoryback to summary
public static DefaultHttpHeadersFactory trailersFactory()

Get the default implementation of HttpHeadersFactory for creating trailers.

This DefaultHttpHeadersFactory creates HttpHeaders instances that has the validation enabled that is recommended for trailers.

withCombiningHeadersback to summary
public DefaultHttpHeadersFactory withCombiningHeaders(boolean combiningHeaders)

Create a new builder that will build HttpHeaders objects that either combine multi-valued headers, or not.

Parameters
combiningHeaders:boolean

true if multi-valued headers should be combined, otherwise false.

Returns:DefaultHttpHeadersFactory

The new builder.

withNameValidationback to summary
public DefaultHttpHeadersFactory withNameValidation(boolean validation)

Create a new builder that has HTTP header name validation enabled or disabled.

Warning

Setting validation to false will mean that Netty won't validate & protect against user-supplied headers that are malicious. This can leave your server implementation vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') . When disabling this validation, it is the responsibility of the caller to ensure that the values supplied do not contain a non-url-escaped carriage return (CR) and/or line feed (LF) characters.

Parameters
validation:boolean

If validation should be enabled or disabled.

Returns:DefaultHttpHeadersFactory

The new builder.

withNameValidatorback to summary
public DefaultHttpHeadersFactory withNameValidator(DefaultHeaders.NameValidator<CharSequence> validator)

Create a new builder that with the given NameValidator.

Warning

If the given validator does not check that the header names are standards compliant, Netty won't validate & protect against user-supplied headers that are malicious. This can leave your server implementation vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') . When disabling this validation, it is the responsibility of the caller to ensure that the values supplied do not contain a non-url-escaped carriage return (CR) and/or line feed (LF) characters.

Parameters
validator:DefaultHeaders.NameValidator<CharSequence>

The HTTP header name validator to use.

Returns:DefaultHttpHeadersFactory

The new builder.

withValidationback to summary
public DefaultHttpHeadersFactory withValidation(boolean validation)

Create a new builder that has HTTP header validation enabled or disabled.

Warning

Setting validation to false will mean that Netty won't validate & protect against user-supplied headers that are malicious. This can leave your server implementation vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') . When disabling this validation, it is the responsibility of the caller to ensure that the values supplied do not contain a non-url-escaped carriage return (CR) and/or line feed (LF) characters.

Parameters
validation:boolean

If validation should be enabled or disabled.

Returns:DefaultHttpHeadersFactory

The new builder.

withValueValidationback to summary
public DefaultHttpHeadersFactory withValueValidation(boolean validation)

Create a new builder that has HTTP header value validation enabled or disabled.

Warning

Setting validation to false will mean that Netty won't validate & protect against user-supplied headers that are malicious. This can leave your server implementation vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') . When disabling this validation, it is the responsibility of the caller to ensure that the values supplied do not contain a non-url-escaped carriage return (CR) and/or line feed (LF) characters.

Parameters
validation:boolean

If validation should be enabled or disabled.

Returns:DefaultHttpHeadersFactory

The new builder.

withValueValidatorback to summary
public DefaultHttpHeadersFactory withValueValidator(DefaultHeaders.ValueValidator<CharSequence> validator)

Create a new builder that with the given ValueValidator.

Warning

If the given validator does not check that the header values are standards compliant, Netty won't validate & protect against user-supplied headers that are malicious. This can leave your server implementation vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') . When disabling this validation, it is the responsibility of the caller to ensure that the values supplied do not contain a non-url-escaped carriage return (CR) and/or line feed (LF) characters.

Parameters
validator:DefaultHeaders.ValueValidator<CharSequence>

The HTTP header name validator to use.

Returns:DefaultHttpHeadersFactory

The new builder.