Package com.azure.core.http.policy
Class HostPolicy
java.lang.Object
com.azure.core.http.policy.HostPolicy
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprocess(HttpPipelineCallContext context, HttpPipelineNextPolicy next) Processes provided request context and invokes the next policy.processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next) Processes provided request context and invokes the next policy synchronously.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.core.http.policy.HttpPipelinePolicy
getPipelinePosition
-
Constructor Details
-
HostPolicy
Create HostPolicy.- Parameters:
host- The host to set on every HttpRequest.
-
-
Method Details
-
process
Description copied from interface:HttpPipelinePolicyProcesses provided request context and invokes the next policy.- Specified by:
processin interfaceHttpPipelinePolicy- Parameters:
context- The request context.next- The next policy to invoke.- Returns:
- A publisher that initiates the request upon subscription and emits a response on completion.
-
processSync
Description copied from interface:HttpPipelinePolicyProcesses provided request context and invokes the next policy synchronously.- Specified by:
processSyncin interfaceHttpPipelinePolicy- Parameters:
context- The request context.next- The next policy to invoke.- Returns:
- A publisher that initiates the request upon subscription and emits a response on completion.
-