ringcentral / RingCentral.Net

RingCentral SDK for .NET
MIT License
19 stars 26 forks source link

Rate limit header not found in RateLimitExtension #53

Closed agaskill closed 1 year ago

agaskill commented 1 year ago

Occasionally the API will respond with a 429 with no rate limit headers, see example:

HTTP/1.1 429 Unknown
Content-Length: 22
Content-Type: text/html; charset=UTF-8

429 Too Many Requests.

In this case the RateLimitExtension gets an error because it expects the X-RateLimit-Window header to be present:

System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The given header was not found.
   at System.Net.Http.Headers.HttpHeaders.GetValues(String name)
   at RingCentral.Net.RateLimit.RateLimitExtension.<>c__DisplayClass1_0.<DefaultOptions>b__1(RestException restException, Int32 retriesAttempted)
   at RingCentral.Net.Retry.RetryExtension.<>c__DisplayClass2_0.<<Install>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

It should be using TryGetValues instead of GetValues since the header may not exist in the response.

tylerlong commented 1 year ago

Released 1.0.2