@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 |
isRedirected(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.
|
createLocationURI, getLocationURI, isRedirectAllowed
public static final LaxRedirectStrategy INSTANCE
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)
RedirectStrategy
isRedirected
in interface RedirectStrategy
isRedirected
in class DefaultRedirectStrategy
request
- the executed requestresponse
- the response received from the target servercontext
- the context for the request executiontrue
if the request should be redirected, false
otherwiseprotected boolean isRedirectable(String method)
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.