@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 . |
Constructor and Description |
---|
DefaultRedirectStrategy() |
Modifier and Type | Method and Description |
---|---|
protected URI |
createLocationURI(String location) |
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.
|
protected boolean |
isRedirectable(String method) |
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.
|
@Deprecated public static final String REDIRECT_LOCATIONS
HttpClientContext.REDIRECT_LOCATIONS
.public static final DefaultRedirectStrategy INSTANCE
public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException
RedirectStrategy
isRedirected
in interface RedirectStrategy
request
- the executed requestresponse
- the response received from the target servercontext
- the context for the request executiontrue
if the request should be redirected, false
otherwiseProtocolException
public URI getLocationURI(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException
ProtocolException
protected URI createLocationURI(String location) throws ProtocolException
ProtocolException
protected boolean isRedirectable(String method)
public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException
RedirectStrategy
getRedirect
in interface RedirectStrategy
request
- the executed requestresponse
- the response received from the target servercontext
- the context for the request executionProtocolException
Copyright © 1999–2013 The Apache Software Foundation. All rights reserved.