Top Description Inners Fields Constructors Methods
io.netty5.handler.codec.http.headers

public final Class HeaderUtils

extends Object
Class Inheritance
Imports
io.netty5.handler.codec.http.HttpHeaderNames, .HttpHeaderValues, io.netty5.util.AsciiString, org.jetbrains.annotations.Nullable, java.util.Iterator, .Map, .NoSuchElementException, java.util.function.BiFunction

Utilities to use for HttpHeaders implementations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
HeaderUtils.AbstractCookiesByNameIterator

An Iterator of HttpCookiePair designed to iterate across multiple values of HttpHeaderNames#COOKIE for a specific cookie-name.

public abstract static class
HeaderUtils.AbstractCookiesIterator

An Iterator of HttpCookiePair designed to iterate across multiple values of HttpHeaderNames#COOKIE.

Field Summary

Modifier and TypeField and Description
public static final BiFunction<? super CharSequence, ? super CharSequence, CharSequence>
pack-priv static final int
HASH_CODE_SEED

Constant used to seed the hash code generation.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean
private static boolean

Returns:

true if the value is found, false otherwise.
containsCommaSeparatedValueIgnoreCase
(final CharSequence
the comma separated values.
commaSeparatedValues
,
final CharSequence
the value to look for.
needle
)

Returns true if commaSeparatedValues is comma separated and one of the values (or the whole string) matches needle case insensitively.

public static boolean

Returns:

true if there is a match.
domainMatches
(final CharSequence
The domain from the request.
requestDomain
,
final @Nullable CharSequence
The domain from the cookie.
cookieDomain
)

Domain Matching.

public static boolean

Returns:

true if a set-cookie-string's cookie-name matches setCookieName.
isSetCookieNameMatches
(final CharSequence setCookieString, final CharSequence setCookieName)

Determine if a set-cookie-string's cookie-name matches setCookieName.

public static boolean

Returns:

true if headers indicates transfer-encoding chunked, false otherwise.
isTransferEncodingChunked
(final HttpHeaders
The HttpHeaders to check.
headers
)

Returns true if headers indicates transfer-encoding chunked.

private static int
nextCookieDelimiter(CharSequence cookieHeaderValue, int startIndex)

private static int
nextCookieDelimiter(AsciiString cookieHeaderValue, int startIndex)

public static @Nullable HttpCookiePair

Returns:

parseCookiePair
(final CharSequence
The cookie-string that may contain multiple cookie-pairs.
cookieString
,
final CharSequence
The cookie-name identifying the cookie-pairs to parse.
cookiePairName
)

Parse a single cookie-pair from a cookie-string.

public static @Nullable HttpSetCookie

Returns:

a HttpSetCookie from a set-cookie-string.
parseSetCookie
(final CharSequence setCookieString, final CharSequence setCookieName, final boolean
true to attempt extra validation.
validate
)

Parse a HttpSetCookie from a set-cookie-string.

public static boolean

Returns:

true if there is a match.
pathMatches
(final CharSequence
The path from the request.
requestPath
,
final @Nullable CharSequence
The path from the cookie.
cookiePath
)

Path Matching.

public static @Nullable CharSequence

Returns:

removeCookiePairs
(final CharSequence
The cookie-string that may contain multiple cookie-pairs.
cookieString
,
final CharSequence
The cookie-name identifying the cookie-pairs to remove.
cookiePairName
)

Remove a single cookie-pair for a cookie-string.

pack-priv static String
toString(final HttpHeaders headers, final BiFunction<? super CharSequence, ? super CharSequence, CharSequence> filter)

pack-priv static void
validateCookieNameAndValue(final CharSequence cookieName, final CharSequence cookieValue)

pack-priv static void
pack-priv static void
validateToken(final CharSequence
the token to validate.
token
)

Validate a token contains only allowed characters.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_HEADER_FILTERback to summary
public static final BiFunction<? super CharSequence, ? super CharSequence, CharSequence> DEFAULT_HEADER_FILTER
HASH_CODE_SEEDback to summary
pack-priv static final int HASH_CODE_SEED

Constant used to seed the hash code generation. Could be anything but this was borrowed from murmur3.

Constructor Detail

HeaderUtilsback to summary
private HeaderUtils()

Method Detail

containsCommaSeparatedValueIgnoreCaseback to summary
pack-priv static boolean containsCommaSeparatedValueIgnoreCase(final HttpHeaders headers, final CharSequence name, final CharSequence value)
containsCommaSeparatedValueIgnoreCaseback to summary
private static boolean containsCommaSeparatedValueIgnoreCase(final CharSequence commaSeparatedValues, final CharSequence needle)

Returns true if commaSeparatedValues is comma separated and one of the values (or the whole string) matches needle case insensitively.

Parameters
commaSeparatedValues:CharSequence

the comma separated values.

needle:CharSequence

the value to look for.

Returns:boolean

true if the value is found, false otherwise.

domainMatchesback to summary
public static boolean domainMatches(final CharSequence requestDomain, final @Nullable CharSequence cookieDomain)

Domain Matching.

Parameters
requestDomain:CharSequence

The domain from the request.

cookieDomain:@Nullable CharSequence

The domain from the cookie.

Returns:boolean

true if there is a match.

isSetCookieNameMatchesback to summary
public static boolean isSetCookieNameMatches(final CharSequence setCookieString, final CharSequence setCookieName)

Determine if a set-cookie-string's cookie-name matches setCookieName.

Parameters
setCookieString:CharSequence

The set-cookie-string.

setCookieName:CharSequence

The cookie-name.

Returns:boolean

true if a set-cookie-string's cookie-name matches setCookieName.

isTransferEncodingChunkedback to summary
public static boolean isTransferEncodingChunked(final HttpHeaders headers)

Returns true if headers indicates transfer-encoding chunked.

The values of all HttpHeaderNames#TRANSFER_ENCODING headers are interpreted as comma-separated values, with spaces between values trimmed. If any of these values is HttpHeaderValues#CHUNKED, this method return true, otherwise it returns false.

Parameters
headers:HttpHeaders

The HttpHeaders to check.

Returns:boolean

true if headers indicates transfer-encoding chunked, false otherwise.

nextCookieDelimiterback to summary
private static int nextCookieDelimiter(CharSequence cookieHeaderValue, int startIndex)
nextCookieDelimiterback to summary
private static int nextCookieDelimiter(AsciiString cookieHeaderValue, int startIndex)
parseCookiePairback to summary
public static @Nullable HttpCookiePair parseCookiePair(final CharSequence cookieString, final CharSequence cookiePairName)

Parse a single cookie-pair from a cookie-string.

Parameters
cookieString:CharSequence

The cookie-string that may contain multiple cookie-pairs.

cookiePairName:CharSequence

The cookie-name identifying the cookie-pairs to parse.

Returns:@Nullable HttpCookiePair

Annotations
@Nullable
parseSetCookieback to summary
public static @Nullable HttpSetCookie parseSetCookie(final CharSequence setCookieString, final CharSequence setCookieName, final boolean validate)

Parse a HttpSetCookie from a set-cookie-string.

Parameters
setCookieString:CharSequence

The set-cookie-string.

setCookieName:CharSequence

The cookie-name.

validate:boolean

true to attempt extra validation.

Returns:@Nullable HttpSetCookie

a HttpSetCookie from a set-cookie-string.

Annotations
@Nullable
pathMatchesback to summary
public static boolean pathMatches(final CharSequence requestPath, final @Nullable CharSequence cookiePath)

Path Matching.

Parameters
requestPath:CharSequence

The path from the request.

cookiePath:@Nullable CharSequence

The path from the cookie.

Returns:boolean

true if there is a match.

removeCookiePairsback to summary
public static @Nullable CharSequence removeCookiePairs(final CharSequence cookieString, final CharSequence cookiePairName)

Remove a single cookie-pair for a cookie-string.

Parameters
cookieString:CharSequence

The cookie-string that may contain multiple cookie-pairs.

cookiePairName:CharSequence

The cookie-name identifying the cookie-pairs to remove.

Returns:@Nullable CharSequence

Annotations
@Nullable
toStringback to summary
pack-priv static String toString(final HttpHeaders headers, final BiFunction<? super CharSequence, ? super CharSequence, CharSequence> filter)
validateCookieNameAndValueback to summary
pack-priv static void validateCookieNameAndValue(final CharSequence cookieName, final CharSequence cookieValue)
validateHeaderValueback to summary
pack-priv static void validateHeaderValue(final CharSequence value)
validateTokenback to summary
pack-priv static void validateToken(final 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.

io.netty5.handler.codec.http.headers back to summary

public abstract Class HeaderUtils.AbstractCookiesByNameIterator

extends Object
implements Iterator<HttpCookiePair>
Class Inheritance
  • java.lang.Object
  • io.netty5.handler.codec.http.headers.HeaderUtils.AbstractCookiesByNameIterator
All Implemented Interfaces
java.util.Iterator
Known Direct Subclasses
io.netty5.handler.codec.http.headers.DefaultHttpHeaders.CookiesByNameIterator

An Iterator of HttpCookiePair designed to iterate across multiple values of HttpHeaderNames#COOKIE for a specific cookie-name.

Field Summary

Modifier and TypeField and Description
private final CharSequence
private @Nullable HttpCookiePair
private int

Constructor Summary

AccessConstructor and Description
protected
AbstractCookiesByNameIterator(final CharSequence
Each return value of next() will have HttpCookiePair#name() equivalent to this value.
cookiePairName
)

Create a new instance.

Method Summary

Modifier and TypeMethod and Description
protected abstract void
protected abstract @Nullable CharSequence

Returns:

the current value for HttpHeaderNames#COOKIE, or null if all have been iterated.
cookieHeaderValue
()

Get the current value for HttpHeaderNames#COOKIE.

private @Nullable HttpCookiePair

Returns:

the next HttpCookiePair value for next(), or null if all have been parsed.
findNext
(CharSequence
The current value for HttpHeaderNames#COOKIE.
cookieHeaderValue
)

Find the next HttpCookiePair value for next().

public final boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
protected final void
initNext(CharSequence
The initial value for HttpHeaderNames#COOKIE.
cookieHeaderValue
)

Initialize the next HttpCookiePair value for next().

public final HttpCookiePair
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cookiePairNameback to summary
private final CharSequence cookiePairName
nextback to summary
private @Nullable HttpCookiePair next
Annotations
@Nullable
nextNextStartback to summary
private int nextNextStart

Constructor Detail

AbstractCookiesByNameIteratorback to summary
protected AbstractCookiesByNameIterator(final CharSequence cookiePairName)

Create a new instance.

Parameters
cookiePairName:CharSequence

Each return value of next() will have HttpCookiePair#name() equivalent to this value.

Method Detail

advanceCookieHeaderValueback to summary
protected abstract void advanceCookieHeaderValue()

Advance the cookieHeaderValue() to the next HttpHeaderNames#COOKIE header value.

cookieHeaderValueback to summary
protected abstract @Nullable CharSequence cookieHeaderValue()

Get the current value for HttpHeaderNames#COOKIE. This value may change during iteration.

Returns:@Nullable CharSequence

the current value for HttpHeaderNames#COOKIE, or null if all have been iterated.

Annotations
@Nullable
findNextback to summary
private @Nullable HttpCookiePair findNext(CharSequence cookieHeaderValue)

Find the next HttpCookiePair value for next().

Parameters
cookieHeaderValue:CharSequence

The current value for HttpHeaderNames#COOKIE.

Returns:@Nullable HttpCookiePair

the next HttpCookiePair value for next(), or null if all have been parsed.

Annotations
@Nullable
hasNextback to summary
public final boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
initNextback to summary
protected final void initNext(CharSequence cookieHeaderValue)

Initialize the next HttpCookiePair value for next().

Parameters
cookieHeaderValue:CharSequence

The initial value for HttpHeaderNames#COOKIE.

nextback to summary
public final HttpCookiePair next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:HttpCookiePair

the next element in the iteration

Annotations
@Override
io.netty5.handler.codec.http.headers back to summary

public abstract Class HeaderUtils.AbstractCookiesIterator

extends Object
implements Iterator<HttpCookiePair>
Class Inheritance
  • java.lang.Object
  • io.netty5.handler.codec.http.headers.HeaderUtils.AbstractCookiesIterator
All Implemented Interfaces
java.util.Iterator
Known Direct Subclasses
io.netty5.handler.codec.http.headers.DefaultHttpHeaders.CookiesIterator

An Iterator of HttpCookiePair designed to iterate across multiple values of HttpHeaderNames#COOKIE.

Field Summary

Modifier and TypeField and Description
private @Nullable HttpCookiePair
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract void
protected abstract @Nullable CharSequence

Returns:

the current value for HttpHeaderNames#COOKIE, or null if all have been iterated.
cookieHeaderValue
()

Get the current value for HttpHeaderNames#COOKIE.

private HttpCookiePair

Returns:

the next HttpCookiePair value for next(), or null if all have been parsed.
findNext
(CharSequence
The current value for HttpHeaderNames#COOKIE.
cookieHeaderValue
)

Find the next HttpCookiePair value for next().

public final boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
protected final void
initNext(CharSequence
The initial value for HttpHeaderNames#COOKIE.
cookieHeaderValue
)

Initialize the next HttpCookiePair value for next().

public final HttpCookiePair
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nextback to summary
private @Nullable HttpCookiePair next
Annotations
@Nullable
nextNextStartback to summary
private int nextNextStart

Constructor Detail

AbstractCookiesIteratorback to summary
public AbstractCookiesIterator()

Method Detail

advanceCookieHeaderValueback to summary
protected abstract void advanceCookieHeaderValue()

Advance the cookieHeaderValue() to the next HttpHeaderNames#COOKIE header value.

cookieHeaderValueback to summary
protected abstract @Nullable CharSequence cookieHeaderValue()

Get the current value for HttpHeaderNames#COOKIE. This value may change during iteration.

Returns:@Nullable CharSequence

the current value for HttpHeaderNames#COOKIE, or null if all have been iterated.

Annotations
@Nullable
findNextback to summary
private HttpCookiePair findNext(CharSequence cookieHeaderValue)

Find the next HttpCookiePair value for next().

Parameters
cookieHeaderValue:CharSequence

The current value for HttpHeaderNames#COOKIE.

Returns:HttpCookiePair

the next HttpCookiePair value for next(), or null if all have been parsed.

hasNextback to summary
public final boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
initNextback to summary
protected final void initNext(CharSequence cookieHeaderValue)

Initialize the next HttpCookiePair value for next().

Parameters
cookieHeaderValue:CharSequence

The initial value for HttpHeaderNames#COOKIE.

nextback to summary
public final HttpCookiePair next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:HttpCookiePair

the next element in the iteration

Annotations
@Override