TransientHttpErrorHandler Class
- Namespace
- Kampute.HttpClient.ErrorHandlers
- Assembly
- Kampute.HttpClient.dll
Definition
Handles HTTP responses with a transient error status code by attempting to back off and retry the request according to a specified or default backoff strategy.
public class TransientHttpErrorHandler : RetryableHttpErrorHandler- Inheritance
- object
- RetryableHttpErrorHandler
- TransientHttpErrorHandler
Constructors
TransientHttpErrorHandler()
Initializes a new instance of the TransientHttpErrorHandler class with default transient error status codes.
public TransientHttpErrorHandler()Remarks
The default transient error status codes handled by this instance are:
- 408–Request Timeout
- 502–Bad Gateway
- 503–Service Unavailable
- 504–Gateway Timeout
- 507–Insufficient Storage
- 509–Bandwidth Limit Exceeded
TransientHttpErrorHandler(IEnumerable<HttpStatusCode>)
Initializes a new instance of the TransientHttpErrorHandler class with specified transient error status codes.
public TransientHttpErrorHandler(IEnumerable<HttpStatusCode> statusCodes)Parameters
statusCodesIEnumerable<HttpStatusCode>- The collection of HTTP status codes that this handler will process as transient errors.
Exceptions
- ArgumentNullException
- Thrown if
statusCodesisnull. - ArgumentException
- Thrown if
statusCodesis empty.
Properties
HandledStatusCodes
Gets the collection of HTTP status codes that are considered transient errors and handled by this instance.
public IReadOnlyCollection<HttpStatusCode> HandledStatusCodes { get; }Property Value
- IReadOnlyCollection<HttpStatusCode>
- A read-only collection of HttpStatusCode values that are treated as transient errors.
Methods
CanHandle(HttpStatusCode)
Determines whether this handler can process the specified HTTP status code.
public sealed override bool CanHandle(HttpStatusCode statusCode)Parameters
statusCodeHttpStatusCode- The HTTP status code to evaluate.
