Class DefaultRedirectStrategy
java.lang.Object
org.apache.http.impl.client.DefaultRedirectStrategy
- All Implemented Interfaces:
RedirectStrategy
- Direct Known Subclasses:
LaxRedirectStrategy
Default implementation of
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.- Since:
- 4.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DefaultRedirectStrategystatic final StringDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected URIcreateLocationURI(String location) getLocationURI(HttpRequest request, HttpResponse response, HttpContext context) 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 booleanisRedirectable(String method) booleanisRedirected(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 Details
-
REDIRECT_LOCATIONS
Deprecated.(4.3) useHttpClientContext.REDIRECT_LOCATIONS.- See Also:
-
INSTANCE
-
-
Constructor Details
-
DefaultRedirectStrategy
public DefaultRedirectStrategy()
-
-
Method Details
-
isRedirected
public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException Description copied from interface:RedirectStrategyDetermines if a request should be redirected to a new location given the response from the target server.- Specified by:
isRedirectedin interfaceRedirectStrategy- Parameters:
request- the executed requestresponse- the response received from the target servercontext- the context for the request execution- Returns:
trueif the request should be redirected,falseotherwise- Throws:
ProtocolException
-
getLocationURI
public URI getLocationURI(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException - Throws:
ProtocolException
-
createLocationURI
- Throws:
ProtocolException- Since:
- 4.1
-
isRedirectable
- Since:
- 4.2
-
getRedirect
public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException Description copied from interface:RedirectStrategyDetermines 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:
getRedirectin interfaceRedirectStrategy- Parameters:
request- the executed requestresponse- the response received from the target servercontext- the context for the request execution- Returns:
- redirected request
- Throws:
ProtocolException
-
HttpClientContext.REDIRECT_LOCATIONS.