Package org.apache.hc.client5.http.impl
Class LaxRedirectStrategy
- java.lang.Object
-
- org.apache.hc.client5.http.impl.DefaultRedirectStrategy
-
- org.apache.hc.client5.http.impl.LaxRedirectStrategy
-
- All Implemented Interfaces:
RedirectStrategy
@Contract(threading=STATELESS) public class LaxRedirectStrategy extends DefaultRedirectStrategy
A lax implementation of theRedirectStrategythat 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 Modifier and Type Field Description static LaxRedirectStrategyINSTANCEprivate static java.lang.String[]REDIRECT_METHODS
-
Constructor Summary
Constructors Constructor Description LaxRedirectStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanisRedirectable(java.lang.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 org.apache.hc.client5.http.impl.DefaultRedirectStrategy
createLocationURI, getLocationURI
-
-
-
-
Field Detail
-
INSTANCE
public static final LaxRedirectStrategy INSTANCE
-
REDIRECT_METHODS
private static final java.lang.String[] REDIRECT_METHODS
-
-
Method Detail
-
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
protected boolean isRedirectable(java.lang.String method)
-
-