Class RedirectPolicy

java.lang.Object
com.azure.core.http.policy.RedirectPolicy
All Implemented Interfaces:
HttpPipelinePolicy

public final class RedirectPolicy extends Object implements HttpPipelinePolicy
The RedirectPolicy class is an implementation of the HttpPipelinePolicy interface. This policy handles HTTP redirects by determining if an HTTP request should be redirected based on the received HttpResponse.

This class is useful when you need to handle HTTP redirects in a pipeline. It uses a RedirectStrategy to decide if a request should be redirected. By default, it uses the DefaultRedirectStrategy, which redirects the request based on the HTTP status code of the response.

Code sample:

In this example, a RedirectPolicy is constructed and can be added to a pipeline. For a request sent by the pipeline, if the server responds with a redirect status code, the request will be redirected according to the RedirectStrategy used by the RedirectPolicy.

 RedirectPolicy redirectPolicy = new RedirectPolicy();
 
See Also: