Class UserAgentPolicy
- java.lang.Object
-
- com.azure.android.core.http.policy.UserAgentPolicy
-
- All Implemented Interfaces:
HttpPipelinePolicy
public class UserAgentPolicy extends java.lang.Object implements HttpPipelinePolicy
Pipeline policy that adds "User-Agent" header to a request. The format for the "User-Agent" string is outlined in Azure Core: Telemetry policy.
-
-
Constructor Summary
Constructors Constructor Description UserAgentPolicy()
Creates aUserAgentPolicy
with a default user agent string i.e.UserAgentPolicy(java.lang.String applicationId, java.lang.String sdkName, java.lang.String sdkVersion)
Creates a UserAgentPolicy with thesdkName
andsdkVersion
in the User-Agent header value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
process(HttpPipelinePolicyChain chain)
Updates the "User-Agent" header with the value supplied at the time of creating policy.
-
-
-
Constructor Detail
-
UserAgentPolicy
public UserAgentPolicy()
Creates aUserAgentPolicy
with a default user agent string i.e. "azsdk-android".
-
UserAgentPolicy
public UserAgentPolicy(java.lang.String applicationId, java.lang.String sdkName, java.lang.String sdkVersion)
Creates a UserAgentPolicy with thesdkName
andsdkVersion
in the User-Agent header value.- Parameters:
applicationId
- User specified application Id.sdkName
- Name of the client library.sdkVersion
- Version of the client library.- Throws:
java.lang.IllegalArgumentException
- If the givenapplicationId
is longer than 24 characters or contains spaces.
-
-
Method Detail
-
process
public void process(HttpPipelinePolicyChain chain)
Updates the "User-Agent" header with the value supplied at the time of creating policy.- Specified by:
process
in interfaceHttpPipelinePolicy
- Parameters:
chain
- The chain for the policy to access the request and response.
-
-