Package com.azure.core.http.policy
Class AddHeadersFromContextPolicy
- java.lang.Object
-
- com.azure.core.http.policy.AddHeadersFromContextPolicy
-
- All Implemented Interfaces:
HttpPipelinePolicy
public class AddHeadersFromContextPolicy extends Object implements HttpPipelinePolicy
The pipeline policy that override or addHttpHeaders
inHttpRequest
by reading values fromContext
with key 'azure-http-headers-key'. The value for this key should be of typeHttpHeaders
for it to be added inHttpRequest
.Code Sample: Add multiple HttpHeader in Context and call client
// Create ConfigurationClient for example ConfigurationClient configurationClient = new ConfigurationClientBuilder() .connectionString("endpoint={endpoint_value};id={id_value};secret={secret_value}") .buildClient(); // Add your headers HttpHeaders headers = new HttpHeaders(); headers.put("my-header1", "my-header1-value"); headers.put("my-header2", "my-header2-value"); headers.put("my-header3", "my-header3-value"); // Call API by passing headers in Context. configurationClient.addConfigurationSettingWithResponse( new ConfigurationSetting().setKey("key").setValue("value"), new Context(AddHeadersFromContextPolicy.AZURE_REQUEST_HTTP_HEADERS_KEY, headers)); // Above three HttpHeader will be added in outgoing HttpRequest.
-
-
Field Summary
Fields Modifier and Type Field Description static String
AZURE_REQUEST_HTTP_HEADERS_KEY
Key used to override headers in HttpRequest.
-
Constructor Summary
Constructors Constructor Description AddHeadersFromContextPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<HttpResponse>
process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)
Processes provided request context and invokes the next policy.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.azure.core.http.policy.HttpPipelinePolicy
getPipelinePosition
-
-
-
-
Field Detail
-
AZURE_REQUEST_HTTP_HEADERS_KEY
public static final String AZURE_REQUEST_HTTP_HEADERS_KEY
Key used to override headers in HttpRequest. The Value for this key should beHttpHeaders
.- See Also:
- Constant Field Values
-
-
Method Detail
-
process
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)
Description copied from interface:HttpPipelinePolicy
Processes provided request context and invokes the next policy.- Specified by:
process
in 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.
-
-