@Contract(threading=IMMUTABLE) public class DefaultRedirectStrategy extends Object implements RedirectStrategy
RedirectStrategy. 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 and
307 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 of DefaultRedirectStrategy.
LaxRedirectStrategy| Modifier and Type | Field and Description |
|---|---|
static DefaultRedirectStrategy |
INSTANCE |
static String |
REDIRECT_LOCATIONS
Deprecated.
(4.3) use
HttpClientContext.REDIRECT_LOCATIONS. |
static int |
SC_PERMANENT_REDIRECT |
| Constructor and Description |
|---|
DefaultRedirectStrategy() |
DefaultRedirectStrategy(String[] redirectMethods)
Constructs a new instance to redirect the given HTTP methods.
|
| Modifier and Type | Method and Description |
|---|---|
protected URI |
createLocationURI(String location) |
URI |
getLocationURI(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context) |
HttpUriRequest |
getRedirect(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.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.
|
protected boolean |
isRedirectable(String method) |
boolean |
isRedirected(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context)
Determines if a request should be redirected to a new location
given the response from the target server.
|
public static final int SC_PERMANENT_REDIRECT
@Deprecated public static final String REDIRECT_LOCATIONS
HttpClientContext.REDIRECT_LOCATIONS.public static final DefaultRedirectStrategy INSTANCE
public DefaultRedirectStrategy()
public DefaultRedirectStrategy(String[] redirectMethods)
redirectMethods - The methods to redirect.public boolean isRedirected(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context)
throws org.apache.http.ProtocolException
RedirectStrategyisRedirected in interface RedirectStrategyrequest - the executed requestresponse - the response received from the target servercontext - the context for the request executiontrue if the request should be redirected, false
otherwiseorg.apache.http.ProtocolExceptionpublic URI getLocationURI(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context) throws org.apache.http.ProtocolException
org.apache.http.ProtocolExceptionprotected URI createLocationURI(String location) throws org.apache.http.ProtocolException
org.apache.http.ProtocolExceptionprotected boolean isRedirectable(String method)
public HttpUriRequest getRedirect(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context) throws org.apache.http.ProtocolException
RedirectStrategygetRedirect in interface RedirectStrategyrequest - the executed requestresponse - the response received from the target servercontext - the context for the request executionorg.apache.http.ProtocolExceptionCopyright © 1999–2022 The Apache Software Foundation. All rights reserved.