Package org.apache.http.impl.client
Class DefaultRedirectStrategy
- java.lang.Object
-
- org.apache.http.impl.client.DefaultRedirectStrategy
-
- All Implemented Interfaces:
RedirectStrategy
- Direct Known Subclasses:
LaxRedirectStrategy
@Contract(threading=IMMUTABLE) public class DefaultRedirectStrategy extends java.lang.Object implements RedirectStrategy
Default implementation ofRedirectStrategy
. This strategy honors the restrictions on automatic redirection of entity enclosing methods such as POST and PUT imposed by the HTTP specification.302 Moved Temporarily
,301 Moved Permanently
and307 Temporary Redirect
status codes will result in an automatic redirect of HEAD and GET methods only. POST and PUT methods will not be automatically redirected as requiring user confirmation.The restriction on automatic redirection of POST methods can be relaxed by using
LaxRedirectStrategy
instead ofDefaultRedirectStrategy
.- Since:
- 4.1
- See Also:
LaxRedirectStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultRedirectStrategy
INSTANCE
static java.lang.String
REDIRECT_LOCATIONS
Deprecated.(4.3) useHttpClientContext.REDIRECT_LOCATIONS
.
-
Constructor Summary
Constructors Constructor Description DefaultRedirectStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.URI
getLocationURI(HttpRequest request, HttpResponse response, HttpContext context)
HttpUriRequest
getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
Determines the redirect location given the response from the target server and the current request execution context and generates a new request to be sent to the location.boolean
isRedirected(HttpRequest request, HttpResponse response, HttpContext context)
Determines if a request should be redirected to a new location given the response from the target server.
-
-
-
Field Detail
-
REDIRECT_LOCATIONS
@Deprecated public static final java.lang.String REDIRECT_LOCATIONS
Deprecated.(4.3) useHttpClientContext.REDIRECT_LOCATIONS
.- See Also:
- Constant Field Values
-
INSTANCE
public static final DefaultRedirectStrategy INSTANCE
-
-
Method Detail
-
isRedirected
public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException
Description copied from interface:RedirectStrategy
Determines if a request should be redirected to a new location given the response from the target server.- Specified by:
isRedirected
in interfaceRedirectStrategy
- Parameters:
request
- the executed requestresponse
- the response received from the target servercontext
- the context for the request execution- Returns:
true
if the request should be redirected,false
otherwise- Throws:
ProtocolException
-
getLocationURI
public java.net.URI getLocationURI(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException
- Throws:
ProtocolException
-
getRedirect
public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException
Description copied from interface:RedirectStrategy
Determines the redirect location given the response from the target server and the current request execution context and generates a new request to be sent to the location.- Specified by:
getRedirect
in interfaceRedirectStrategy
- Parameters:
request
- the executed requestresponse
- the response received from the target servercontext
- the context for the request execution- Returns:
- redirected request
- Throws:
ProtocolException
-
-