Class RequestContext
Options that can be used to control the behavior of a request sent by a client.
Inheritance
Namespace: System.Dynamic.ExpandoObject
Assembly: Azure.Core.dll
Syntax
public class RequestContext
Constructors
RequestContext()
Properties
CancellationToken
The token to check for cancellation.
Declaration
public System.Threading.CancellationToken CancellationToken { get; set; }
Property Value
|
System.Threading.CancellationToken
|
ErrorOptions
Controls under what conditions the operation raises an exception if the underlying response indicates a failure.
Declaration
public Azure.ErrorOptions ErrorOptions { get; set; }
Property Value
|
ErrorOptions
|
Methods
AddClassifier(ResponseClassificationHandler)
Customizes the ResponseClassifier for this operation. Adding a ResponseClassificationHandler changes the classification behavior so that it first tries to classify a response via the handler, and if the handler doesn't have an opinion, it instead uses the default classifier. Handlers are applied in order so the most recently added takes precedence. This is useful for cases where you'd like to prevent specific response status codes from being treated as errors by logging and distributed tracing policies -- that is, if a response is not classified as an error, it will not appear as an error in logs or distributed traces.
Declaration
public void AddClassifier (Azure.Core.ResponseClassificationHandler classifier);
Parameters
|
ResponseClassificationHandler
classifier
The custom classifier. |
Exceptions
|
System.InvalidOperationException
If this method is called after the RequestContext has been used in a method call. |
AddClassifier(Int32, Boolean)
Customizes the ResponseClassifier for this operation to change the default Response classification behavior so that it considers the passed-in status code to be an error or not, as specified. Status code classifiers are applied after all ResponseClassificationHandler classifiers. This is useful for cases where you'd like to prevent specific response status codes from being treated as errors by logging and distributed tracing policies -- that is, if a response is not classified as an error, it will not appear as an error in logs or distributed traces.
Declaration
public void AddClassifier (int statusCode, bool isError);
Parameters
|
System.Int32
statusCode
The status code to customize classification for. |
|
System.Boolean
isError
Whether the passed-in status code should be classified as an error. |
Exceptions
|
System.ArgumentOutOfRangeException
statusCode is not between 100 and 599 (inclusive). |
|
System.InvalidOperationException
If this method is called after the RequestContext has been used in a method call. |
AddPolicy(HttpPipelinePolicy, HttpPipelinePosition)
Adds an HttpPipelinePolicy into the pipeline for the duration of this request.
The position of policy in the pipeline is controlled by position parameter.
If you want the policy to execute once per client request use PerCall
otherwise use PerRetry to run the policy for every retry.
Declaration
public void AddPolicy (Azure.Core.Pipeline.HttpPipelinePolicy policy, Azure.Core.HttpPipelinePosition position);
Parameters
|
HttpPipelinePolicy
policy
The HttpPipelinePolicy instance to be added to the pipeline. |
|
HttpPipelinePosition
position
The position of the policy in the pipeline. |
Operators
Implicit(ErrorOptions to RequestContext)
Initializes a new instance of the RequestContext class using the given ErrorOptions.
Declaration
public static implicit operator Azure.RequestContext (Azure.ErrorOptions options);
Parameters
|
ErrorOptions
options
|
Returns
|
RequestContext
|