public final class HttpHeaders
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.regex.Pattern |
PARAMETER |
private static java.lang.String |
QUOTED_STRING |
private static java.lang.String |
TOKEN |
Modifier | Constructor and Description |
---|---|
private |
HttpHeaders() |
Modifier and Type | Method and Description |
---|---|
static long |
contentLength(Headers headers) |
static long |
contentLength(Response response) |
static boolean |
hasBody(Response response)
Returns true if the response must have a (possibly 0-length) body.
|
static boolean |
hasVaryAll(Headers responseHeaders)
Returns true if a Vary header contains an asterisk.
|
static boolean |
hasVaryAll(Response response)
Returns true if a Vary header contains an asterisk.
|
static java.util.List<Challenge> |
parseChallenges(Headers responseHeaders,
java.lang.String challengeHeader)
Parse RFC 7617 challenges, also wrong ordered ones.
|
static int |
parseSeconds(java.lang.String value,
int defaultValue)
Returns
value as a positive integer, or 0 if it is negative, or defaultValue if
it cannot be parsed. |
static void |
receiveHeaders(CookieJar cookieJar,
HttpUrl url,
Headers headers) |
static int |
skipUntil(java.lang.String input,
int pos,
java.lang.String characters)
Returns the next index in
input at or after pos that contains a character from
characters . |
static int |
skipWhitespace(java.lang.String input,
int pos)
Returns the next non-whitespace character in
input that is white space. |
private static long |
stringToLong(java.lang.String s) |
static java.util.Set<java.lang.String> |
varyFields(Headers responseHeaders)
Returns the names of the request headers that need to be checked for equality when caching.
|
private static java.util.Set<java.lang.String> |
varyFields(Response response) |
static Headers |
varyHeaders(Headers requestHeaders,
Headers responseHeaders)
Returns the subset of the headers in
requestHeaders that impact the content of
response's body. |
static Headers |
varyHeaders(Response response)
Returns the subset of the headers in
response 's request that impact the content of
response's body. |
static boolean |
varyMatches(Response cachedResponse,
Headers cachedRequest,
Request newRequest)
Returns true if none of the Vary headers have changed between
cachedRequest and newRequest . |
private static final java.lang.String TOKEN
private static final java.lang.String QUOTED_STRING
private static final java.util.regex.Pattern PARAMETER
public static long contentLength(Response response)
public static long contentLength(Headers headers)
private static long stringToLong(java.lang.String s)
public static boolean varyMatches(Response cachedResponse, Headers cachedRequest, Request newRequest)
cachedRequest
and newRequest
.public static boolean hasVaryAll(Response response)
public static boolean hasVaryAll(Headers responseHeaders)
private static java.util.Set<java.lang.String> varyFields(Response response)
public static java.util.Set<java.lang.String> varyFields(Headers responseHeaders)
public static Headers varyHeaders(Response response)
response
's request that impact the content of
response's body.public static Headers varyHeaders(Headers requestHeaders, Headers responseHeaders)
requestHeaders
that impact the content of
response's body.public static java.util.List<Challenge> parseChallenges(Headers responseHeaders, java.lang.String challengeHeader)
public static boolean hasBody(Response response)
public static int skipUntil(java.lang.String input, int pos, java.lang.String characters)
input
at or after pos
that contains a character from
characters
. Returns the input length if none of the requested characters can be found.public static int skipWhitespace(java.lang.String input, int pos)
input
that is white space. Result is
undefined if input contains newline characters.public static int parseSeconds(java.lang.String value, int defaultValue)
value
as a positive integer, or 0 if it is negative, or defaultValue
if
it cannot be parsed.