Enum Class RedirectStatusCode
- All Implemented Interfaces:
Serializable,Comparable<RedirectStatusCode>,Constable
Use SEE_OTHER whenever redirecting after collecting a credential (i.e., some
proof of who the user is, like a password or token). Do not use MOVED_TEMPORARILY or
MOVED_PERMANENTLY because the user agent may automatically make a request to the URI in the
Location header using the same HTTP method and contents. In such a case, the URI to be redirected to
may be another server that should not gain access to the credential. Only SEE_OTHER guarantees
that the method will be changed to GET.
The following table from RFC 7238 gives a good overview of the different kinds of redirects:
| Permanent | Temporary | |
|---|---|---|
| Allows changing the request method from POST to GET | MOVED_PERMANENTLY |
MOVED_TEMPORARILY |
| Does not allow changing the request method from POST to GET | PERMANENT_REDIRECT |
TEMPORARY_REDIRECT |
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionStatus code (301) indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests.Status code (302) indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource.Status code (308) indicating that the requested resource permanently resides at a different URI and the user agent may not change the request method fromPOSTtoGET(if applicable).Status code (303) indicating that the response to the request can be found under a different URI.Status code (307) indicating that the requested resource resides temporarily under a different URI.Deprecated.As of RFC 7231, this status code has been deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic RedirectStatusCodefromInt(int redirectStatusCode) Creates a redirect status code.static RedirectStatusCodefromInt(int redirectStatusCode, int defaultValue) Creates a redirect status code using the default value if the input is not acceptable.intvalue()Gets the integer value of the redirect status code.static RedirectStatusCodeReturns the enum constant of this class with the specified name.static RedirectStatusCode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
MOVED_PERMANENTLY
Status code (301) indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests. -
MOVED_TEMPORARILY
Status code (302) indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource.This definition is being retained for backwards compatibility. SC_FOUND is now the preferred definition.
-
SEE_OTHER
Status code (303) indicating that the response to the request can be found under a different URI. -
TEMPORARY_REDIRECT
Status code (307) indicating that the requested resource resides temporarily under a different URI. The temporary URI SHOULD be given by theLocationfield in the response. When following such a redirect, the user agent may not change the request method fromPOSTtoGET(if applicable). -
USE_PROXY
Deprecated.As of RFC 7231, this status code has been deprecated.Status code (305) indicating that the requested resource MUST be accessed through the proxy given by theLocationfield. -
PERMANENT_REDIRECT
Status code (308) indicating that the requested resource permanently resides at a different URI and the user agent may not change the request method fromPOSTtoGET(if applicable).- See Also:
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
value
public int value()Gets the integer value of the redirect status code.- Returns:
- the redirect status code
-
fromInt
Creates a redirect status code.Valid values are 301, 302, 303, 305, 307, or 308.
- Parameters:
redirectStatusCode- the redirect status code to convert- Returns:
- the redirect status code
- Throws:
IllegalArgumentException- if redirectStatusCode is not one of the valid redirect status codes
-
fromInt
Creates a redirect status code using the default value if the input is not acceptable.Valid values are 301, 302, 305, 307, or 308. If redirectStatusCode is any other value, then defaultValue will be used. If defaultValue is not one of these values, then an error will be thrown.
- Parameters:
redirectStatusCode- the redirect status code to convertdefaultValue- the default value to use if redirectStatusCode is invalid- Returns:
- the redirect status code
- Throws:
IllegalArgumentException- if redirectStatusCode and defaultValue are not one of the valid redirect status codes- Since:
- 3.0.0
-