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
handler
HttpMessageHandlerThe handler we are wrapping.
basePriority
PriorityThe base priority of the request.
priority
intThe priority of the request.
maxBytesToRead
long?The maximum number of bytes we can read.
opQueue
OperationQueueThe operation queue on which to run the operation.
cacheResultFunc
Func<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
maxBytesToRead
long?The maximum number of bytes to read.
SendAsync(HttpRequestMessage, CancellationToken)
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Parameters
request
HttpRequestMessagecancellationToken
CancellationToken
Returns
UniqueKeyForRequest(HttpRequestMessage)
Generates a unique key for a HttpRequestMessage. This assists with the caching.
public static string UniqueKeyForRequest(HttpRequestMessage request)
Parameters
request
HttpRequestMessageThe request to generate a unique key for.
Returns
- string
The unique key.