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 String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final Pattern
private static final String
private final int
private static final String
private static final String
private int
private static final String
private static final String
private static final String
private final String
private static final String
private static final String
private static final String
private static final Pattern
private String
private int
private Instant
private String
private static final String
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
consumeCharacter
(char c) protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
Returns the "warn-agent" string associated with this warning, which is either the name or pseudonym of the server that added this particular Warning header.int
Returns the 3-digit code associated with this warning.Returns the date and time when this warning was added, ornull
if 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 boolean
isChar
(char c) private boolean
isControl
(char c) private boolean
isSeparator
(char c) private boolean
isTokenChar
(char c) private void
toString()
Formats aWarningValue
as aString
suitable 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
- WarningHeader
to parse- Returns:
- array of
WarnValue
objects
-
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
Returns the "warn-agent" string associated with this warning, which is either the name or pseudonym of the server that added this particular Warning header.- Returns:
String
-
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
Returns the date and time when this warning was added, ornull
if a warning date was not supplied in the header.- Returns:
Instant
-
toString
Formats aWarningValue
as aString
suitable for including in a header. For example, you can:WarningValue wv = ...; HttpResponse resp = ...; resp.addHeader("Warning", wv.toString());
-