Interface RedirectStrategy

All Known Implementing Classes:
DefaultRedirectStrategy, LaxRedirectStrategy

@Contract(threading=STATELESS) public interface RedirectStrategy
A strategy for determining if an HTTP request should be redirected to a new location in response to an HTTP response received from the target server.

Implementations of this interface must be thread-safe. Access to shared data must be synchronized as methods of this interface may be executed from multiple threads.

Since:
4.1
  • Method Summary

    Modifier and Type
    Method
    Description
    getLocationURI(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context)
     
    default 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.
  • Method Details

    • isRedirected

      boolean isRedirected(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context) throws org.apache.hc.core5.http.HttpException
      Determines if a request should be redirected to a new location given the response from the target server.
      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
      Throws:
      org.apache.hc.core5.http.HttpException
    • getLocationURI

      URI getLocationURI(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context) throws org.apache.hc.core5.http.HttpException
      Throws:
      org.apache.hc.core5.http.HttpException
    • isRedirectAllowed

      default 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.

      It is legal for this method implementation to modify the redirect request in order to make it suitable for redirect execution.

      Since:
      5.4