Class LaxRedirectStrategy
java.lang.Object
org.apache.hc.client5.http.impl.DefaultRedirectStrategy
org.apache.hc.client5.http.impl.LaxRedirectStrategy
- All Implemented Interfaces:
RedirectStrategy
A lax implementation of the
RedirectStrategy that automatically handles HTTP redirects
for HEAD, GET, POST, and DELETE requests based on the response status code.
This strategy relaxes the HTTP specification restrictions on automatic redirection of POST requests, allowing redirects for these methods where the specification might otherwise prohibit them. This can be useful in scenarios where a server indicates a redirect for a POST request that the client should follow.
This class is thread-safe and stateless, suitable for use across multiple threads without additional synchronization.
- Since:
- 5.4
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanisRedirectable(String method) booleanisRedirectAllowed(org.apache.hc.core5.http.HttpHost currentTarget, org.apache.hc.core5.http.HttpHost newTarget, org.apache.hc.core5.http.HttpRequest redirect, org.apache.hc.core5.http.protocol.HttpContext context) Determines if the given redirect should be executed or the redirect response should be returned to the caller without further processing.booleanisRedirected(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context) Determines if a request should be redirected to a new location given the response from the target server.Methods inherited from class DefaultRedirectStrategy
createLocationURI, getLocationURI
-
Field Details
-
INSTANCE
-
REDIRECT_METHODS
-
-
Constructor Details
-
LaxRedirectStrategy
public LaxRedirectStrategy()
-
-
Method Details
-
isRedirected
public boolean isRedirected(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context) 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- Overrides:
isRedirectedin classDefaultRedirectStrategy- 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
-
isRedirectAllowed
public boolean isRedirectAllowed(org.apache.hc.core5.http.HttpHost currentTarget, org.apache.hc.core5.http.HttpHost newTarget, org.apache.hc.core5.http.HttpRequest redirect, org.apache.hc.core5.http.protocol.HttpContext context) Description copied from interface:RedirectStrategyDetermines if the given redirect should be executed or the redirect response should be returned to the caller without further processing.It is legal for this method implementation to modify the redirect request in order to make it suitable for redirect execution.
- Specified by:
isRedirectAllowedin interfaceRedirectStrategy- Overrides:
isRedirectAllowedin classDefaultRedirectStrategy
-
isRedirectable
-