AddHeadersPolicy Class
- java.
lang. Object - com.
azure. core. http. policy. AddHeadersPolicy
- com.
Implements
public class AddHeadersPolicy
implements HttpPipelinePolicy
The AddHeadersPolicy class is an implementation of the HttpPipelinePolicy interface. This policy is used to add a set of headers to all outgoing HTTP requests.
This class is useful when there are certain headers that should be included in all requests. For example, you might want to include a "User-Agent" header in all requests to identify your application, or a "Content-Type" header to specify the format of the request body.
Code sample:
In this example, the AddHeadersPolicy is created from the specified headers. The policy can be added to the pipeline and the requests sent will include the headers specified in the AddHeadersPolicy.
HttpHeaders headers = new HttpHeaders();
headers.put("User-Agent", "MyApp/1.0");
headers.put("Content-Type", "application/json");
new AddHeadersPolicy(headers);
Constructor Summary
| Constructor | Description |
|---|---|
| AddHeadersPolicy(HttpHeaders headers) |
Creates a Add |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
Mono<Http |
process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)
Processes provided request context and invokes the next policy. |
|
Http |
processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)
Processes provided request context and invokes the next policy synchronously. |
Methods inherited from java.lang.Object
Constructor Details
AddHeadersPolicy
public AddHeadersPolicy(HttpHeaders headers)
Creates a AddHeadersPolicy.
Parameters:
Method Details
process
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)
Processes provided request context and invokes the next policy.
Parameters:
processSync
public HttpResponse processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)
Processes provided request context and invokes the next policy synchronously.
Parameters: