SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Using HttpRedirectPolicy, application developers can more control over HTTP redirect in a clustered environment. Application developers can specify the policy using WebSocketFactory.setDefaultRedirectPolicy() that will be inherited by all the WebSocket objects that are created from the factory. The policy can be overridden on individual connection basis using WebSocket.setRedirectPolicy().
The pre-defined policies are HttpRedirectPolicy.ALWAYS, HttpRedirectPolicy.NEVER, HttpRedirectPolicy.PEER_DOMAIN, HttpRedirectPolicy.SAME_DOMAIN, HttpRedirectPolicy.SAME_ORIGIN, and HttpRedirectPolicy.SUB_DOMAIN.
Field Summary | |
<static> HttpRedirectPolicy
|
ALWAYS
(Read only) Follow HTTP redirect requests always regardless of the origin, host, domain, etc. |
<static> HttpRedirectPolicy
|
NEVER
(Read only) Do not follow HTTP redirects. |
<static> HttpRedirectPolicy
|
PEER_DOMAIN
(Read only) Follow HTTP redirect only if the redirected request is for a peer-domain. |
<static> HttpRedirectPolicy
|
SAME_DOMAIN
(Read only) Follow HTTP redirect only if the redirected request is for same domain. |
<static> HttpRedirectPolicy
|
SAME_ORIGIN
(Read only) Follow HTTP redirect only if the redirected request is for same origin. |
<static> HttpRedirectPolicy
|
SUB_DOMAIN
(Read only) Follow HTTP redirect only if the redirected request is for child-domain or sub-domain of the original request. |
Constructor Summary | |
HttpRedirectPolicy()
Do not create a new instance of HttpRedirectPolicy. |
Method Summary | |
boolean
|
isRedirectAllowed(originalLoc, redirectLoc)
Returns true if the policy allows redirecting from the original URI to the redirect URI. |
string
|
toString()
Returns the policy name. |
Field Detail |
<static> HttpRedirectPolicy ALWAYS
<static> HttpRedirectPolicy NEVER
<static> HttpRedirectPolicy PEER_DOMAIN
URIs that satisfy HttpRedirectPolicy.SAME_DOMAIN policy will implicitly satisfy HttpRedirectPolicy.PEER_DOMAIN policy.
To determine if the two URIs that are passed into isRedirectionAllowed(originalURI, redirectedURI) function 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.
<static> 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.
<static> HttpRedirectPolicy SAME_ORIGIN
<static> 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.
Constructor Detail |
HttpRedirectPolicy()
Method Detail |
boolean isRedirectAllowed(originalLoc, redirectLoc)
originalLoc
- {String} the original URI
redirectLoc
- {String} the redirected URI
boolean
string toString()
string