public enum HttpRedirectPolicy extends Enum<HttpRedirectPolicy> implements Comparator<URI>
Enum Constant and Description |
---|
ALWAYS
Follow HTTP redirect requests always regardless of the origin, domain, etc.
|
NEVER
Do not follow HTTP redirects.
|
PEER_DOMAIN
Follow HTTP redirect only if the redirected request is for a peer-domain.
|
SAME_DOMAIN
Follow HTTP redirect only if the redirected request is for the same
domain.
|
SAME_ORIGIN
Follow HTTP redirect only if the redirected request is for the same
origin.
|
SUB_DOMAIN
Follow HTTP redirect only if the redirected request is for child-domain
or sub-domain of the original request.
|
Modifier and Type | Method and Description |
---|---|
abstract int |
compare(URI current,
URI redirect)
Returns 0, if the aspects of current and the redirected URIs match as per
the option.
|
abstract String |
toString() |
static HttpRedirectPolicy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static HttpRedirectPolicy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
equals
public static final HttpRedirectPolicy NEVER
public static final HttpRedirectPolicy ALWAYS
public static final HttpRedirectPolicy SAME_ORIGIN
public static final HttpRedirectPolicy SAME_DOMAIN
URIs that satisfy HttpRedirectPolicy.SAME_ORIGIN policy will implicitly satisfy HttpRedirectPolicy.SAME_DOMAIN policy.
URIs with identical domains would be ws://production.example.com:8001 and ws://production.example.com:8002.
public static final HttpRedirectPolicy PEER_DOMAIN
URIs that satisfy HttpRedirectPolicy.SAME_DOMAIN policy will implicitly satisfy HttpRedirectPolicy.PEER_DOMAIN policy.
To determine if the two URIs have peer-domains, we do the following:
If both the conditions are satisfied, then we conclude that the URIs are for peer-domains. However, if the host in the URI has no '.'(for eg., ws://localhost:8000), then we just use the entire hostname as the computed base-domain.
If you are using this policy, it is recommended that the number of tokens in the hostname be atleast 2 + number_of_tokens(top-level-domain). For example, if the top-level-domain(TLD) is "com", then the URIs should have atleast 3 tokens in the hostname. So, ws://marketing.example.com:8001 and ws://sales.example.com:8002 are examples of URIs with peer-domains. Similarly, if the TLD is "co.uk", then the URIs should have atleast 4 tokens in the hostname. So, ws://marketing.example.co.uk:8001 and ws://sales.example.co.uk:8002 are examples of URIs with peer-domains.
public static final HttpRedirectPolicy SUB_DOMAIN
URIs that satisfy HttpRedirectPolicy.SAME_DOMAIN policy will implicitly satisfy HttpRedirectPolicy.SUB_DOMAIN policy.
To determine if the domain of the redirected URI is sub-domain/child-domain of the domain of the original URI, we check if the hostname of the redirected URI ends with the hostname of the original URI.
Domain of the redirected URI ws://benefits.hr.example.com:8002 is a sub-domain/child-domain of the domain of the original URI ws://hr.example.com:8001. Note that domain in ws://example.com:9001 is a sub-domain of the domain in ws://example.com:9001.
public static HttpRedirectPolicy[] values()
for (HttpRedirectPolicy c : HttpRedirectPolicy.values()) System.out.println(c);
public static HttpRedirectPolicy valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic abstract int compare(URI current, URI redirect)
compare
in interface Comparator<URI>
current
- URI of the current requestredirect
- URI of the redirected requestpublic abstract String toString()
toString
in class Enum<HttpRedirectPolicy>
Copyright © 2015. All Rights Reserved.