Module org.htmlunit
Package org.htmlunit

Enum Class ReferrerPolicy

java.lang.Object
java.lang.Enum<ReferrerPolicy>
org.htmlunit.ReferrerPolicy
All Implemented Interfaces:
Serializable, Comparable<ReferrerPolicy>, Constable

public enum ReferrerPolicy extends Enum<ReferrerPolicy>
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
The referrer policies; a referrer policy determines the referrer (the Referer header) of a request.
Author:
Ronald Brill
See Also:
  • Enum Constant Details

    • NO_REFERRER

      public static final ReferrerPolicy NO_REFERRER
      No referrer at all.
    • NO_REFERRER_WHEN_DOWNGRADE

      public static final ReferrerPolicy NO_REFERRER_WHEN_DOWNGRADE
      The full url, but no referrer from https to http.
    • SAME_ORIGIN

      public static final ReferrerPolicy SAME_ORIGIN
      The full url for same-origin requests, no referrer for cross-origin requests.
    • ORIGIN

      public static final ReferrerPolicy ORIGIN
      Only the origin.
    • STRICT_ORIGIN

      public static final ReferrerPolicy STRICT_ORIGIN
      Only the origin, but no referrer from https to http.
    • ORIGIN_WHEN_CROSS_ORIGIN

      public static final ReferrerPolicy ORIGIN_WHEN_CROSS_ORIGIN
      The full url for same-origin requests, only the origin for cross-origin requests.
    • STRICT_ORIGIN_WHEN_CROSS_ORIGIN

      public static final ReferrerPolicy STRICT_ORIGIN_WHEN_CROSS_ORIGIN
      The full url for same-origin requests, only the origin for cross-origin requests, no referrer from https to http; this is the default.
    • UNSAFE_URL

      public static final ReferrerPolicy UNSAFE_URL
      Always the full url.
  • Field Details

    • DEFAULT

      public static final ReferrerPolicy DEFAULT
      The default policy.
  • Method Details

    • values

      public static ReferrerPolicy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ReferrerPolicy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getToken

      public String getToken()
      Returns the token of this policy (e.g. 'no-referrer').
      Returns:
      the token
    • fromToken

      public static ReferrerPolicy fromToken(String token)
      Returns the policy for the given token (case-insensitive); used for the referrerpolicy attribute.
      Parameters:
      token - the token
      Returns:
      the policy or null if the token is not a known policy
    • fromMetaContent

      public static ReferrerPolicy fromMetaContent(String content)
      Returns the policy for the content of a meta element with the name 'referrer'; the legacy values ('never', 'default', 'always' and 'origin-when-crossorigin') are supported.
      Parameters:
      content - the content
      Returns:
      the policy or null if the content is not a known policy
      See Also:
    • fromHeader

      public static ReferrerPolicy fromHeader(String headerValue)
      Returns the policy of the value of the Referrer-Policy header: the last known token of the comma separated list.
      Parameters:
      headerValue - the header value
      Returns:
      the policy or null if the value contains no known token
      See Also:
    • getReferrer

      public String getReferrer(URL referrerUrl, URL targetUrl, BrowserVersion browserVersion)
      Determines the referrer for a request to the target url.
      Parameters:
      referrerUrl - the url of the referrer (without user info and ref)
      targetUrl - the url of the request
      browserVersion - the browser version
      Returns:
      the referrer (the value of the Referer header) or null if there is no referrer
      See Also: