Browse Source

Readded 502 handling

tags/1.0-rc
RogueException 9 years ago
parent
commit
6545509ade
2 changed files with 7 additions and 1 deletions
  1. +5
    -0
      src/Discord.Net/Net/Queue/RequestQueueBucket.cs
  2. +2
    -1
      src/Discord.Net/Net/Rest/DefaultRestClient.cs

+ 5
- 0
src/Discord.Net/Net/Queue/RequestQueueBucket.cs View File

@@ -1,6 +1,7 @@
#pragma warning disable CS4014 #pragma warning disable CS4014
using System; using System;
using System.IO; using System.IO;
using System.Net;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;


@@ -68,6 +69,10 @@ namespace Discord.Net.Queue
//We have all our semaphores, send the request //We have all our semaphores, send the request
return await request.SendAsync().ConfigureAwait(false); return await request.SendAsync().ConfigureAwait(false);
} }
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.BadGateway)
{
continue;
}
catch (HttpRateLimitException ex) catch (HttpRateLimitException ex)
{ {
Pause(ex.RetryAfterMilliseconds); Pause(ex.RetryAfterMilliseconds);


+ 2
- 1
src/Discord.Net/Net/Rest/DefaultRestClient.cs View File

@@ -127,7 +127,8 @@ namespace Discord.Net.Rest
if (statusCode == 429) if (statusCode == 429)
{ {
//TODO: Include bucket info //TODO: Include bucket info
throw new HttpRateLimitException(int.Parse(response.Headers.GetValues("retry-after").First()));
int retryAfterMillis = int.Parse(response.Headers.GetValues("retry-after").First());
throw new HttpRateLimitException(retryAfterMillis);
} }


string reason = null; string reason = null;


Loading…
Cancel
Save