Class HttpForwardedHeaderHop

java.lang.Object
com.helger.http.header.specific.HttpForwardedHeaderHop

@NotThreadSafe public class HttpForwardedHeaderHop extends Object
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 Details

    • PARAM_FOR

      public static final String PARAM_FOR
      Standard "for" parameter name as defined in RFC 7239
      See Also:
    • PARAM_HOST

      public static final String PARAM_HOST
      Standard "host" parameter name as defined in RFC 7239
      See Also:
    • PARAM_BY

      public static final String PARAM_BY
      Standard "by" parameter name as defined in RFC 7239
      See Also:
    • PARAM_PROTO

      public static final String 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

      @Nullable public String getFirstValue(@Nonnull @Nonempty String sToken)
      Get the value for the specified token.
      Parameters:
      sToken - The token to get the value for. May not be null or empty.
      Returns:
      null if no such token is present.
    • containsToken

      public boolean containsToken(@Nonnull @Nonempty String sToken)
      Check if the specified token is present.
      Parameters:
      sToken - The token to check. May not be null or empty.
      Returns:
      true if the token is present, false otherwise.
    • containsFor

      public boolean containsFor()
      Check if the "for" token is present.
      Returns:
      true if the token is present, false otherwise.
    • containsHost

      public boolean containsHost()
      Check if the "host" token is present.
      Returns:
      true if the token is present, false otherwise.
    • containsBy

      public boolean containsBy()
      Check if the "by" token is present.
      Returns:
      true if the token is present, false otherwise.
    • containsProto

      public boolean containsProto()
      Check if the "proto" token is present.
      Returns:
      true if the token is present, false otherwise.
    • removePair

      @Nullable public com.helger.base.state.EChange removePair(@Nonnull @Nonempty String sToken)
      Remove the specified token and its value.
      Parameters:
      sToken - The token to remove. May not be null or empty.
      Returns:
      EChange.CHANGED if the value was removed, EChange.UNCHANGED otherwise.
    • 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

      @Nonnull public HttpForwardedHeaderHop removeAll()
      Remove all pairs.
      Returns:
      this for chaining.
    • isEmpty

      public boolean isEmpty()
      Check if this forwarded list is empty (contains no pairs).
      Returns:
      true if empty, false otherwise.
    • isNotEmpty

      public boolean isNotEmpty()
      Check if this forwarded list is not empty (contains at least one pair).
      Returns:
      true if not empty, false otherwise.
    • size

      public int size()
      Get the number of pairs contained in this list.
      Returns:
      The number of pairs. Always ≥ 0.
    • setFor

      @Nonnull public HttpForwardedHeaderHop setFor(@Nonnull String sClientIdentifier)
      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 be null.
      Returns:
      this for chaining.
    • getFor

      @Nullable public String getFor()
      Get the "for" parameter value.
      Returns:
      The client identifier or null if not present.
    • setHost

      @Nonnull public HttpForwardedHeaderHop setHost(@Nonnull String sHost)
      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 be null.
      Returns:
      this for chaining.
    • getHost

      @Nullable public String getHost()
      Get the "host" parameter value.
      Returns:
      The host header value or null if not present.
    • setBy

      @Nonnull public HttpForwardedHeaderHop setBy(@Nonnull String sProxyIdentifier)
      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 be null.
      Returns:
      this for chaining.
    • getBy

      @Nullable public String getBy()
      Get the "by" parameter value.
      Returns:
      The proxy identifier or null if not present.
    • setProto

      @Nonnull public HttpForwardedHeaderHop setProto(@Nonnull String sProtocolScheme)
      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 be null.
      Returns:
      this for chaining.
    • getProto

      @Nullable public String getProto()
      Get the "proto" parameter value.
      Returns:
      The protocol scheme or null if not present.
    • getAsString

      @Nonnull public String 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 null but may be empty.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object