Class WarningValue
java.lang.Object
org.apache.hc.client5.http.impl.cache.WarningValue
This class provides for parsing and understanding Warning headers. As
the Warning header can be multi-valued, but the values can contain
separators like commas inside quoted strings, we cannot use the regular
NameValuePair.getValue() } call to access the values.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Patternprivate static final Stringprivate final intprivate static final Stringprivate static final Stringprivate intprivate static final Stringprivate static final Stringprivate static final Stringprivate final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Patternprivate Stringprivate intprivate Instantprivate Stringprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconsumeCharacter(char c) protected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidReturns the "warn-agent" string associated with this warning, which is either the name or pseudonym of the server that added this particular Warning header.intReturns the 3-digit code associated with this warning.Returns the date and time when this warning was added, ornullif a warning date was not supplied in the header.static WarningValue[]getWarningValues(org.apache.hc.core5.http.Header h) Returns an array of the parsable warning values contained in the given header value, which is assumed to be a Warning header.Returns the human-readable warning text for this warning.private booleanisChar(char c) private booleanisControl(char c) private booleanisSeparator(char c) private booleanisTokenChar(char c) private voidtoString()Formats aWarningValueas aStringsuitable for including in a header.
-
Field Details
-
offs
private int offs -
init_offs
private final int init_offs -
src
-
warnCode
private int warnCode -
warnAgent
-
warnText
-
warnDate
-
TOPLABEL
- See Also:
-
DOMAINLABEL
- See Also:
-
HOSTNAME
- See Also:
-
IPV4ADDRESS
- See Also:
-
HOST
- See Also:
-
PORT
- See Also:
-
HOSTPORT
- See Also:
-
HOSTPORT_PATTERN
-
MONTH
- See Also:
-
WEEKDAY
- See Also:
-
WKDAY
- See Also:
-
TIME
- See Also:
-
DATE3
- See Also:
-
DATE2
- See Also:
-
DATE1
- See Also:
-
ASCTIME_DATE
- See Also:
-
RFC850_DATE
- See Also:
-
RFC1123_DATE
- See Also:
-
HTTP_DATE
- See Also:
-
WARN_DATE
- See Also:
-
WARN_DATE_PATTERN
-
-
Constructor Details
-
Method Details
-
getWarningValues
Returns an array of the parsable warning values contained in the given header value, which is assumed to be a Warning header. Improperly formatted warning values will be skipped, in keeping with the philosophy of "ignore what you cannot understand."- Parameters:
h- WarningHeaderto parse- Returns:
- array of
WarnValueobjects
-
consumeLinearWhitespace
protected void consumeLinearWhitespace() -
isChar
private boolean isChar(char c) -
isControl
private boolean isControl(char c) -
isSeparator
private boolean isSeparator(char c) -
consumeToken
protected void consumeToken() -
isTokenChar
private boolean isTokenChar(char c) -
consumeHostPort
protected void consumeHostPort() -
consumeWarnAgent
protected void consumeWarnAgent() -
consumeQuotedString
protected void consumeQuotedString() -
consumeWarnText
protected void consumeWarnText() -
consumeWarnDate
protected void consumeWarnDate() -
consumeWarnValue
protected void consumeWarnValue() -
consumeCharacter
protected void consumeCharacter(char c) -
consumeWarnCode
protected void consumeWarnCode() -
parseError
private void parseError() -
getWarnCode
public int getWarnCode()Returns the 3-digit code associated with this warning.- Returns:
int
-
getWarnAgent
-
getWarnText
Returns the human-readable warning text for this warning. Note that the original quoted-string is returned here, including escaping for any contained characters. In other words, if the header was:Warning: 110 fred "Response is stale"
then this method will return"\"Response is stale\""(surrounding quotes included).- Returns:
String
-
getWarnDate
-
toString
-