public class ConfigurableMessageHandler : DelegatingHandler
A message handler which contains the main logic of our HTTP requests. It contains a list of IHttpUnsuccessfulResponseHandlers for handling abnormal responses, a list of IHttpExceptionHandlers for handling exception in a request and a list of IHttpExecuteInterceptors for intercepting a request before it has been sent to the server. It also contains important properties like number of tries, follow redirect, etc.
Namespace
Google.Apis.HttpAssembly
Google.Apis.Core.dll
Constructors
ConfigurableMessageHandler(HttpMessageHandler)
public ConfigurableMessageHandler(HttpMessageHandler httpMessageHandler)
Constructs a new configurable message handler.
Parameter | |
---|---|
Name | Description |
httpMessageHandler | HttpMessageHandler |
Fields
CredentialKey
public const string CredentialKey = null
Key for a credential in a properties.
Field Value | |
---|---|
Type | Description |
String |
ExceptionHandlerKey
public const string ExceptionHandlerKey = null
Key for exception handlers in an properties.
Field Value | |
---|---|
Type | Description |
String |
ExecuteInterceptorKey
public const string ExecuteInterceptorKey = null
Key for execute handlers in an properties.
Field Value | |
---|---|
Type | Description |
String |
MaxAllowedNumTries
public const int MaxAllowedNumTries = null
Maximum allowed number of tries.
Field Value | |
---|---|
Type | Description |
Int32 |
ResponseStreamInterceptorProviderKey
public const string ResponseStreamInterceptorProviderKey = null
Key for a stream response interceptor provider in an properties.
Field Value | |
---|---|
Type | Description |
String |
UnsuccessfulResponseHandlerKey
public const string UnsuccessfulResponseHandlerKey = null
Key for unsuccessful response handlers in an properties.
Field Value | |
---|---|
Type | Description |
String |
Properties
ApplicationName
public string ApplicationName { get; set; }
Gets or sets the application name which will be used on the User-Agent header.
Property Value | |
---|---|
Type | Description |
String |
Credential
public IHttpExecuteInterceptor Credential { get; set; }
The credential to apply to all requests made with this client, unless theres a specific call credential set. If Credential implements IHttpUnsuccessfulResponseHandler then it will also be included as a handler of an unsuccessful response.
Property Value | |
---|---|
Type | Description |
IHttpExecuteInterceptor |
ExceptionHandlers
public IList<IHttpExceptionHandler> ExceptionHandlers { get; }
Gets a list of IHttpExceptionHandlers.
Property Value | |
---|---|
Type | Description |
IList<IHttpExceptionHandler> |
ExecuteInterceptors
public IList<IHttpExecuteInterceptor> ExecuteInterceptors { get; }
Gets a list of IHttpExecuteInterceptors.
Property Value | |
---|---|
Type | Description |
IList<IHttpExecuteInterceptor> |
FollowRedirect
public bool FollowRedirect { get; set; }
Gets or sets whether the handler should follow a redirect when a redirect response is received. Default
value is true
.
Property Value | |
---|---|
Type | Description |
Boolean |
GoogleApiClientHeader
public string GoogleApiClientHeader { get; set; }
Gets or sets the value set for the x-goog-api-client header.
Property Value | |
---|---|
Type | Description |
String |
IsLoggingEnabled
public bool IsLoggingEnabled { get; set; }
Gets or sets whether logging is enabled. Default value is true
.
Property Value | |
---|---|
Type | Description |
Boolean |
LogEvents
public ConfigurableMessageHandler.LogEventType LogEvents { get; set; }
The request/response types to log.
Property Value | |
---|---|
Type | Description |
ConfigurableMessageHandler.LogEventType |
NumRedirects
public int NumRedirects { get; set; }
Gets or sets the number of redirects that will be allowed to execute. The default value is 10
.
See NumTries for more information.
Property Value | |
---|---|
Type | Description |
Int32 |
NumTries
public int NumTries { get; set; }
Gets or sets the number of tries that will be allowed to execute. Retries occur as a result of either
IHttpUnsuccessfulResponseHandler or IHttpExceptionHandler which handles the
abnormal HTTP response or exception before being terminated.
Set 1
for not retrying requests. The default value is 3
.
Property Value | |
---|---|
Type | Description |
Int32 |
UnsuccessfulResponseHandlers
public IList<IHttpUnsuccessfulResponseHandler> UnsuccessfulResponseHandlers { get; }
Gets a list of IHttpUnsuccessfulResponseHandlers.
Property Value | |
---|---|
Type | Description |
IList<IHttpUnsuccessfulResponseHandler> |
Methods
AddExceptionHandler(IHttpExceptionHandler)
public void AddExceptionHandler(IHttpExceptionHandler handler)
Adds the specified handler to the list of exception handlers.
Parameter | |
---|---|
Name | Description |
handler | IHttpExceptionHandler |
AddExecuteInterceptor(IHttpExecuteInterceptor)
public void AddExecuteInterceptor(IHttpExecuteInterceptor interceptor)
Adds the specified interceptor to the list of execute interceptors.
Parameter | |
---|---|
Name | Description |
interceptor | IHttpExecuteInterceptor |
AddUnsuccessfulResponseHandler(IHttpUnsuccessfulResponseHandler)
public void AddUnsuccessfulResponseHandler(IHttpUnsuccessfulResponseHandler handler)
Adds the specified handler to the list of unsuccessful response handlers.
Parameter | |
---|---|
Name | Description |
handler | IHttpUnsuccessfulResponseHandler |
RemoveExceptionHandler(IHttpExceptionHandler)
public void RemoveExceptionHandler(IHttpExceptionHandler handler)
Removes the specified handler from the list of exception handlers.
Parameter | |
---|---|
Name | Description |
handler | IHttpExceptionHandler |
RemoveExecuteInterceptor(IHttpExecuteInterceptor)
public void RemoveExecuteInterceptor(IHttpExecuteInterceptor interceptor)
Removes the specified interceptor from the list of execute interceptors.
Parameter | |
---|---|
Name | Description |
interceptor | IHttpExecuteInterceptor |
RemoveUnsuccessfulResponseHandler(IHttpUnsuccessfulResponseHandler)
public void RemoveUnsuccessfulResponseHandler(IHttpUnsuccessfulResponseHandler handler)
Removes the specified handler from the list of unsuccessful response handlers.
Parameter | |
---|---|
Name | Description |
handler | IHttpUnsuccessfulResponseHandler |
SendAsync(HttpRequestMessage, CancellationToken)
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
The main logic of sending a request to the server. This send method adds the User-Agent header to a request with ApplicationName and the library version. It also calls interceptors before each attempt, and unsuccessful response handler or exception handlers when abnormal response or exception occurred.
Parameters | |
---|---|
Name | Description |
request | HttpRequestMessage |
cancellationToken | CancellationToken |
Returns | |
---|---|
Type | Description |
Task<HttpResponseMessage> |