Package com.azure.core.http
Class HttpPipelineBuilder
java.lang.Object
com.azure.core.http.HttpPipelineBuilder
This class provides a fluent builder API to help aid the configuration and instantiation of the
HttpPipeline
,
calling build
constructs an instance of the pipeline.
A pipeline is configured with a HttpClient that sends the request, if no client is set a default is used. A pipeline may be configured with a list of policies that are applied to each request.
Code Samples
Create a pipeline without configuration
HttpPipeline pipeline = new HttpPipelineBuilder().build();
Create a pipeline using the default HTTP client and a retry policy
HttpPipeline pipeline = new HttpPipelineBuilder() .httpClient(HttpClient.createDefault()) .policies(new RetryPolicy()) .build();
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of HttpPipelineBuilder that can configure options for theHttpPipeline
before creating an instance of it. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates anHttpPipeline
based on options set in the builder.clientOptions
(ClientOptions clientOptions) Sets the ClientOptions that will configure the pipeline.httpClient
(HttpClient httpClient) Sets the HttpClient that the pipeline will use to send requests.policies
(HttpPipelinePolicy... policies) Addspolicies
to the set of policies that the pipeline will use when sending requests.
-
Constructor Details
-
HttpPipelineBuilder
public HttpPipelineBuilder()Creates a new instance of HttpPipelineBuilder that can configure options for theHttpPipeline
before creating an instance of it.
-
-
Method Details
-
build
Creates anHttpPipeline
based on options set in the builder. Every timebuild()
is called, a new instance ofHttpPipeline
is created.If HttpClient is not set then a default HttpClient is used.
- Returns:
- A HttpPipeline with the options set from the builder.
-
httpClient
Sets the HttpClient that the pipeline will use to send requests.- Parameters:
httpClient
- The HttpClient the pipeline will use when sending requests.- Returns:
- The updated HttpPipelineBuilder object.
-
policies
Addspolicies
to the set of policies that the pipeline will use when sending requests.- Parameters:
policies
- Policies to add to the policy set.- Returns:
- The updated HttpPipelineBuilder object.
-
clientOptions
Sets the ClientOptions that will configure the pipeline.- Parameters:
clientOptions
- The ClientOptions that will configure the pipeline.- Returns:
- The updated HttpPipelineBuilder object.
-