Class HostPolicy

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

public class HostPolicy extends Object implements HttpPipelinePolicy
The HostPolicy class is an implementation of the HttpPipelinePolicy interface. This policy is used to add a specific host to each HTTP request.

This class is useful when you need to set a specific host for all requests in a pipeline. It ensures that the host is set correctly for each request.

Code sample:

In this example, a HostPolicy is created with a host of "www.example.com". Once added to the pipeline, all requests will have their host set to "www.example.com" by the HostPolicy.

 HostPolicy hostPolicy = new HostPolicy("www.example.com");
 
See Also:
  • Constructor Details

    • HostPolicy

      public HostPolicy(String host)
      Create HostPolicy.
      Parameters:
      host - The host to set on every HttpRequest.
  • Method Details