public final class HeaderUtils
extends Object
HttpHeaders implementations.| Modifier and Type | Class and Description |
|---|---|
static class |
HeaderUtils.CookiesByNameIterator
An
Iterator of HttpCookiePair designed to iterate across multiple values of
HttpHeaderNames.COOKIE for a specific cookie-name. |
static class |
HeaderUtils.CookiesIterator
|
| Modifier and Type | Field and Description |
|---|---|
static BiFunction<? super CharSequence,? super CharSequence,CharSequence> |
DEFAULT_HEADER_FILTER |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
domainMatches(CharSequence requestDomain,
CharSequence cookieDomain)
|
static boolean |
hasContentType(HttpHeaders headers,
CharSequence expectedContentType,
Charset expectedCharset)
Checks if the provider headers contain a
Content-Type header that matches the specified content type,
and optionally the provided charset. |
static boolean |
isSetCookieNameMatches(CharSequence setCookieString,
CharSequence setCookieName)
|
static boolean |
isTransferEncodingChunked(HttpHeaders headers)
Returns
true if headers indicates transfer-encoding chunked. |
static HttpCookiePair |
parseCookiePair(CharSequence cookieString,
CharSequence cookiePairName)
Parse a single cookie-pair from a
cookie-string.
|
static HttpSetCookie |
parseSetCookie(CharSequence setCookieString,
CharSequence setCookieName,
boolean validate)
Parse a
HttpSetCookie from a
set-cookie-string. |
static boolean |
pathMatches(CharSequence requestPath,
CharSequence cookiePath)
|
static CharSequence |
removeCookiePairs(CharSequence cookieString,
CharSequence cookiePairName)
Remove a single cookie-pair for a
cookie-string.
|
public static final BiFunction<? super CharSequence,? super CharSequence,CharSequence> DEFAULT_HEADER_FILTER
public static boolean isTransferEncodingChunked(HttpHeaders headers)
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.
headers - The HttpHeaders to check.headers indicates transfer-encoding chunked, false
otherwise.public static boolean domainMatches(CharSequence requestDomain,
@Nullable
CharSequence cookieDomain)
requestDomain - The domain from the request.cookieDomain - The domain from the cookie.true if there is a match.public static boolean pathMatches(CharSequence requestPath,
@Nullable
CharSequence cookiePath)
requestPath - The path from the request.cookiePath - The path from the cookie.true if there is a match.public static boolean isSetCookieNameMatches(CharSequence setCookieString,
CharSequence setCookieName)
setCookieString - The set-cookie-string.setCookieName - The cookie-name.true if a set-cookie-string's
cookie-name matches setCookieName.@Nullable public static HttpSetCookie parseSetCookie(CharSequence setCookieString, CharSequence setCookieName, boolean validate)
HttpSetCookie from a
set-cookie-string.setCookieString - The set-cookie-string.setCookieName - The cookie-name.validate - true to attempt extra validation.HttpSetCookie from a
set-cookie-string.@Nullable public static HttpCookiePair parseCookiePair(CharSequence cookieString, CharSequence cookiePairName)
cookieString - The cookie-string that may
contain multiple cookie-pairs.cookiePairName - The cookie-name identifying
the cookie-pairs to parse.cookiePairNamenull if no matches were found@Nullable
public static CharSequence removeCookiePairs(CharSequence cookieString,
CharSequence cookiePairName)
cookieString - The cookie-string that may
contain multiple cookie-pairs.cookiePairName - The cookie-name identifying
the cookie-pairs to remove.cookiePairNamecookiePairNamenull if none of the cookie-pairs
matched cookiePairNamepublic static boolean hasContentType(HttpHeaders headers, CharSequence expectedContentType, @Nullable Charset expectedCharset)
Content-Type header that matches the specified content type,
and optionally the provided charset.headers - the HttpHeaders instanceexpectedContentType - the content type to look for, provided as a type/subtypeexpectedCharset - an optional charset constraint.true if a Content-Type header that matches the specified content type, and optionally
the provided charset has been found, false otherwise.