public Func<HttpResponseMessage, bool> HandleUnsuccessfulResponseFunc { get; }
Gets a delegate function which indicates whether this back-off handler should handle an abnormal HTTP
response. The default isDefaultHandleUnsuccessfulResponseFunc.
Gets the maximum time span to wait. If the back-off instance returns a greater time span, the handle method
returnsfalse. Default value is 16 seconds per a retry request.
public virtual Task<bool> HandleExceptionAsync(HandleExceptionArgs args)
Handles an exception thrown when sending a HTTP request.
A simple rule must be followed, if you modify the request object in a way that the exception can be
resolved, you must returntrue.
public virtual Task<bool> HandleResponseAsync(HandleUnsuccessfulResponseArgs args)
Handles an abnormal response when sending a HTTP request.
A simple rule must be followed, if you modify the request object in a way that the abnormal response can
be resolved, you must returntrue.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eBackOffHandler\u003c/code\u003e class is a thread-safe handler designed to manage abnormal HTTP responses or exceptions by utilizing an \u003ccode\u003eIBackOff\u003c/code\u003e policy for retry mechanisms.\u003c/p\u003e\n"],["\u003cp\u003eIt implements both \u003ccode\u003eIHttpUnsuccessfulResponseHandler\u003c/code\u003e and \u003ccode\u003eIHttpExceptionHandler\u003c/code\u003e interfaces, allowing it to handle both unsuccessful HTTP responses and exceptions that may arise during HTTP requests.\u003c/p\u003e\n"],["\u003cp\u003eThis handler provides properties such as \u003ccode\u003eBackOff\u003c/code\u003e, \u003ccode\u003eHandleExceptionFunc\u003c/code\u003e, \u003ccode\u003eHandleUnsuccessfulResponseFunc\u003c/code\u003e, and \u003ccode\u003eMaxTimeSpan\u003c/code\u003e to customize the back-off policy, exception handling, and response handling behaviors.\u003c/p\u003e\n"],["\u003cp\u003eThe class offers methods like \u003ccode\u003eHandleExceptionAsync\u003c/code\u003e and \u003ccode\u003eHandleResponseAsync\u003c/code\u003e for implementing custom logic to modify request objects and determine if a request needs to be resent after an exception or abnormal response.\u003c/p\u003e\n"],["\u003cp\u003eConstructors are available to initialize the \u003ccode\u003eBackOffHandler\u003c/code\u003e with either a \u003ccode\u003eBackOffHandler.Initializer\u003c/code\u003e or an \u003ccode\u003eIBackOff\u003c/code\u003e instance, offering flexibility in setting up the retry strategy.\u003c/p\u003e\n"]]],[],null,["# Class BackOffHandler (1.69.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.69.0 (latest)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.BackOffHandler)\n- [1.68.0](/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Http.BackOffHandler)\n- [1.60.0](/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Http.BackOffHandler)\n- [1.59.0](/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Http.BackOffHandler)\n- [1.55.0](/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Http.BackOffHandler)\n- [1.50.0](/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Http.BackOffHandler) \n\n public class BackOffHandler : IHttpUnsuccessfulResponseHandler, IHttpExceptionHandler\n\nA thread-safe back-off handler which handles an abnormal HTTP response or an exception with\n[IBackOff](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.IBackOff). \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e BackOffHandler \n\nImplements\n----------\n\n[IHttpUnsuccessfulResponseHandler](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.IHttpUnsuccessfulResponseHandler), [IHttpExceptionHandler](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.IHttpExceptionHandler) \n\nInherited Members\n-----------------\n\n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) \n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Apis.Http](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http)\n\nAssembly\n--------\n\nGoogle.Apis.Core.dll\n\nConstructors\n------------\n\n### BackOffHandler(Initializer)\n\n public BackOffHandler(BackOffHandler.Initializer initializer)\n\nConstructs a new back-off handler with the given initializer.\n\n### BackOffHandler(IBackOff)\n\n public BackOffHandler(IBackOff backOff)\n\nConstructs a new back-off handler with the given back-off.\n\nProperties\n----------\n\n### BackOff\n\n public IBackOff BackOff { get; }\n\nGets the back-off policy used by this back-off handler.\n\n### HandleExceptionFunc\n\n public Func\u003cException, bool\u003e HandleExceptionFunc { get; }\n\nGets a delegate function which indicates whether this back-off handler should handle an exception. The\ndefault is [DefaultHandleExceptionFunc](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.BackOffHandler.Initializer#Google_Apis_Http_BackOffHandler_Initializer_DefaultHandleExceptionFunc).\n\n### HandleUnsuccessfulResponseFunc\n\n public Func\u003cHttpResponseMessage, bool\u003e HandleUnsuccessfulResponseFunc { get; }\n\nGets a delegate function which indicates whether this back-off handler should handle an abnormal HTTP\nresponse. The default is [DefaultHandleUnsuccessfulResponseFunc](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.BackOffHandler.Initializer#Google_Apis_Http_BackOffHandler_Initializer_DefaultHandleUnsuccessfulResponseFunc).\n\n### MaxTimeSpan\n\n public TimeSpan MaxTimeSpan { get; }\n\nGets the maximum time span to wait. If the back-off instance returns a greater time span, the handle method\nreturns `false`. Default value is 16 seconds per a retry request.\n\nMethods\n-------\n\n### HandleExceptionAsync(HandleExceptionArgs)\n\n public virtual Task\u003cbool\u003e HandleExceptionAsync(HandleExceptionArgs args)\n\nHandles an exception thrown when sending a HTTP request.\nA simple rule must be followed, if you modify the request object in a way that the exception can be\nresolved, you must return `true`.\n\n### HandleResponseAsync(HandleUnsuccessfulResponseArgs)\n\n public virtual Task\u003cbool\u003e HandleResponseAsync(HandleUnsuccessfulResponseArgs args)\n\nHandles an abnormal response when sending a HTTP request.\nA simple rule must be followed, if you modify the request object in a way that the abnormal response can\nbe resolved, you must return `true`.\n\n### Wait(TimeSpan, CancellationToken)\n\n protected virtual Task Wait(TimeSpan ts, CancellationToken cancellationToken)\n\nWaits the given time span. Overriding this method is recommended for mocking purposes.\n\nExtension Method\n----------------\n\n[Utilities.ThrowIfNull\\\u003cT\\\u003e(T, string)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)"]]