Class DefaultHttpHeadersFactory
- All Implemented Interfaces:
HttpHeadersFactory
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 headersFactory().
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate static final DefaultHttpHeadersFactoryprivate static final DefaultHttpHeadersFactoryprivate static final DefaultHeaders.NameValidator<java.lang.CharSequence> private static final DefaultHttpHeadersFactoryprivate static final DefaultHttpHeadersFactoryprivate static final DefaultHeaders.NameValidator<java.lang.CharSequence> private static final DefaultHeaders.ValueValidator<java.lang.CharSequence> private final DefaultHeaders.NameValidator<java.lang.CharSequence> private static final DefaultHeaders.NameValidator<java.lang.CharSequence> private static final DefaultHeaders.ValueValidator<java.lang.CharSequence> private final DefaultHeaders.ValueValidator<java.lang.CharSequence> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDefaultHttpHeadersFactory(DefaultHeaders.NameValidator<java.lang.CharSequence> nameValidator, DefaultHeaders.ValueValidator<java.lang.CharSequence> valueValidator, boolean combiningHeaders) Create a header builder with the given settings. -
Method Summary
Modifier and TypeMethodDescriptionDefaultHeaders.NameValidator<java.lang.CharSequence> Get the currently configuredDefaultHeaders.NameValidator.DefaultHeaders.ValueValidator<java.lang.CharSequence> Get the currently configuredDefaultHeaders.ValueValidator.static DefaultHttpHeadersFactoryGet the default implementation ofHttpHeadersFactoryfor creating headers.booleanCheck whether header combining is enabled or not.booleanCheck whether header name validation is enabled.booleanCheck whether header value validation is enabled.Create a newHttpHeadersinstance, but sized to be as small an object as possible.Create a newHttpHeadersinstance.static DefaultHttpHeadersFactoryGet the default implementation ofHttpHeadersFactoryfor creating trailers.withCombiningHeaders(boolean combiningHeaders) Create a new builder that will buildHttpHeadersobjects that either combine multi-valued headers, or not.withNameValidation(boolean validation) Create a new builder that has HTTP header name validation enabled or disabled.withNameValidator(DefaultHeaders.NameValidator<java.lang.CharSequence> validator) Create a new builder that with the givenDefaultHeaders.NameValidator.withValidation(boolean validation) Create a new builder that has HTTP header validation enabled or disabled.withValueValidation(boolean validation) Create a new builder that has HTTP header value validation enabled or disabled.withValueValidator(DefaultHeaders.ValueValidator<java.lang.CharSequence> validator) Create a new builder that with the givenDefaultHeaders.ValueValidator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
DEFAULT_NAME_VALIDATOR
-
DEFAULT_VALUE_VALIDATOR
-
DEFAULT_TRAILER_NAME_VALIDATOR
private static final DefaultHeaders.NameValidator<java.lang.CharSequence> DEFAULT_TRAILER_NAME_VALIDATOR -
NO_NAME_VALIDATOR
-
NO_VALUE_VALIDATOR
-
DEFAULT
-
DEFAULT_TRAILER
-
DEFAULT_COMBINING
-
DEFAULT_NO_VALIDATION
-
nameValidator
-
valueValidator
-
combiningHeaders
private final boolean combiningHeaders
-
-
Constructor Details
-
DefaultHttpHeadersFactory
private DefaultHttpHeadersFactory(DefaultHeaders.NameValidator<java.lang.CharSequence> nameValidator, DefaultHeaders.ValueValidator<java.lang.CharSequence> valueValidator, boolean combiningHeaders) Create a header builder with the given settings.- Parameters:
nameValidator- The name validator to use, not null.valueValidator- The value validator to use, not null.combiningHeaders-trueif multi-valued headers should be combined into single lines.
-
-
Method Details
-
headersFactory
Get the default implementation ofHttpHeadersFactoryfor creating headers.This
DefaultHttpHeadersFactorycreatesHttpHeadersinstances that has the recommended header validation enabled. -
trailersFactory
Get the default implementation ofHttpHeadersFactoryfor creating trailers.This
DefaultHttpHeadersFactorycreatesHttpHeadersinstances that has the validation enabled that is recommended for trailers. -
newHeaders
Description copied from interface:HttpHeadersFactoryCreate a newHttpHeadersinstance.- Specified by:
newHeadersin interfaceHttpHeadersFactory
-
newEmptyHeaders
Description copied from interface:HttpHeadersFactoryCreate a newHttpHeadersinstance, but sized to be as small an object as possible.- Specified by:
newEmptyHeadersin interfaceHttpHeadersFactory
-
withNameValidation
Create a new builder that has HTTP header name validation enabled or disabled.Warning! Setting
validationtofalsewill mean that Netty won't validate invalid input: '&' 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- If validation should be enabled or disabled.- Returns:
- The new builder.
-
withNameValidator
public DefaultHttpHeadersFactory withNameValidator(DefaultHeaders.NameValidator<java.lang.CharSequence> validator) Create a new builder that with the givenDefaultHeaders.NameValidator.Warning! If the given validator does not check that the header names are standards compliant, Netty won't validate invalid input: '&' 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- The HTTP header name validator to use.- Returns:
- The new builder.
-
withValueValidation
Create a new builder that has HTTP header value validation enabled or disabled.Warning! Setting
validationtofalsewill mean that Netty won't validate invalid input: '&' 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- If validation should be enabled or disabled.- Returns:
- The new builder.
-
withValueValidator
public DefaultHttpHeadersFactory withValueValidator(DefaultHeaders.ValueValidator<java.lang.CharSequence> validator) Create a new builder that with the givenDefaultHeaders.ValueValidator.Warning! If the given validator does not check that the header values are standards compliant, Netty won't validate invalid input: '&' 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- The HTTP header name validator to use.- Returns:
- The new builder.
-
withValidation
Create a new builder that has HTTP header validation enabled or disabled.Warning! Setting
validationtofalsewill mean that Netty won't validate invalid input: '&' 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- If validation should be enabled or disabled.- Returns:
- The new builder.
-
withCombiningHeaders
Create a new builder that will buildHttpHeadersobjects that either combine multi-valued headers, or not.- Parameters:
combiningHeaders-trueif multi-valued headers should be combined, otherwisefalse.- Returns:
- The new builder.
-
getNameValidator
Get the currently configuredDefaultHeaders.NameValidator.This method will be used by the
newHeaders()method.- Returns:
- The configured name validator.
-
getValueValidator
Get the currently configuredDefaultHeaders.ValueValidator.This method will be used by the
newHeaders()method.- Returns:
- The configured value validator.
-
isCombiningHeaders
public boolean isCombiningHeaders()Check whether header combining is enabled or not.- Returns:
trueif header value combining is enabled, otherwisefalse.
-
isValidatingHeaderNames
public boolean isValidatingHeaderNames()Check whether header name validation is enabled.- Returns:
trueif header name validation is enabled, otherwisefalse.
-
isValidatingHeaderValues
public boolean isValidatingHeaderValues()Check whether header value validation is enabled.- Returns:
trueif header value validation is enabled, otherwisefalse.
-