C# Class WebApiThrottle.ThrottlingHandler

Inheritance: System.Net.Http.DelegatingHandler
Mostra file Open project: stefanprodan/WebApiThrottle

Public Methods

Method Description
ThrottlingHandler ( ) : System

Initializes a new instance of the ThrottlingHandler class. By default, the QuotaExceededResponseCode property is set to 429 (Too Many Requests).

ThrottlingHandler ( WebApiThrottle.ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger, IIpAddressParser ipAddressParser = null ) : System

Initializes a new instance of the ThrottlingHandler class. Persists the policy object in cache using IPolicyRepository implementation. The policy object can be updated by ThrottleManager at runtime.

Protected Methods

Method Description
ComputeThrottleKey ( RequestIdentity requestIdentity, RateLimitPeriod period ) : string
GetClientIp ( HttpRequestMessage request ) : IPAddress
QuotaExceededResponse ( HttpRequestMessage request, object content, HttpStatusCode responseCode, string retryAfter ) : Task
SendAsync ( HttpRequestMessage request, CancellationToken cancellationToken ) : Task
SetIdentity ( HttpRequestMessage request ) : RequestIdentity

Method Details

ComputeThrottleKey() protected method

protected ComputeThrottleKey ( RequestIdentity requestIdentity, RateLimitPeriod period ) : string
requestIdentity RequestIdentity
period RateLimitPeriod
return string

GetClientIp() protected method

protected GetClientIp ( HttpRequestMessage request ) : IPAddress
request System.Net.Http.HttpRequestMessage
return System.Net.IPAddress

QuotaExceededResponse() protected method

protected QuotaExceededResponse ( HttpRequestMessage request, object content, HttpStatusCode responseCode, string retryAfter ) : Task
request System.Net.Http.HttpRequestMessage
content object
responseCode HttpStatusCode
retryAfter string
return Task

SendAsync() protected method

protected SendAsync ( HttpRequestMessage request, CancellationToken cancellationToken ) : Task
request System.Net.Http.HttpRequestMessage
cancellationToken System.Threading.CancellationToken
return Task

SetIdentity() protected method

protected SetIdentity ( HttpRequestMessage request ) : RequestIdentity
request System.Net.Http.HttpRequestMessage
return RequestIdentity

ThrottlingHandler() public method

Initializes a new instance of the ThrottlingHandler class. By default, the QuotaExceededResponseCode property is set to 429 (Too Many Requests).
public ThrottlingHandler ( ) : System
return System

ThrottlingHandler() public method

Initializes a new instance of the ThrottlingHandler class. Persists the policy object in cache using IPolicyRepository implementation. The policy object can be updated by ThrottleManager at runtime.
public ThrottlingHandler ( WebApiThrottle.ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger, IIpAddressParser ipAddressParser = null ) : System
policy WebApiThrottle.ThrottlePolicy /// The policy. ///
policyRepository IPolicyRepository /// The policy repository. ///
repository IThrottleRepository /// The repository. ///
logger IThrottleLogger /// The logger. ///
ipAddressParser IIpAddressParser /// The IpAddressParser ///
return System