public final class HttpHeaders
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static okio.ByteString |
QUOTED_STRING_DELIMITERS |
private static okio.ByteString |
TOKEN_DELIMITERS |
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.
|
private static void |
parseChallengeHeader(java.util.List<Challenge> result,
okio.Buffer header) |
static java.util.List<Challenge> |
parseChallenges(Headers responseHeaders,
java.lang.String headerName)
Parse RFC 7235 challenges.
|
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. |
private static java.lang.String |
readQuotedString(okio.Buffer buffer)
Reads a double-quoted string, unescaping quoted pairs like
\" to the 2nd character in
each sequence. |
private static java.lang.String |
readToken(okio.Buffer buffer)
Consumes and returns a non-empty token, terminating at special characters in
TOKEN_DELIMITERS . |
static void |
receiveHeaders(CookieJar cookieJar,
HttpUrl url,
Headers headers) |
private static java.lang.String |
repeat(char c,
int count) |
private static int |
skipAll(okio.Buffer buffer,
byte b) |
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 boolean |
skipWhitespaceAndCommas(okio.Buffer buffer)
Returns true if any commas were skipped.
|
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 okio.ByteString QUOTED_STRING_DELIMITERS
private static final okio.ByteString TOKEN_DELIMITERS
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 headerName)
For example, the first line has a parameter name/value pair and the second line has a single token68:
WWW-Authenticate: Digest foo=bar
WWW-Authenticate: Digest foo=
Similarly, the first line has one challenge and the second line has two challenges:
WWW-Authenticate: Digest ,foo=bar
WWW-Authenticate: Digest ,foo
private static void parseChallengeHeader(java.util.List<Challenge> result, okio.Buffer header)
private static boolean skipWhitespaceAndCommas(okio.Buffer buffer)
private static int skipAll(okio.Buffer buffer, byte b)
private static java.lang.String readQuotedString(okio.Buffer buffer)
\"
to the 2nd character in
each sequence. Returns the unescaped string, or null if the buffer isn't prefixed with a
double-quoted string.private static java.lang.String readToken(okio.Buffer buffer)
TOKEN_DELIMITERS
. Returns null if the buffer is empty or prefixed with a delimiter.private static java.lang.String repeat(char c, int count)
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.