Class LaxRedirectStrategy

  • All Implemented Interfaces:
    RedirectStrategy

    @Contract(threading=STATELESS)
    public class LaxRedirectStrategy
    extends DefaultRedirectStrategy
    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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean isRedirectable​(java.lang.String method)  
      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)
      Determines if the given redirect should be executed or the redirect response should be returned to the caller without further processing.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • REDIRECT_METHODS

        private static final java.lang.String[] REDIRECT_METHODS
    • Constructor Detail

      • LaxRedirectStrategy

        public LaxRedirectStrategy()
    • 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: RedirectStrategy
        Determines if a request should be redirected to a new location given the response from the target server.
        Specified by:
        isRedirected in interface RedirectStrategy
        Overrides:
        isRedirected in class DefaultRedirectStrategy
        Parameters:
        request - the executed request
        response - the response received from the target server
        context - the context for the request execution
        Returns:
        true if the request should be redirected, false otherwise
      • 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: RedirectStrategy
        Determines 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:
        isRedirectAllowed in interface RedirectStrategy
        Overrides:
        isRedirectAllowed in class DefaultRedirectStrategy
      • isRedirectable

        protected boolean isRedirectable​(java.lang.String method)