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

public final Class HttpHeaderValidationUtil

extends Object
Class Inheritance
Annotations
@UnstableApi
Imports
io.netty.util.AsciiString, io.netty.util.internal.UnstableApi

Functions used to perform various validations of HTTP header names and values.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final long
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the given header name is one of the specified connection-related headers.
isConnectionHeader
(CharSequence
the name of the header to check. The check is case-insensitive.
name
,
boolean
true if the TE header should be ignored by this check. This is relevant for HTTP/2 header validation, where the TE header has special rules.
ignoreTeHeader
)

Check if a header name is "connection related".

public static boolean

Returns:

true only if the header name is TE, and the header value is not TRAILERS. Otherwise, false.
isTeNotTrailers
(CharSequence
the header name to check if it is TE or not.
name
,
CharSequence
the header value to check if it is something other than TRAILERS.
value
)

If the given header is HttpHeaderNames#TE and the given header value is not HttpHeaderValues#TRAILERS, then return true.

private static int
validateAsciiStringToken(AsciiString
the ascii string to validate.
token
)

Validate that an AsciiString contain onlu valid token characters.

private static int
validateCharSequenceToken(CharSequence
the character sequence to validate.
token
)

Validate that a CharSequence contain onlu valid token characters.

public static int

Returns:

the index of the first invalid token character found, or -1 if there are none.
validateToken
(CharSequence
the token to validate.
token
)

Validate a token contains only allowed characters.

public static int

Returns:

the index of the first illegal character found, or -1 if there are none and the header value is valid.
validateValidHeaderValue
(CharSequence
the HTTP header value to validate.
value
)

Validate the given HTTP header value by searching for any illegal characters.

private static int
private static int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

TOKEN_CHARS_HIGHback to summary
private static final long TOKEN_CHARS_HIGH
TOKEN_CHARS_LOWback to summary
private static final long TOKEN_CHARS_LOW

Constructor Detail

HttpHeaderValidationUtilback to summary
private HttpHeaderValidationUtil()

Method Detail

isConnectionHeaderback to summary
public static boolean isConnectionHeader(CharSequence name, boolean ignoreTeHeader)

Check if a header name is "connection related".

The RFC9110 only specify an incomplete list of the following headers:

  • Connection
  • Proxy-Connection
  • Keep-Alive
  • TE
  • Transfer-Encoding
  • Upgrade
Parameters
name:CharSequence

the name of the header to check. The check is case-insensitive.

ignoreTeHeader:boolean

true if the TE header should be ignored by this check. This is relevant for HTTP/2 header validation, where the TE header has special rules.

Returns:boolean

true if the given header name is one of the specified connection-related headers.

Annotations
@SuppressWarnings:deprecation
isTeNotTrailersback to summary
public static boolean isTeNotTrailers(CharSequence name, CharSequence value)

If the given header is HttpHeaderNames#TE and the given header value is not HttpHeaderValues#TRAILERS, then return true. Otherwie, false.

The string comparisons are case-insensitive.

This check is important for HTTP/2 header validation.

Parameters
name:CharSequence

the header name to check if it is TE or not.

value:CharSequence

the header value to check if it is something other than TRAILERS.

Returns:boolean

true only if the header name is TE, and the header value is not TRAILERS. Otherwise, false.

validateAsciiStringTokenback to summary
private static int validateAsciiStringToken(AsciiString token)

Validate that an AsciiString contain onlu valid token characters.

Parameters
token:AsciiString

the ascii string to validate.

validateCharSequenceTokenback to summary
private static int validateCharSequenceToken(CharSequence token)

Validate that a CharSequence contain onlu valid token characters.

Parameters
token:CharSequence

the character sequence to validate.

validateTokenback to summary
public static int validateToken(CharSequence token)

Validate a token contains only allowed characters.

The token format is used for variety of HTTP components, like cookie-name, field-name of a header-field, or request method.

Parameters
token:CharSequence

the token to validate.

Returns:int

the index of the first invalid token character found, or -1 if there are none.

validateValidHeaderValueback to summary
public static int validateValidHeaderValue(CharSequence value)

Validate the given HTTP header value by searching for any illegal characters.

Parameters
value:CharSequence

the HTTP header value to validate.

Returns:int

the index of the first illegal character found, or -1 if there are none and the header value is valid.

verifyValidHeaderValueAsciiStringback to summary
private static int verifyValidHeaderValueAsciiString(AsciiString value)
verifyValidHeaderValueCharSequenceback to summary
private static int verifyValidHeaderValueCharSequence(CharSequence value)
io.netty.handler.codec.http back to summary

private final Class HttpHeaderValidationUtil.BitSet128

extends Object
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http.HttpHeaderValidationUtil.BitSet128

Field Summary

Modifier and TypeField and Description
private long
private long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv HttpHeaderValidationUtil.BitSet128
bits(char... bits)

pack-priv static boolean
contains(byte bit, long high, long low)

pack-priv long
high()

pack-priv long
low()

pack-priv HttpHeaderValidationUtil.BitSet128
range(char fromInc, char toInc)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

highback to summary
private long high
lowback to summary
private long low

Constructor Detail

BitSet128back to summary
private BitSet128()

Method Detail

bitsback to summary
pack-priv HttpHeaderValidationUtil.BitSet128 bits(char... bits)
containsback to summary
pack-priv static boolean contains(byte bit, long high, long low)
highback to summary
pack-priv long high()
lowback to summary
pack-priv long low()
rangeback to summary
pack-priv HttpHeaderValidationUtil.BitSet128 range(char fromInc, char toInc)