@Contract(threading=STATELESS) public class LaxRedirectStrategy extends DefaultRedirectStrategy
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.
| Modifier and Type | Field and Description |
|---|---|
static LaxRedirectStrategy |
INSTANCE |
| Constructor and Description |
|---|
LaxRedirectStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
isRedirectable(String method) |
boolean |
isRedirectAllowed(HttpHost currentTarget,
HttpHost newTarget,
HttpRequest redirect,
HttpContext context)
Determines if the given redirect should be executed or the redirect response
should be returned to the caller without further processing.
|
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.
|
createLocationURI, getLocationURIpublic static final LaxRedirectStrategy INSTANCE
public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context)
RedirectStrategyisRedirected in interface RedirectStrategyisRedirected in class DefaultRedirectStrategyrequest - the executed requestresponse - the response received from the target servercontext - the context for the request executiontrue if the request should be redirected, false
otherwisepublic boolean isRedirectAllowed(HttpHost currentTarget, HttpHost newTarget, HttpRequest redirect, HttpContext context)
RedirectStrategyIt is legal for this method implementation to modify the redirect request in order to make it suitable for redirect execution.
isRedirectAllowed in interface RedirectStrategyisRedirectAllowed in class DefaultRedirectStrategyprotected boolean isRedirectable(String method)
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.