Google API Client Library for .NET  1.10.0
Public Member Functions | Public Attributes | Protected Member Functions | Properties | List of all members
Google.Apis.Http.ConfigurableMessageHandler Class Reference

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. More...

Inheritance diagram for Google.Apis.Http.ConfigurableMessageHandler:

Public Member Functions

void AddUnsuccessfulResponseHandler (IHttpUnsuccessfulResponseHandler handler)
 Adds the specified handler to the list of unsuccessful response handlers. More...
 
void RemoveUnsuccessfulResponseHandler (IHttpUnsuccessfulResponseHandler handler)
 Removes the specified handler from the list of unsuccessful response handlers. More...
 
void AddExceptionHandler (IHttpExceptionHandler handler)
 Adds the specified handler to the list of exception handlers. More...
 
void RemoveExceptionHandler (IHttpExceptionHandler handler)
 Removes the specified handler from the list of exception handlers. More...
 
void AddExecuteInterceptor (IHttpExecuteInterceptor interceptor)
 Adds the specified interceptor to the list of execute interceptors. More...
 
void RemoveExecuteInterceptor (IHttpExecuteInterceptor interceptor)
 Removes the specified interceptor from the list of execute interceptors. More...
 
 ConfigurableMessageHandler (HttpMessageHandler httpMessageHandler)
 Constructs a new configurable message handler. More...
 

Public Attributes

const int MaxAllowedNumTries = 20
 Maximum allowed number of tries. More...
 

Protected Member Functions

override async 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. More...
 

Properties

IList
< IHttpUnsuccessfulResponseHandler
UnsuccessfulResponseHandlers [get]
 Gets a list of IHttpUnsuccessfulResponseHandlers. More...
 
IList< IHttpExceptionHandlerExceptionHandlers [get]
 Gets a list of IHttpExceptionHandlers. More...
 
IList< IHttpExecuteInterceptorExecuteInterceptors [get]
 Gets a list of IHttpExecuteInterceptors. More...
 
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. More...
 
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. More...
 
bool FollowRedirect [get, set]
 Gets or sets whether the handler should follow a redirect when a redirect response is received. Default value is true. More...
 
bool IsLoggingEnabled [get, set]
 Gets or sets whether logging is enabled. Default value is true. More...
 
string ApplicationName [get, set]
 Gets or sets the application name which will be used on the User-Agent header. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

Google.Apis.Http.ConfigurableMessageHandler.ConfigurableMessageHandler ( HttpMessageHandler  httpMessageHandler)
inline

Constructs a new configurable message handler.

Member Function Documentation

void Google.Apis.Http.ConfigurableMessageHandler.AddExceptionHandler ( IHttpExceptionHandler  handler)
inline

Adds the specified handler to the list of exception handlers.

void Google.Apis.Http.ConfigurableMessageHandler.AddExecuteInterceptor ( IHttpExecuteInterceptor  interceptor)
inline

Adds the specified interceptor to the list of execute interceptors.

void Google.Apis.Http.ConfigurableMessageHandler.AddUnsuccessfulResponseHandler ( IHttpUnsuccessfulResponseHandler  handler)
inline

Adds the specified handler to the list of unsuccessful response handlers.

void Google.Apis.Http.ConfigurableMessageHandler.RemoveExceptionHandler ( IHttpExceptionHandler  handler)
inline

Removes the specified handler from the list of exception handlers.

void Google.Apis.Http.ConfigurableMessageHandler.RemoveExecuteInterceptor ( IHttpExecuteInterceptor  interceptor)
inline

Removes the specified interceptor from the list of execute interceptors.

void Google.Apis.Http.ConfigurableMessageHandler.RemoveUnsuccessfulResponseHandler ( IHttpUnsuccessfulResponseHandler  handler)
inline

Removes the specified handler from the list of unsuccessful response handlers.

override async Task<HttpResponseMessage> Google.Apis.Http.ConfigurableMessageHandler.SendAsync ( HttpRequestMessage  request,
CancellationToken  cancellationToken 
)
inlineprotected

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.

Member Data Documentation

const int Google.Apis.Http.ConfigurableMessageHandler.MaxAllowedNumTries = 20

Maximum allowed number of tries.

Property Documentation

string Google.Apis.Http.ConfigurableMessageHandler.ApplicationName
getset

Gets or sets the application name which will be used on the User-Agent header.

IList<IHttpExceptionHandler> Google.Apis.Http.ConfigurableMessageHandler.ExceptionHandlers
get

Gets a list of IHttpExceptionHandlers.

Since version 1.10, AddExceptionHandler and RemoveExceptionHandler were added in order to keep this class thread-safe. More information is available on #592.

IList<IHttpExecuteInterceptor> Google.Apis.Http.ConfigurableMessageHandler.ExecuteInterceptors
get

Gets a list of IHttpExecuteInterceptors.

Since version 1.10, AddExecuteInterceptor and RemoveExecuteInterceptor were added in order to keep this class thread-safe. More information is available on #592.

bool Google.Apis.Http.ConfigurableMessageHandler.FollowRedirect
getset

Gets or sets whether the handler should follow a redirect when a redirect response is received. Default value is true.

bool Google.Apis.Http.ConfigurableMessageHandler.IsLoggingEnabled
getset

Gets or sets whether logging is enabled. Default value is true.

int Google.Apis.Http.ConfigurableMessageHandler.NumRedirects
getset

Gets or sets the number of redirects that will be allowed to execute. The default value is 10. See NumTries for more information.

int Google.Apis.Http.ConfigurableMessageHandler.NumTries
getset

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.

The number of allowed redirects (3xx) is defined by NumRedirects. This property defines only the allowed tries for >=400 responses, or when an exception is thrown. For example if you set NumTries to 1 and NumRedirects to 5, the library will send up to five redirect requests, but will not send any retry requests due to an error HTTP status code.

IList<IHttpUnsuccessfulResponseHandler> Google.Apis.Http.ConfigurableMessageHandler.UnsuccessfulResponseHandlers
get

Gets a list of IHttpUnsuccessfulResponseHandlers.

Since version 1.10, AddUnsuccessfulResponseHandler and RemoveUnsuccessfulResponseHandler were added in order to keep this class thread-safe. More information is available on #592.


The documentation for this class was generated from the following file: