Class RateLimitedHttpMessageHandler
- Namespace
- Fusillade
- Assembly
- Fusillade.dll
A http handler which will limit the rate at which we can read.
public class RateLimitedHttpMessageHandler : LimitingHttpMessageHandler, IDisposable
- Inheritance
-
RateLimitedHttpMessageHandler
- Implements
- Inherited Members
- Extension Methods
Remarks
Initializes a new instance of the RateLimitedHttpMessageHandler class.
Constructors
RateLimitedHttpMessageHandler(HttpMessageHandler?, Priority, int, long?, OperationQueue?, Func<HttpRequestMessage, HttpResponseMessage, string, CancellationToken, Task>?)
A http handler which will limit the rate at which we can read.
public RateLimitedHttpMessageHandler(HttpMessageHandler? handler, Priority basePriority, int priority = 0, long? maxBytesToRead = null, OperationQueue? opQueue = null, Func<HttpRequestMessage, HttpResponseMessage, string, CancellationToken, Task>? cacheResultFunc = null)
Parameters
handlerHttpMessageHandlerThe handler we are wrapping.
basePriorityPriorityThe base priority of the request.
priorityintThe priority of the request.
maxBytesToReadlong?The maximum number of bytes we can read.
opQueueOperationQueueThe operation queue on which to run the operation.
cacheResultFuncFunc<HttpRequestMessage, HttpResponseMessage, string, CancellationToken, Task>A method that is called if we need to get cached results.
Remarks
Initializes a new instance of the RateLimitedHttpMessageHandler class.
Methods
ResetLimit(long?)
Resets the total limit of bytes to read. This is usually called when the app resumes from suspend, to indicate that we should fetch another set of data.
public override void ResetLimit(long? maxBytesToRead = null)
Parameters
maxBytesToReadlong?The maximum number of bytes to read.
SendAsync(HttpRequestMessage, CancellationToken)
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Parameters
requestHttpRequestMessagecancellationTokenCancellationToken
Returns
UniqueKeyForRequest(HttpRequestMessage)
Generates a unique key for a HttpRequestMessage. This assists with the caching.
public static string UniqueKeyForRequest(HttpRequestMessage request)
Parameters
requestHttpRequestMessageThe request to generate a unique key for.
Returns
- string
The unique key.