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
ConstructorsConstructorDescriptionConstructor creating an empty forwarded header hop. -
Method Summary
Modifier and TypeMethodDescription@NonNull HttpForwardedHeaderHopAdd a token-value pair to this forwarded hop.booleanCheck 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(@NonNull @Nonempty String sToken) Check if the specified token is present.booleanGet a copy of all pairs.@NonNull com.helger.collection.commons.ICommonsOrderedSet<String> Get all token names in the order they were added.@NonNull StringConvert this forwarded list to its string representation according to RFC 7239.@Nullable StringgetBy()Get the "by" parameter value.@Nullable StringgetFirstValue(@NonNull @Nonempty String sToken) Get the value for the specified token.@Nullable StringgetFor()Get the "for" parameter value.@Nullable StringgetHost()Get the "host" parameter value.@Nullable StringgetProto()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).@NonNull HttpForwardedHeaderHopRemove all pairs.@Nullable com.helger.base.state.EChangeremovePair(@NonNull @Nonempty String sToken) Remove the specified token and its value.@NonNull HttpForwardedHeaderHopAdd the "by" parameter with the specified proxy identifier.@NonNull HttpForwardedHeaderHopAdd the "for" parameter with the specified client identifier.@NonNull HttpForwardedHeaderHopAdd the "host" parameter with the specified host header value.@NonNull HttpForwardedHeaderHopAdd 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()Constructor creating an empty forwarded header hop.
-
-
Method Details
-
addPair
public @NonNull HttpForwardedHeaderHop addPair(@Nonempty @NonNull @Nonempty String sToken, @NonNull String sValue) Add a token-value pair to this forwarded hop. If the token already exists, its value will be overwritten with a warning.- Parameters:
sToken- The token name. May neither benullnor empty. Must be a valid RFC 7230 token.sValue- The value for the token. May not benull.- Returns:
- this for chaining
-
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
public @Nullable com.helger.base.state.EChange removePair(@Nonempty @NonNull @Nonempty String sToken) 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
@ReturnsMutableCopy public @NonNull 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
@ReturnsMutableCopy public @NonNull 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
-