Package com.helger.http.header.specific
Class HttpForwardedHeaderHop
java.lang.Object
com.helger.http.header.specific.HttpForwardedHeaderHop
This class contains the different value pairs for a single "Forwarded" header hop as defined in
RFC 7239.
- Since:
- 10.5.1
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringStandard "by" parameter name as defined in RFC 7239static final StringStandard "for" parameter name as defined in RFC 7239static final StringStandard "host" parameter name as defined in RFC 7239static final StringStandard "proto" parameter name as defined in RFC 7239 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if the "by" token is present.booleanCheck if the "for" token is present.booleanCheck if the "host" token is present.booleanCheck if the "proto" token is present.booleancontainsToken(String sToken) Check if the specified token is present.booleanGet a copy of all pairs.com.helger.collection.commons.ICommonsOrderedSet<String> Get all token names in the order they were added.Convert this forwarded list to its string representation according to RFC 7239.getBy()Get the "by" parameter value.getFirstValue(String sToken) Get the value for the specified token.getFor()Get the "for" parameter value.getHost()Get the "host" parameter value.getProto()Get the "proto" parameter value.inthashCode()booleanisEmpty()Check if this forwarded list is empty (contains no pairs).booleanCheck if this forwarded list is not empty (contains at least one pair).Remove all pairs.com.helger.base.state.EChangeremovePair(String sToken) Remove the specified token and its value.Add the "by" parameter with the specified proxy identifier.Add the "for" parameter with the specified client identifier.Add the "host" parameter with the specified host header value.Add the "proto" parameter with the specified protocol scheme.intsize()Get the number of pairs contained in this list.toString()
-
Field Details
-
PARAM_FOR
Standard "for" parameter name as defined in RFC 7239- See Also:
-
PARAM_HOST
Standard "host" parameter name as defined in RFC 7239- See Also:
-
PARAM_BY
Standard "by" parameter name as defined in RFC 7239- See Also:
-
PARAM_PROTO
Standard "proto" parameter name as defined in RFC 7239- See Also:
-
-
Constructor Details
-
HttpForwardedHeaderHop
public HttpForwardedHeaderHop()
-
-
Method Details
-
addPair
@Nonnull public HttpForwardedHeaderHop addPair(@Nonnull @Nonempty String sToken, @Nonnull String sValue) -
getFirstValue
Get the value for the specified token.- Parameters:
sToken- The token to get the value for. May not benullor empty.- Returns:
nullif no such token is present.
-
containsToken
Check if the specified token is present.- Parameters:
sToken- The token to check. May not benullor empty.- Returns:
trueif the token is present,falseotherwise.
-
containsFor
public boolean containsFor()Check if the "for" token is present.- Returns:
trueif the token is present,falseotherwise.
-
containsHost
public boolean containsHost()Check if the "host" token is present.- Returns:
trueif the token is present,falseotherwise.
-
containsBy
public boolean containsBy()Check if the "by" token is present.- Returns:
trueif the token is present,falseotherwise.
-
containsProto
public boolean containsProto()Check if the "proto" token is present.- Returns:
trueif the token is present,falseotherwise.
-
removePair
Remove the specified token and its value.- Parameters:
sToken- The token to remove. May not benullor empty.- Returns:
EChange.CHANGEDif the value was removed,EChange.UNCHANGEDotherwise.
-
getAllTokens
@Nonnull @ReturnsMutableCopy public com.helger.collection.commons.ICommonsOrderedSet<String> getAllTokens()Get all token names in the order they were added.- Returns:
- A mutable copy of all token names. Never
null.
-
getAllPairs
@Nonnull @ReturnsMutableCopy public com.helger.collection.commons.ICommonsOrderedMap<String,String> getAllPairs()Get a copy of all pairs.- Returns:
- A mutable copy of all pairs. Never
null.
-
removeAll
Remove all pairs.- Returns:
- this for chaining.
-
isEmpty
public boolean isEmpty()Check if this forwarded list is empty (contains no pairs).- Returns:
trueif empty,falseotherwise.
-
isNotEmpty
public boolean isNotEmpty()Check if this forwarded list is not empty (contains at least one pair).- Returns:
trueif not empty,falseotherwise.
-
size
public int size()Get the number of pairs contained in this list.- Returns:
- The number of pairs. Always ≥ 0.
-
setFor
Add the "for" parameter with the specified client identifier. This parameter identifies the client that the request came from.- Parameters:
sClientIdentifier- The client identifier. May not benull.- Returns:
- this for chaining.
-
getFor
Get the "for" parameter value.- Returns:
- The client identifier or
nullif not present.
-
setHost
Add the "host" parameter with the specified host header value. This parameter contains the host header field value that the client requested.- Parameters:
sHost- The host header value. May not benull.- Returns:
- this for chaining.
-
getHost
Get the "host" parameter value.- Returns:
- The host header value or
nullif not present.
-
setBy
Add the "by" parameter with the specified proxy identifier. This parameter identifies the proxy that received the request.- Parameters:
sProxyIdentifier- The proxy identifier. May not benull.- Returns:
- this for chaining.
-
getBy
Get the "by" parameter value.- Returns:
- The proxy identifier or
nullif not present.
-
setProto
Add the "proto" parameter with the specified protocol scheme. This parameter indicates the protocol scheme of the original request.- Parameters:
sProtocolScheme- The protocol scheme. May not benull.- Returns:
- this for chaining.
-
getProto
Get the "proto" parameter value.- Returns:
- The protocol scheme or
nullif not present.
-
getAsString
Convert this forwarded list to its string representation according to RFC 7239. The format is: token=value;token=value;...- Returns:
- The string representation. Never
nullbut may be empty.
-
equals
-
hashCode
public int hashCode() -
toString
-