Class HttpPolicyProviders

java.lang.Object
com.azure.core.http.policy.HttpPolicyProviders

public final class HttpPolicyProviders extends Object
The HttpPolicyProviders class is responsible for adding Service Provider Interface (SPI) pluggable policies to an HTTP pipeline automatically.

This class is useful when you need to add custom policies to the HTTP pipeline that are loaded using Java's ServiceLoader. It provides methods to add policies before and after the retry policy in the pipeline.

Code sample:

In this example, an empty list of policies is created. Then, the HttpPolicyProviders.addBeforeRetryPolicies method is used to add policies that should be executed before the retry policy. The HttpPolicyProviders.addAfterRetryPolicies method is used to add policies that should be executed after the retry policy. The list of policies can then be used to build an HTTP pipeline.

 List<HttpPipelinePolicy> policies = new ArrayList<>();
 // Add policies that should be executed before the retry policy
 HttpPolicyProviders.addBeforeRetryPolicies(policies);
 // Add the retry policy
 policies.add(new RetryPolicy());
 // Add policies that should be executed after the retry policy
 HttpPolicyProviders.addAfterRetryPolicies(policies);
 
See Also: